From 862fd345fe6b9ff0f787411b8487c2c1ccb556de Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 21 Apr 2016 12:38:26 +0200 Subject: [PATCH] Icons: Additionally add lower resolutions to QIcons in HighDPI mode The lower resolution(s) are needed in setups where attached Displays have different scale factors and Qt Creator is dragged to the lower resolution screens. Task-number: QTCREATORBUG-16128 Change-Id: I20a2e67e4ac5929f3cffc9d7b25e340257be0cee Reviewed-by: Eike Ziller --- src/libs/utils/icon.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libs/utils/icon.cpp b/src/libs/utils/icon.cpp index 37b6878c963..138a3ddbd9d 100644 --- a/src/libs/utils/icon.cpp +++ b/src/libs/utils/icon.cpp @@ -183,12 +183,15 @@ QIcon Icon::icon() const return QIcon(combinedPlainPixmaps(*this)); } else { QIcon result; - const MasksAndColors masks = masksAndColors(*this, qRound(qApp->devicePixelRatio())); - const QPixmap combinedMask = Utils::combinedMask(masks, m_style); - result.addPixmap(masksToIcon(masks, combinedMask, m_style)); + const int maxDpr = qRound(qApp->devicePixelRatio()); + for (int dpr = 1; dpr <= maxDpr; dpr++) { + const MasksAndColors masks = masksAndColors(*this, dpr); + const QPixmap combinedMask = Utils::combinedMask(masks, m_style); + result.addPixmap(masksToIcon(masks, combinedMask, m_style)); - const QColor disabledColor = creatorTheme()->color(Theme::IconsDisabledColor); - result.addPixmap(maskToColorAndAlpha(combinedMask, disabledColor), QIcon::Disabled); + const QColor disabledColor = creatorTheme()->color(Theme::IconsDisabledColor); + result.addPixmap(maskToColorAndAlpha(combinedMask, disabledColor), QIcon::Disabled); + } return result; } }