Skip to content

Commit

Permalink
chore: Move s_logicalDpiFactorOverride to Platform_qt
Browse files Browse the repository at this point in the history
So it can be reused for Slint for now
  • Loading branch information
iamsergio committed Aug 2, 2024
1 parent bf0b7e4 commit ed6f4f6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/qtcommon/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,16 @@ 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))
{
// 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
Expand Down
2 changes: 2 additions & 0 deletions src/qtcommon/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions src/qtcommon/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions src/qtwidgets/views/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "kddockwidgets/core/Controller.h"
#include "kddockwidgets/qtcommon/View.h"
#include "kddockwidgets/qtcommon/Platform.h"

#include <QDebug>
#include <QEvent>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed6f4f6

Please sign in to comment.