Prefer QIcon::pixmap(QWindow*, ...) overload

Summary:
It takes into account the dpi of the screen we're rendering to.
Other overloads assume the window is nullptr and will use the primary screen's dpi which can change almost randomly.

Test Plan: Icons still look fine even if I drag windows from a screen to another.

Reviewers: #plasma, #frameworks, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: davidedmundson, ngraham, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D29102
This commit is contained in:
Aleix Pol 2020-04-22 18:00:19 +02:00
parent 77be3197e2
commit 25ce2b90da
2 changed files with 2 additions and 2 deletions

View File

@ -598,7 +598,7 @@ void IconItem::loadPixmap()
}
} else if (!m_icon.isNull()) {
KIconLoader::global()->setCustomPalette(Plasma::Theme().palette());
result = m_icon.pixmap(QSize(size, size) * (window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()));
result = m_icon.pixmap(window(), QSize(size, size));
KIconLoader::global()->resetPalette();
} else if (!m_imageIcon.isNull()) {
result = QPixmap::fromImage(m_imageIcon);

View File

@ -381,7 +381,7 @@ void WindowThumbnail::iconToTexture(WindowTextureNode *textureNode)
// fallback to plasma icon
icon = QIcon::fromTheme(QStringLiteral("plasma"));
}
QImage image = icon.pixmap(boundingRect().size().toSize()).toImage();
QImage image = icon.pixmap(window(), boundingRect().size().toSize()).toImage();
textureNode->reset(window()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas));
}