diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-07-31 10:23:39 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-08-01 13:20:23 +0200 |
commit | 174061f9f32ac76c6b8a6d155d772e37708d8cfc (patch) | |
tree | 44845c0ef7b52dee6e524ce86fa3554ed560ece6 /src/gui/kernel/qhighdpiscaling_p.h | |
parent | 3d7bd7ad19254bb1c4794349e71501e58c91891e (diff) |
QHighDPI: Fix broken scaling of QPoint(F)
For some reason, the overload resolution of the
High DPI scale() functions introduced by
b6ded193ee64ffe67df6d22e7a23aa1ea9e02ec7 chose the
wrong overloads for QPointF and/or QPoint; it fell
back to the generic template intended for qreal,
QSize, etc, ignoring the origin. Remove the
template and spell out all overloads.
Fixes: QTBUG-77255
Change-Id: I5661f16f7326f65156f646f430f5a0c71d5302d2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel/qhighdpiscaling_p.h')
-rw-r--r-- | src/gui/kernel/qhighdpiscaling_p.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 3410c1d345..c43641b8c9 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -59,6 +59,7 @@ #include <QtCore/qloggingcategory.h> #include <QtGui/qregion.h> #include <QtGui/qscreen.h> +#include <QtGui/qvector2d.h> #include <QtGui/qwindow.h> QT_BEGIN_NAMESPACE @@ -117,13 +118,26 @@ private: namespace QHighDpi { -template <typename T> -inline T scale(const T &value, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +inline qreal scale(qreal value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) { - Q_UNUSED(origin) return value * scaleFactor; } +inline QSize scale(const QSize &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * scaleFactor; +} + +inline QSizeF scale(const QSizeF &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * scaleFactor; +} + +inline QVector2D scale(const QVector2D &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * float(scaleFactor); +} + inline QPointF scale(const QPointF &pos, qreal scaleFactor, QPointF origin = QPointF(0, 0)) { return (pos - origin) * scaleFactor + origin; |