From 5facb0ce90008dfc7014029a81ef6d4cd2626a46 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 19 Jan 2015 16:00:21 +0100 Subject: D-Bus tray icon: when eliminating large icons, scale to medium size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jørgen Lind --- src/platformsupport/dbustray/qdbustraytypes.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/platformsupport') 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 #include #include +#include #include #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 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 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); -- cgit v1.2.3