summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@digia.com>2014-07-14 15:11:07 +0200
committerAlessandro Portale <alessandro.portale@digia.com>2014-09-24 11:34:23 +0200
commit1fc8e089d805f79618bcdab06542c6159f072b15 (patch)
tree8d093254f2ecc48feb887eb101694b24f948a038 /src
parent0fe2c752731b25afe2b9f033e9d3abb442ebdc15 (diff)
Windows: devicePixelRatio aware QWindowsTheme::standardPixmap
QWindowsTheme::standardPixmap() takes a size parameter which is in user space coordinates. This patch causes it to calculate the size in device pixels, to get the image from the OS in the correct resolution and to set the devicePixelratio of the returned pixmap accordingly. Change-Id: Ifad5d0a26d5fd5945e37e432787d63ee79269295 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index a23b3cb4bb..69b04ef0cb 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -51,6 +51,7 @@
#include "qwindowsintegration.h"
#include "qt_windows.h"
#include "qwindowsfontdatabase.h"
+#include "qwindowsscaling.h"
#ifdef Q_OS_WINCE
# include "qplatformfunctions_wince.h"
# include "winuser.h"
@@ -491,6 +492,8 @@ static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
{
+ const int scaleFactor = QWindowsScaling::factor();
+ const QSizeF pixmapSize = size * scaleFactor;
int resourceId = -1;
LPCTSTR iconName = 0;
switch (sp) {
@@ -557,9 +560,10 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con
SHSTOCKICONINFO iconInfo;
memset(&iconInfo, 0, sizeof(iconInfo));
iconInfo.cbSize = sizeof(iconInfo);
- const int iconSize = size.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON;
+ const int iconSize = pixmapSize.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON;
if (QWindowsContext::shell32dll.sHGetStockIconInfo(SIID_SHIELD, SHGFI_ICON | iconSize, &iconInfo) == S_OK) {
pixmap = qt_pixmapFromWinHICON(iconInfo.hIcon);
+ pixmap.setDevicePixelRatio(scaleFactor);
DestroyIcon(iconInfo.hIcon);
return pixmap;
}
@@ -571,13 +575,14 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con
}
if (resourceId != -1) {
- QPixmap pixmap = loadIconFromShell32(resourceId, size);
+ QPixmap pixmap = loadIconFromShell32(resourceId, pixmapSize);
if (!pixmap.isNull()) {
if (sp == FileLinkIcon || sp == DirLinkIcon || sp == DirLinkOpenIcon) {
QPainter painter(&pixmap);
- QPixmap link = loadIconFromShell32(30, size);
- painter.drawPixmap(0, 0, size.width(), size.height(), link);
+ QPixmap link = loadIconFromShell32(30, pixmapSize);
+ painter.drawPixmap(0, 0, pixmapSize.width(), pixmapSize.height(), link);
}
+ pixmap.setDevicePixelRatio(scaleFactor);
return pixmap;
}
}
@@ -585,6 +590,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con
if (iconName) {
HICON iconHandle = LoadIcon(NULL, iconName);
QPixmap pixmap = qt_pixmapFromWinHICON(iconHandle);
+ pixmap.setDevicePixelRatio(scaleFactor);
DestroyIcon(iconHandle);
if (!pixmap.isNull())
return pixmap;