diff options
| author | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
|---|---|---|
| committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
| commit | 9f831dde07cb2411808534e76669b28a1b76e21d (patch) | |
| tree | ed6252d64c9a3ab27aa93786272cda1b6008f3c7 /src/plugins/projectexplorer/miniprojecttargetselector.cpp | |
| parent | cdac81f896ef4b052d76f96485a08e6ec13696b8 (diff) | |
| parent | ea1a92484ac99057b06130a012164bf9788650e9 (diff) | |
| download | qt-creator-wip/clang.tar.gz | |
Merge remote-tracking branch 'origin/master' into wip/clangwip/clang
Change-Id: I8a2c8068a3f2b15034fb1bf6304c9a0f3f0e3c8f
Diffstat (limited to 'src/plugins/projectexplorer/miniprojecttargetselector.cpp')
| -rw-r--r-- | src/plugins/projectexplorer/miniprojecttargetselector.cpp | 39 |
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); } |
