diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-04 13:53:19 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2019-08-23 01:41:33 +0000 |
commit | d603ee689f0e3fdcfa3230b3d75cdce6c5af05c1 (patch) | |
tree | ffc037205f5bdad40adfca36abde8f7676832b3e /src/widgets/styles/qstylehelper_p.h | |
parent | f1e40dd6d6968c59885231f61f94787abd4cf783 (diff) |
Widget style: Use per-screen DPI in QStyleHelper::dpiScaled()
Pass the style option to dpiScaled() in order to get
the correct screen DPI. The style option contains the
font, which again contains the current DPI value.
Add QFontMetrics::fontDpi() accessors to get the DPI
from the QFont. This DPI will/should be updated on screen
change.
Replace hardcoded Q_OS_MAC DPI with hardcoded base
DPI. This makes per-screen DPI testable on macOS, too.
Task-number: QTBUG-45055
Change-Id: I75f8b37d45eb50c3334b46b8469a546d29712f1b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/widgets/styles/qstylehelper_p.h')
-rw-r--r-- | src/widgets/styles/qstylehelper_p.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index fe052b8984..165608257a 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -40,6 +40,7 @@ #include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtCore/qpoint.h> #include <QtCore/qstring.h> +#include <QtGui/qpaintdevice.h> #include <QtGui/qpolygon.h> #include <QtCore/qstringbuilder.h> #include <QtGui/qaccessible.h> @@ -75,7 +76,13 @@ class QWindow; namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size); - Q_WIDGETS_EXPORT qreal dpiScaled(qreal value); + + Q_WIDGETS_EXPORT qreal dpi(const QStyleOption *option); + + Q_WIDGETS_EXPORT qreal dpiScaled(qreal value, qreal dpi); + Q_WIDGETS_EXPORT qreal dpiScaled(qreal value, const QPaintDevice *device); + Q_WIDGETS_EXPORT qreal dpiScaled(qreal value, const QStyleOption *option); + #if QT_CONFIG(dial) qreal angle(const QPointF &p1, const QPointF &p2); QPolygonF calcLines(const QStyleOptionSlider *dial); |