summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/miniprojecttargetselector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/projectexplorer/miniprojecttargetselector.cpp')
-rw-r--r--src/plugins/projectexplorer/miniprojecttargetselector.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp
index 25270eb353..7a3e31565e 100644
--- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp
+++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp
@@ -59,21 +59,42 @@
#include <QAction>
#include <QItemDelegate>
+#if QT_VERSION >= 0x050100
+#include <QGuiApplication>
+#endif
+
static QIcon createCenteredIcon(const QIcon &icon, const QIcon &overlay)
{
QPixmap targetPixmap;
- targetPixmap = QPixmap(Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE);
+ qreal appDevicePixelRatio = 1.0;
+#if QT_VERSION >= 0x050100
+ appDevicePixelRatio = qApp->devicePixelRatio();
+#endif
+ int deviceSpaceIconSize = Core::Constants::TARGET_ICON_SIZE * appDevicePixelRatio;
+ targetPixmap = QPixmap(deviceSpaceIconSize, deviceSpaceIconSize);
+#if QT_VERSION >= 0x050100
+ targetPixmap.setDevicePixelRatio(appDevicePixelRatio);
+#endif
targetPixmap.fill(Qt::transparent);
- QPainter painter(&targetPixmap);
-
- QPixmap pixmap = icon.pixmap(Core::Constants::TARGET_ICON_SIZE);
- painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width())/2,
- (Core::Constants::TARGET_ICON_SIZE - pixmap.height())/2, pixmap);
+ QPainter painter(&targetPixmap); // painter in user space
+
+ QPixmap pixmap = icon.pixmap(Core::Constants::TARGET_ICON_SIZE); // already takes app devicePixelRatio into account
+ qreal pixmapDevicePixelRatio = 1.0;
+#if QT_VERSION >= 0x050100
+ pixmapDevicePixelRatio = pixmap.devicePixelRatio();
+#endif
+ painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width() / pixmapDevicePixelRatio) / 2,
+ (Core::Constants::TARGET_ICON_SIZE - pixmap.height() / pixmapDevicePixelRatio) / 2, pixmap);
if (!overlay.isNull()) {
- pixmap = overlay.pixmap(Core::Constants::TARGET_ICON_SIZE);
- painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width())/2,
- (Core::Constants::TARGET_ICON_SIZE - pixmap.height())/2, pixmap);
+ pixmap = overlay.pixmap(Core::Constants::TARGET_ICON_SIZE); // already takes app devicePixelRatio into account
+ pixmapDevicePixelRatio = 1.0;
+#if QT_VERSION >= 0x050100
+ pixmapDevicePixelRatio = pixmap.devicePixelRatio();
+#endif
+ painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width() / pixmapDevicePixelRatio) / 2,
+ (Core::Constants::TARGET_ICON_SIZE - pixmap.height() / pixmapDevicePixelRatio) / 2, pixmap);
}
+
return QIcon(targetPixmap);
}