From 63619f68d4d80a78f9f5a5df236ee2b17c4de806 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Wed, 21 Apr 2021 08:26:15 +0200 Subject: [PATCH] qskGlobalScalefactor added --- src/common/QskFunctions.cpp | 33 ++++++++++++++++----------------- src/common/QskFunctions.h | 1 + 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/common/QskFunctions.cpp b/src/common/QskFunctions.cpp index 5552d42f..6917b108 100644 --- a/src/common/QskFunctions.cpp +++ b/src/common/QskFunctions.cpp @@ -8,6 +8,15 @@ QSK_QT_PRIVATE_BEGIN #include + +#if QT_VERSION < QT_VERSION_CHECK( 5, 8, 0 ) + #ifndef foreach + // qhighdpiscaling_p.h needs it + #define foreach Q_FOREACH + #endif +#endif + +#include QSK_QT_PRIVATE_END #include @@ -162,6 +171,13 @@ qreal qskHorizontalAdvance( const QFontMetricsF& fontMetrics, const QString& tex #endif } +qreal qskGlobalScaleFactor() +{ + // The value of QT_SCALE_FACTOR + const QScreen* noScreen = nullptr; + return QHighDpiScaling::factor( noScreen ); +} + bool qskHasPlatformWindowManagement() { if ( auto platform = QGuiApplicationPrivate::platformIntegration() ) @@ -177,20 +193,3 @@ QRect qskPlatformScreenGeometry( const QScreen* screen ) return screen->handle()->geometry(); } - -#if 0 - -// does not compile with Qt 5.6 TODO ... - -QSK_QT_PRIVATE_BEGIN -#include -QSK_QT_PRIVATE_END - -qreal qskGlobalScaleFactor() -{ - // The value of QT_SCALE_FACTOR - const QScreen* noScreen = nullptr; - return QHighDpiScaling::factor( noScreen ); -} - -#endif diff --git a/src/common/QskFunctions.h b/src/common/QskFunctions.h index 6f509a75..ea8ba764 100644 --- a/src/common/QskFunctions.h +++ b/src/common/QskFunctions.h @@ -17,6 +17,7 @@ class QFontMetricsF; class QString; QSK_EXPORT qreal qskDpiScaled( qreal value ); +QSK_EXPORT qreal qskGlobalScaleFactor(); QSK_EXPORT bool qskHasPlatformWindowManagement(); QSK_EXPORT QRect qskPlatformScreenGeometry( const QScreen* );