From ed6f4f61008a242ec3358acec4baffe871e3446d Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Fri, 2 Aug 2024 23:24:35 +0100 Subject: [PATCH] chore: Move s_logicalDpiFactorOverride to Platform_qt So it can be reused for Slint for now --- src/qtcommon/Platform.cpp | 4 +++- src/qtcommon/Platform.h | 2 ++ src/qtcommon/View.cpp | 4 ---- src/qtwidgets/views/View.h | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/qtcommon/Platform.cpp b/src/qtcommon/Platform.cpp index c5a6eac40..e5b7c2e29 100644 --- a/src/qtcommon/Platform.cpp +++ b/src/qtcommon/Platform.cpp @@ -181,6 +181,8 @@ Platform_qt::Platform_qt() #ifdef DOCKS_DEVELOPER_MODE +int Platform_qt::s_logicalDpiFactorOverride = 0; + // ctor used by the tests only Platform_qt::Platform_qt(QCoreApplication *) : m_globalEventFilter(new GlobalEventFilter(this)) @@ -188,7 +190,7 @@ Platform_qt::Platform_qt(QCoreApplication *) // We want stability during tests. // QMainWindow uses the factor for its margins, we don't want tests failing due // to off by 1 or 2 pixels. Use 96dpi everywhere. - View_qt::s_logicalDpiFactorOverride = 1; + Platform_qt::s_logicalDpiFactorOverride = 1; } #endif diff --git a/src/qtcommon/Platform.h b/src/qtcommon/Platform.h index 256683e26..9ab7cfd20 100644 --- a/src/qtcommon/Platform.h +++ b/src/qtcommon/Platform.h @@ -104,6 +104,8 @@ class DOCKS_EXPORT Platform_qt : public Core::Platform bool tests_waitForDeleted(Core::View *, int timeout = 2000) const override; bool tests_waitForDeleted(Core::Controller *, int timeout = 2000) const override; + static int s_logicalDpiFactorOverride; + #endif protected: diff --git a/src/qtcommon/View.cpp b/src/qtcommon/View.cpp index 12ffac356..030425d3d 100644 --- a/src/qtcommon/View.cpp +++ b/src/qtcommon/View.cpp @@ -28,10 +28,6 @@ using namespace KDDockWidgets::QtCommon; // clazy:excludeall=missing-qobject-macro -#if defined(DOCKS_DEVELOPER_MODE) -int View_qt::s_logicalDpiFactorOverride = 0; -#endif - class View_qt::EventFilter : public QObject { public: diff --git a/src/qtwidgets/views/View.h b/src/qtwidgets/views/View.h index d9dde3402..e57d13d8e 100644 --- a/src/qtwidgets/views/View.h +++ b/src/qtwidgets/views/View.h @@ -16,6 +16,7 @@ #include "kddockwidgets/core/Controller.h" #include "kddockwidgets/qtcommon/View.h" +#include "kddockwidgets/qtcommon/Platform.h" #include #include @@ -410,8 +411,8 @@ class DOCKS_EXPORT View : public Base, public QtCommon::View_qt inline qreal logicalDpiFactor(const QWidget *w) { #ifdef DOCKS_DEVELOPER_MODE - if (QtCommon::View_qt::s_logicalDpiFactorOverride > 0) - return QtCommon::View_qt::s_logicalDpiFactorOverride; + if (QtCommon::Platform_qt::s_logicalDpiFactorOverride > 0) + return QtCommon::Platform_qt::s_logicalDpiFactorOverride; #endif #ifdef Q_OS_MACOS