diff options
author | David Schulz <david.schulz@qt.io> | 2023-04-19 10:14:43 +0200 |
---|---|---|
committer | Marcus Tillmanns <marcus.tillmanns@qt.io> | 2023-12-13 15:10:51 +0100 |
commit | 0d9387a942cd947ed04527661c9628c491484ba4 (patch) | |
tree | c43b4785088a35c2afccbc893ef3d548a3689662 /src/gui/image | |
parent | 2b7908ac3ad437c209485dcf00d1e53c98d78cb3 (diff) |
QIcon: prefer downscaling over upscaling pixmap icons
... instead of just choosing the closest scaling factor.
Otherwise we end up with the 1x pixmap for a 1.25 scaling factor instead
of a the better fitting 2x pixmap.
Task-number: QTBUG-90634
Change-Id: Ic554fc8d2715deea43bc22e71414902a263b2fef
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 41f9e7541e..35f6cad4e2 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -169,6 +169,9 @@ static QPixmapIconEngineEntry *bestSizeScaleMatch(const QSize &size, qreal scale qreal ascore = pa->scale - scale; qreal bscore = pb->scale - scale; + // always prefer positive scores to prevent upscaling + if ((ascore < 0) != (bscore < 0)) + return bscore < 0 ? pa : pb; // Take the one closest to 0 return (qAbs(ascore) < qAbs(bscore)) ? pa : pb; } |