some helper functions, for retrieving information from the platform

abstraction
This commit is contained in:
Uwe Rathmann 2020-03-10 10:17:44 +01:00
parent e75937f711
commit d92c20e924
2 changed files with 36 additions and 0 deletions

View File

@ -4,6 +4,14 @@
#include <qmath.h>
#include <qscreen.h>
QSK_QT_PRIVATE_BEGIN
#include <private/qhighdpiscaling_p.h>
#include <private/qguiapplication_p.h>
QSK_QT_PRIVATE_END
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformscreen.h>
template< class Rect, class Value >
static inline Rect qskAlignedRect( const Rect& outerRect,
Value width, Value height, Qt::Alignment alignment )
@ -138,3 +146,26 @@ qreal qskDpiScaled( qreal value )
return value * factor;
}
qreal qskGlobalScaleFactor()
{
// The value of QT_SCALE_FACTOR
const QScreen* noScreen = nullptr;
return QHighDpiScaling::factor( noScreen );
}
bool qskHasPlatformWindowManagement()
{
if ( auto platform = QGuiApplicationPrivate::platformIntegration() )
return platform->hasCapability( QPlatformIntegration::WindowManagement );
return false;
}
QRect qskPlatformScreenGeometry( const QScreen* screen )
{
if ( screen == nullptr )
return QRect();
return screen->handle()->geometry();
}

View File

@ -11,7 +11,12 @@
#include <qmargins.h>
#include <qrect.h>
class QScreen;
QSK_EXPORT qreal qskDpiScaled( qreal value );
QSK_EXPORT qreal qskGlobalScaleFactor();
QSK_EXPORT bool qskHasPlatformWindowManagement();
QSK_EXPORT QRect qskPlatformScreenGeometry( const QScreen* );
QSK_EXPORT QRect qskAlignedRect( const QRect& outerRect,
int width, int height, Qt::Alignment alignment );