forked from github_mirror/framelesshelper
fix build on Qt version < 6.2.1
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
48a1106fc0
commit
7daa1facc7
|
@ -377,7 +377,7 @@ enum class WindowEdge : quint32
|
||||||
Left = 0x00000001,
|
Left = 0x00000001,
|
||||||
Top = 0x00000002,
|
Top = 0x00000002,
|
||||||
Right = 0x00000004,
|
Right = 0x00000004,
|
||||||
Bottom = 0x00000010
|
Bottom = 0x00000008
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(WindowEdge)
|
Q_ENUM_NS(WindowEdge)
|
||||||
Q_DECLARE_FLAGS(WindowEdges, WindowEdge)
|
Q_DECLARE_FLAGS(WindowEdges, WindowEdge)
|
||||||
|
|
|
@ -305,20 +305,15 @@ bool Utils::shouldAppsUseDarkMode()
|
||||||
|
|
||||||
qreal Utils::roundScaleFactor(const qreal factor)
|
qreal Utils::roundScaleFactor(const qreal factor)
|
||||||
{
|
{
|
||||||
Q_ASSERT(factor > 0);
|
// Qt can't handle scale factors less than 1.0 (according to the comments in qhighdpiscaling.cpp).
|
||||||
if (factor <= 0) {
|
Q_ASSERT(factor >= 1);
|
||||||
|
if (factor < 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
#if (defined(FRAMELESSHELPER_CORE_NO_PRIVATE) || (QT_VERSION < QT_VERSION_CHECK(6, 2, 1)))
|
||||||
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
static const auto policy = QGuiApplication::highDpiScaleFactorRoundingPolicy();
|
static const auto policy = QGuiApplication::highDpiScaleFactorRoundingPolicy();
|
||||||
switch (policy) {
|
switch (policy) {
|
||||||
case Qt::HighDpiScaleFactorRoundingPolicy::Unset:
|
|
||||||
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
||||||
return factor;
|
|
||||||
# else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
|
||||||
return qRound(factor);
|
|
||||||
# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
||||||
case Qt::HighDpiScaleFactorRoundingPolicy::Round:
|
case Qt::HighDpiScaleFactorRoundingPolicy::Round:
|
||||||
return qRound(factor);
|
return qRound(factor);
|
||||||
case Qt::HighDpiScaleFactorRoundingPolicy::Ceil:
|
case Qt::HighDpiScaleFactorRoundingPolicy::Ceil:
|
||||||
|
@ -328,13 +323,14 @@ qreal Utils::roundScaleFactor(const qreal factor)
|
||||||
case Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor:
|
case Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor:
|
||||||
return (((factor - qreal(int(factor))) >= qreal(0.75)) ? qRound(factor) : qFloor(factor));
|
return (((factor - qreal(int(factor))) >= qreal(0.75)) ? qRound(factor) : qFloor(factor));
|
||||||
case Qt::HighDpiScaleFactorRoundingPolicy::PassThrough:
|
case Qt::HighDpiScaleFactorRoundingPolicy::PassThrough:
|
||||||
|
case Qt::HighDpiScaleFactorRoundingPolicy::Unset: // According to Qt source code, this enum value is the same with PassThrough.
|
||||||
return factor;
|
return factor;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
# else // (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
# else // (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
||||||
return qRound(factor);
|
return qRound(factor);
|
||||||
# endif // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
# endif // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
#else // (!FRAMELESSHELPER_CORE_NO_PRIVATE && (QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))
|
||||||
return QHighDpiScaling::roundScaleFactor(factor);
|
return QHighDpiScaling::roundScaleFactor(factor);
|
||||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue