summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2017-02-08 17:29:41 +0100
committerKai Uwe Broulik <[email protected]>2017-02-08 17:30:11 +0100
commitf7e84d0de6e9066c13b4cd1986d6eed535d88490 (patch)
tree4afff7555f2a3085bb875139f68a3cb4db4748f5
parente9632c13a97d81ac41b8d579683da2b7109de5e5 (diff)
[Icons KCM] Take into account device pixel ratio for icon preview
While at it, fill the pixmap with transparent color instead of window color as the background inside a tab page in Breeze is lighter than the window. Differential Revision: https://phabricator.kde.org/D4504
-rw-r--r--kcms/icons/iconthemes.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/kcms/icons/iconthemes.cpp b/kcms/icons/iconthemes.cpp
index 1eb9510..69e8af1 100644
--- a/kcms/icons/iconthemes.cpp
+++ b/kcms/icons/iconthemes.cpp
@@ -396,15 +396,19 @@ void IconThemesConfig::updateRemoveButton()
void loadPreview(QLabel *label, KIconTheme& icontheme, const QStringList& iconnames)
{
+ const qreal dpr = label->devicePixelRatioF();
+
//Given the icontheme loads a preview of an icon (several names are allowed for old theme standards) into the pixmap of the given label
- const int size = qMin(48, icontheme.defaultSize(KIconLoader::Desktop));
+ const int size = qMin(48, icontheme.defaultSize(KIconLoader::Desktop)) * dpr;
QSvgRenderer renderer;
foreach(const QString &iconthemename, QStringList() << icontheme.internalName() << icontheme.inherits()) {
foreach(const QString &name, iconnames) {
//load the icon image
QString path = KIconTheme(iconthemename).iconPath(QStringLiteral("%1.png").arg(name), size, KIconLoader::MatchBest);
if (path != QString()) {
- label->setPixmap(QPixmap(path).scaled(size, size));
+ QPixmap pixmap(path);
+ pixmap.setDevicePixelRatio(dpr);
+ label->setPixmap(pixmap.scaled(size, size));
return;
}
//could not find the .png, try loading the .svg or .svgz
@@ -416,8 +420,9 @@ void loadPreview(QLabel *label, KIconTheme& icontheme, const QStringList& iconna
}
}
if (renderer.load(path)) {
- QPixmap pix(size, size);
- pix.fill(label->palette().color(QPalette::Background));
+ QPixmap pix(size * dpr, size * dpr);
+ pix.setDevicePixelRatio(dpr);
+ pix.fill(QColor(Qt::transparent));
QPainter p(&pix);
p.setViewport(0, 0, size, size);
renderer.render(&p);