diff --git a/examples/automotive/SkinFactory.cpp b/examples/automotive/SkinFactory.cpp index a53e69e6..a44bcf62 100644 --- a/examples/automotive/SkinFactory.cpp +++ b/examples/automotive/SkinFactory.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include diff --git a/skins/material/QskMaterialSkin.cpp b/skins/material/QskMaterialSkin.cpp index c33c2596..412ff975 100644 --- a/skins/material/QskMaterialSkin.cpp +++ b/skins/material/QskMaterialSkin.cpp @@ -34,11 +34,12 @@ #include #include #include -#include #include -#include #include +#include +#include + #if 1 // should be defined in the public header, so that // application code can avoid conflicts diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index 08421e47..3ea2406f 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/common/QskFunctions.cpp b/src/common/QskFunctions.cpp index ef54f77c..a0c1f2ca 100644 --- a/src/common/QskFunctions.cpp +++ b/src/common/QskFunctions.cpp @@ -1,28 +1,8 @@ #include "QskFunctions.h" -#include -#include -#include #include #include - -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 -#include - -#include +#include template< class Rect, class Value > static inline Rect qskAlignedRect( const Rect& outerRect, @@ -142,23 +122,6 @@ QRectF qskValidOrEmptyInnerRect( const QRectF& rect, const QMarginsF& margins ) return QRectF( x, y, w, h ); } -qreal qskDpiScaled( qreal value ) -{ - static qreal factor = 0.0; - - if ( factor <= 0.0 ) - { - if ( const QScreen* screen = QGuiApplication::primaryScreen() ) - factor = screen->logicalDotsPerInchX(); - else - factor = 100.0; - - factor /= 96.0; - } - - return value * factor; -} - qreal qskHorizontalAdvance( const QFont& font, const QString& text ) { return qskHorizontalAdvance( QFontMetricsF( font ), text ); @@ -173,37 +136,6 @@ 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 ); -} - -const QPlatformIntegration* qskPlatformIntegration() -{ - return QGuiApplicationPrivate::platformIntegration(); -} - -bool qskMaybeDesktopPlatform() -{ -#if QT_CONFIG(cursor) - // this is what QC2 is doing for menus ? - if ( const auto platform = QGuiApplicationPrivate::platformIntegration() ) - return platform->hasCapability( QPlatformIntegration::MultipleWindows ); -#endif - - return false; -} - -QRect qskPlatformScreenGeometry( const QScreen* screen ) -{ - if ( screen == nullptr ) - return QRect(); - - return screen->handle()->geometry(); -} - qreal qskFuzzyFloor( qreal value, qreal stepSize ) { const double eps = 1.0e-6 * stepSize; diff --git a/src/common/QskFunctions.h b/src/common/QskFunctions.h index 2d0d5dbe..2855a2be 100644 --- a/src/common/QskFunctions.h +++ b/src/common/QskFunctions.h @@ -11,18 +11,9 @@ #include #include -class QScreen; class QFont; class QFontMetricsF; class QString; -class QPlatformIntegration; - -QSK_EXPORT qreal qskDpiScaled( qreal value ); -QSK_EXPORT qreal qskGlobalScaleFactor(); - -QSK_EXPORT bool qskMaybeDesktopPlatform(); -QSK_EXPORT const QPlatformIntegration* qskPlatformIntegration(); -QSK_EXPORT QRect qskPlatformScreenGeometry( const QScreen* ); QSK_EXPORT QRect qskAlignedRect( const QRect& outerRect, int width, int height, Qt::Alignment alignment ); diff --git a/src/common/QskPlatform.cpp b/src/common/QskPlatform.cpp new file mode 100644 index 00000000..1b4b7620 --- /dev/null +++ b/src/common/QskPlatform.cpp @@ -0,0 +1,70 @@ +#include "QskPlatform.h" + +#include +#include + +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 +#include + +qreal qskDpiScaled( qreal value ) +{ + static qreal factor = 0.0; + + if ( factor <= 0.0 ) + { + if ( const auto screen = QGuiApplication::primaryScreen() ) + factor = screen->logicalDotsPerInchX(); + else + factor = 100.0; + + factor /= 96.0; + } + + return value * factor; +} + +qreal qskGlobalScaleFactor() +{ + // The value of QT_SCALE_FACTOR + const QScreen* noScreen = nullptr; + return QHighDpiScaling::factor( noScreen ); +} + +const QPlatformIntegration* qskPlatformIntegration() +{ + return QGuiApplicationPrivate::platformIntegration(); +} + +bool qskMaybeDesktopPlatform() +{ +#if QT_CONFIG(cursor) + // this is what QC2 is doing for menus ? + if ( const auto platform = QGuiApplicationPrivate::platformIntegration() ) + return platform->hasCapability( QPlatformIntegration::MultipleWindows ); +#endif + + return false; +} + +QRect qskPlatformScreenGeometry( const QScreen* screen ) +{ + if ( screen == nullptr ) + return QRect(); + + return screen->handle()->geometry(); +} + + diff --git a/src/common/QskPlatform.h b/src/common/QskPlatform.h new file mode 100644 index 00000000..9184df0c --- /dev/null +++ b/src/common/QskPlatform.h @@ -0,0 +1,22 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the QSkinny License, Version 1.0 + *****************************************************************************/ + +#ifndef QSK_PLATFORM_H +#define QSK_PLATFORM_H + +#include "QskGlobal.h" + +class QScreen; +class QPlatformIntegration; +class QRect; + +QSK_EXPORT qreal qskDpiScaled( qreal value ); +QSK_EXPORT qreal qskGlobalScaleFactor(); + +QSK_EXPORT bool qskMaybeDesktopPlatform(); +QSK_EXPORT const QPlatformIntegration* qskPlatformIntegration(); +QSK_EXPORT QRect qskPlatformScreenGeometry( const QScreen* ); + +#endif diff --git a/src/controls/QskPopup.cpp b/src/controls/QskPopup.cpp index fb952bf4..dd203e0d 100644 --- a/src/controls/QskPopup.cpp +++ b/src/controls/QskPopup.cpp @@ -9,7 +9,7 @@ #include "QskQuick.h" #include "QskWindow.h" #include "QskEvent.h" -#include "QskFunctions.h" +#include "QskPlatform.h" #include diff --git a/src/controls/QskSubWindow.cpp b/src/controls/QskSubWindow.cpp index a36dc85d..b6acca87 100644 --- a/src/controls/QskSubWindow.cpp +++ b/src/controls/QskSubWindow.cpp @@ -5,7 +5,7 @@ #include "QskSubWindow.h" #include "QskAspect.h" -#include "QskFunctions.h" +#include "QskPlatform.h" #include "QskGraphic.h" #include "QskGraphicProvider.h" #include "QskTextOptions.h" diff --git a/src/controls/QskSubWindowArea.cpp b/src/controls/QskSubWindowArea.cpp index d3a5451b..66648eb5 100644 --- a/src/controls/QskSubWindowArea.cpp +++ b/src/controls/QskSubWindowArea.cpp @@ -5,7 +5,7 @@ #include "QskSubWindowArea.h" #include "QskEvent.h" -#include "QskFunctions.h" +#include "QskPlatform.h" #include "QskSubWindow.h" #include diff --git a/src/src.pro b/src/src.pro index 134e460c..f2db71f7 100644 --- a/src/src.pro +++ b/src/src.pro @@ -28,6 +28,7 @@ HEADERS += \ common/QskMetaInvokable.h \ common/QskNamespace.h \ common/QskObjectCounter.h \ + common/QskPlatform.h \ common/QskRgbValue.h \ common/QskRgbPalette.h \ common/QskScaleEngine.h \ @@ -52,6 +53,7 @@ SOURCES += \ common/QskMetaFunction.cpp \ common/QskMetaInvokable.cpp \ common/QskObjectCounter.cpp \ + common/QskPlatform.cpp \ common/QskRgbValue.cpp \ common/QskRgbPalette.cpp \ common/QskScaleEngine.cpp \