summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2015-01-19 16:00:21 +0100
committerShawn Rutledge <shawn.rutledge@digia.com>2015-01-23 05:34:17 +0100
commit5facb0ce90008dfc7014029a81ef6d4cd2626a46 (patch)
treeb2c89e68a6f026a02602258572f21a7179256561 /src/platformsupport
parente910c36a3f5cdd01c1a7bebe409189fda2d128e2 (diff)
D-Bus tray icon: when eliminating large icons, scale to medium size
22px is not always large enough: KDE5 seems to like to make icons up to 28px, and they could be even larger on high-DPI screens. Change-Id: Ifa8e0d49b310e4b4304207596f0f32c36a5db6a7 Reviewed-by: Dmitry Shachnev <mitya57@gmail.com> Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/dbustray/qdbustraytypes.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/platformsupport/dbustray/qdbustraytypes.cpp b/src/platformsupport/dbustray/qdbustraytypes.cpp
index bd64c59274..de0c3c30a6 100644
--- a/src/platformsupport/dbustray/qdbustraytypes.cpp
+++ b/src/platformsupport/dbustray/qdbustraytypes.cpp
@@ -45,27 +45,33 @@
#include <QDebug>
#include <QtEndian>
#include <QPainter>
+#include <QGuiApplication>
#include <qpa/qplatformmenu.h>
#include "qdbusplatformmenu_p.h"
QT_BEGIN_NAMESPACE
-static const int IconSizeLimit = 32;
-static const int IconNormalSmallSize = 22;
+static const int IconSizeLimit = 64 * qGuiApp->devicePixelRatio();
+static const int IconNormalSmallSize = 22 * qGuiApp->devicePixelRatio();
+static const int IconNormalMediumSize = 64 * qGuiApp->devicePixelRatio();
QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon)
{
QXdgDBusImageVector ret;
QList<QSize> sizes = icon.availableSizes();
- // Omit any size larger than 32 px, to save D-Bus bandwidth;
- // and ensure that 22px or smaller exists, because it's a common size.
+ // Omit any size larger than 64 px, to save D-Bus bandwidth;
+ // ensure that 22px or smaller exists, because it's a common size;
+ // and ensure that something between 22px and 64px exists, for better scaling to other sizes.
bool hasSmallIcon = false;
+ bool hasMediumIcon = false;
QList<QSize> toRemove;
Q_FOREACH (const QSize &size, sizes) {
int maxSize = qMax(size.width(), size.height());
if (maxSize <= IconNormalSmallSize)
hasSmallIcon = true;
+ else if (maxSize <= IconNormalMediumSize)
+ hasMediumIcon = true;
else if (maxSize > IconSizeLimit)
toRemove << size;
}
@@ -73,7 +79,8 @@ QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon)
sizes.removeOne(size);
if (!hasSmallIcon)
sizes.append(QSize(IconNormalSmallSize, IconNormalSmallSize));
-
+ if (!hasMediumIcon)
+ sizes.append(QSize(IconNormalMediumSize, IconNormalMediumSize));
foreach (QSize size, sizes) {
// Protocol specifies ARGB32 format in network byte order
QImage im = icon.pixmap(size).toImage().convertToFormat(QImage::Format_ARGB32);