summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-11-19 01:00:11 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-11-19 01:00:12 +0100
commit587f1cbc5d9bbac019be7877e2847f25b7afb52c (patch)
tree15390cd7d30e167a15f44f0cf1ef40067bda4c97 /src/gui/image
parente19345987714f4f76c8d7075355980b154adbc44 (diff)
parentd17094df60d7d05bb583d26fb8d1de1a7a4fb072 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qicon.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index df8220a0c6..84e387e317 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -165,6 +165,11 @@ QIconPrivate::QIconPrivate(QIconEngine *e)
qreal QIconPrivate::pixmapDevicePixelRatio(qreal displayDevicePixelRatio, const QSize &requestedSize, const QSize &actualSize)
{
QSize targetSize = requestedSize * displayDevicePixelRatio;
+ if ((actualSize.width() == targetSize.width() && actualSize.height() <= targetSize.height()) ||
+ (actualSize.width() <= targetSize.width() && actualSize.height() == targetSize.height())) {
+ // Correctly scaled for dpr, just having different aspect ratio
+ return displayDevicePixelRatio;
+ }
qreal scale = 0.5 * (qreal(actualSize.width()) / qreal(targetSize.width()) +
qreal(actualSize.height() / qreal(targetSize.height())));
return qMax(qreal(1.0), displayDevicePixelRatio *scale);
@@ -185,7 +190,12 @@ QPixmapIconEngine::~QPixmapIconEngine()
void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
{
- QSize pixmapSize = rect.size() * qt_effective_device_pixel_ratio(0);
+ qreal dpr = 1.0;
+ if (QCoreApplication::testAttribute(Qt::AA_UseHighDpiPixmaps)) {
+ auto paintDevice = painter->device();
+ dpr = paintDevice ? paintDevice->devicePixelRatioF() : qApp->devicePixelRatio();
+ }
+ const QSize pixmapSize = rect.size() * dpr;
QPixmap px = pixmap(pixmapSize, mode, state);
painter->drawPixmap(rect, px);
}