Commit e75bd17e authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

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: default avatarMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
parent ff49c564
No related merge requests found
Showing with 2 additions and 8 deletions
......@@ -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
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment