some functions copied from QskFunctions to QskPlatform
This commit is contained in:
parent
a4d34dfa54
commit
6c46c0160d
|
@ -20,6 +20,7 @@
|
||||||
#include <QskSkinTransition.h>
|
#include <QskSkinTransition.h>
|
||||||
#include <QskSkinHintTableEditor.h>
|
#include <QskSkinHintTableEditor.h>
|
||||||
#include <QskSkin.h>
|
#include <QskSkin.h>
|
||||||
|
#include <QskPlatform.h>
|
||||||
|
|
||||||
#include <QEasingCurve>
|
#include <QEasingCurve>
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,12 @@
|
||||||
#include <QskBoxBorderColors.h>
|
#include <QskBoxBorderColors.h>
|
||||||
#include <QskBoxBorderMetrics.h>
|
#include <QskBoxBorderMetrics.h>
|
||||||
#include <QskBoxShapeMetrics.h>
|
#include <QskBoxShapeMetrics.h>
|
||||||
#include <QskFunctions.h>
|
|
||||||
#include <QskMargins.h>
|
#include <QskMargins.h>
|
||||||
#include <QskNamespace.h>
|
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
|
||||||
|
#include <QskNamespace.h>
|
||||||
|
#include <QskPlatform.h>
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// should be defined in the public header, so that
|
// should be defined in the public header, so that
|
||||||
// application code can avoid conflicts
|
// application code can avoid conflicts
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <QskBoxBorderColors.h>
|
#include <QskBoxBorderColors.h>
|
||||||
#include <QskBoxBorderMetrics.h>
|
#include <QskBoxBorderMetrics.h>
|
||||||
#include <QskBoxShapeMetrics.h>
|
#include <QskBoxShapeMetrics.h>
|
||||||
#include <QskFunctions.h>
|
#include <QskPlatform.h>
|
||||||
#include <QskGradient.h>
|
#include <QskGradient.h>
|
||||||
#include <QskMargins.h>
|
#include <QskMargins.h>
|
||||||
#include <QskNamespace.h>
|
#include <QskNamespace.h>
|
||||||
|
|
|
@ -1,28 +1,8 @@
|
||||||
#include "QskFunctions.h"
|
#include "QskFunctions.h"
|
||||||
|
|
||||||
#include <qguiapplication.h>
|
|
||||||
#include <qmath.h>
|
|
||||||
#include <qscreen.h>
|
|
||||||
#include <qfont.h>
|
#include <qfont.h>
|
||||||
#include <qfontmetrics.h>
|
#include <qfontmetrics.h>
|
||||||
|
#include <qmath.h>
|
||||||
QSK_QT_PRIVATE_BEGIN
|
|
||||||
#include <private/qguiapplication_p.h>
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 8, 0 )
|
|
||||||
#ifndef foreach
|
|
||||||
// qhighdpiscaling_p.h needs it
|
|
||||||
#define foreach Q_FOREACH
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <private/qhighdpiscaling_p.h>
|
|
||||||
QSK_QT_PRIVATE_END
|
|
||||||
|
|
||||||
#include <qpa/qplatformintegration.h>
|
|
||||||
#include <qpa/qplatformscreen.h>
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
template< class Rect, class Value >
|
template< class Rect, class Value >
|
||||||
static inline Rect qskAlignedRect( const Rect& outerRect,
|
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 );
|
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 )
|
qreal qskHorizontalAdvance( const QFont& font, const QString& text )
|
||||||
{
|
{
|
||||||
return qskHorizontalAdvance( QFontMetricsF( font ), text );
|
return qskHorizontalAdvance( QFontMetricsF( font ), text );
|
||||||
|
@ -173,37 +136,6 @@ qreal qskHorizontalAdvance( const QFontMetricsF& fontMetrics, const QString& tex
|
||||||
#endif
|
#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 )
|
qreal qskFuzzyFloor( qreal value, qreal stepSize )
|
||||||
{
|
{
|
||||||
const double eps = 1.0e-6 * stepSize;
|
const double eps = 1.0e-6 * stepSize;
|
||||||
|
|
|
@ -11,18 +11,9 @@
|
||||||
#include <qmargins.h>
|
#include <qmargins.h>
|
||||||
#include <qrect.h>
|
#include <qrect.h>
|
||||||
|
|
||||||
class QScreen;
|
|
||||||
class QFont;
|
class QFont;
|
||||||
class QFontMetricsF;
|
class QFontMetricsF;
|
||||||
class QString;
|
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,
|
QSK_EXPORT QRect qskAlignedRect( const QRect& outerRect,
|
||||||
int width, int height, Qt::Alignment alignment );
|
int width, int height, Qt::Alignment alignment );
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include "QskPlatform.h"
|
||||||
|
|
||||||
|
#include <qguiapplication.h>
|
||||||
|
#include <qscreen.h>
|
||||||
|
|
||||||
|
QSK_QT_PRIVATE_BEGIN
|
||||||
|
#include <private/qguiapplication_p.h>
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK( 5, 8, 0 )
|
||||||
|
#ifndef foreach
|
||||||
|
// qhighdpiscaling_p.h needs it
|
||||||
|
#define foreach Q_FOREACH
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <private/qhighdpiscaling_p.h>
|
||||||
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
|
#include <qpa/qplatformintegration.h>
|
||||||
|
#include <qpa/qplatformscreen.h>
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -9,7 +9,7 @@
|
||||||
#include "QskQuick.h"
|
#include "QskQuick.h"
|
||||||
#include "QskWindow.h"
|
#include "QskWindow.h"
|
||||||
#include "QskEvent.h"
|
#include "QskEvent.h"
|
||||||
#include "QskFunctions.h"
|
#include "QskPlatform.h"
|
||||||
|
|
||||||
#include <qpa/qplatformintegration.h>
|
#include <qpa/qplatformintegration.h>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "QskSubWindow.h"
|
#include "QskSubWindow.h"
|
||||||
#include "QskAspect.h"
|
#include "QskAspect.h"
|
||||||
#include "QskFunctions.h"
|
#include "QskPlatform.h"
|
||||||
#include "QskGraphic.h"
|
#include "QskGraphic.h"
|
||||||
#include "QskGraphicProvider.h"
|
#include "QskGraphicProvider.h"
|
||||||
#include "QskTextOptions.h"
|
#include "QskTextOptions.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "QskSubWindowArea.h"
|
#include "QskSubWindowArea.h"
|
||||||
#include "QskEvent.h"
|
#include "QskEvent.h"
|
||||||
#include "QskFunctions.h"
|
#include "QskPlatform.h"
|
||||||
#include "QskSubWindow.h"
|
#include "QskSubWindow.h"
|
||||||
|
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
|
|
|
@ -28,6 +28,7 @@ HEADERS += \
|
||||||
common/QskMetaInvokable.h \
|
common/QskMetaInvokable.h \
|
||||||
common/QskNamespace.h \
|
common/QskNamespace.h \
|
||||||
common/QskObjectCounter.h \
|
common/QskObjectCounter.h \
|
||||||
|
common/QskPlatform.h \
|
||||||
common/QskRgbValue.h \
|
common/QskRgbValue.h \
|
||||||
common/QskRgbPalette.h \
|
common/QskRgbPalette.h \
|
||||||
common/QskScaleEngine.h \
|
common/QskScaleEngine.h \
|
||||||
|
@ -52,6 +53,7 @@ SOURCES += \
|
||||||
common/QskMetaFunction.cpp \
|
common/QskMetaFunction.cpp \
|
||||||
common/QskMetaInvokable.cpp \
|
common/QskMetaInvokable.cpp \
|
||||||
common/QskObjectCounter.cpp \
|
common/QskObjectCounter.cpp \
|
||||||
|
common/QskPlatform.cpp \
|
||||||
common/QskRgbValue.cpp \
|
common/QskRgbValue.cpp \
|
||||||
common/QskRgbPalette.cpp \
|
common/QskRgbPalette.cpp \
|
||||||
common/QskScaleEngine.cpp \
|
common/QskScaleEngine.cpp \
|
||||||
|
|
Loading…
Reference in New Issue