QIcon: Set the pixmap's dpr to 1.0 if the window is also set to 1.0

When the pixmap is initially from a higher device pixel ratio and it is
being used on a window that does not have a device pixel ratio other
than 1.0 set then the pixmap should also have it set to 1.0. This ensures
that the size of the pixmap is preserved and it is not scaled down as a
result on the normal display.

Change-Id: Ie5d96b3e1508867b723000bea182c8157640af02
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
bb10
Andy Shaw 2016-08-05 14:43:15 +02:00
parent 579283507c
commit 2ca4fd401b
1 changed files with 5 additions and 2 deletions

View File

@ -835,8 +835,11 @@ QPixmap QIcon::pixmap(QWindow *window, const QSize &size, Mode mode, State state
qreal devicePixelRatio = qt_effective_device_pixel_ratio(window);
// Handle the simple normal-dpi case:
if (!(devicePixelRatio > 1.0))
return d->engine->pixmap(size, mode, state);
if (!(devicePixelRatio > 1.0)) {
QPixmap pixmap = d->engine->pixmap(size, mode, state);
pixmap.setDevicePixelRatio(1.0);
return pixmap;
}
// Try get a pixmap that is big enough to be displayed at device pixel resolution.
QPixmap pixmap = d->engine->pixmap(size * devicePixelRatio, mode, state);