QWindowsTheme::standardPixmap(): Do not create pixmaps with DPR.

The given size is mostly ignored and the resulting pixmaps typically end up
in a QIcon, which will clobber the DPR anyways when returning a pixmap
for a given size.
Moreover, returning a message box icon with a DPR > 1 when
high DPI scaling is active and Qt::AA_UseHighDpiPixmaps is not set
causes the pixmap to become too small due to some scaling error.

Task-number: QTBUG-52622
Change-Id: I8aaaa97667d6c168040e19b7edad9dfb7517f70f
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
bb10
Friedemann Kleint 2016-04-20 11:22:34 +02:00
parent ff49c56450
commit e75bd17e3d
1 changed files with 2 additions and 8 deletions

View File

@ -503,11 +503,8 @@ static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
return QPixmap();
}
QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSize) const
{
const QScreen *primaryScreen = QGuiApplication::primaryScreen();
const int scaleFactor = primaryScreen ? qRound(QHighDpiScaling::factor(primaryScreen)) : 1;
const QSizeF pixmapSize = size * scaleFactor;
int resourceId = -1;
LPCTSTR iconName = 0;
switch (sp) {
@ -577,7 +574,6 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con
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;
}
@ -596,7 +592,6 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con
QPixmap link = loadIconFromShell32(30, pixmapSize);
painter.drawPixmap(0, 0, int(pixmapSize.width()), int(pixmapSize.height()), link);
}
pixmap.setDevicePixelRatio(scaleFactor);
return pixmap;
}
}
@ -604,13 +599,12 @@ 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;
}
return QPlatformTheme::standardPixmap(sp, size);
return QPlatformTheme::standardPixmap(sp, pixmapSize);
}
enum { // Shell image list ids