From d0d81fc95d576f365bf1fcf491c7dc1749f53197 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Fri, 17 May 2024 17:00:12 +0200 Subject: [PATCH 1/3] fix: don't attempt to scale windows opted out of scaling --- src/widgets/BaseWindow.cpp | 21 +++++++++++++++++++-- src/widgets/BaseWindow.hpp | 2 ++ src/widgets/dialogs/SettingsDialog.cpp | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index 08a13007ab9..8c3f4b8c05c 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -931,9 +931,26 @@ void BaseWindow::updateScale() this->setScale(scale); - for (auto *child : this->findChildren()) + BaseWindow::applyScaleRecursive(this, scale); +} + +// NOLINTNEXTLINE(misc-no-recursion) +void BaseWindow::applyScaleRecursive(QObject *root, float scale) +{ + for (QObject *obj : root->children()) { - child->setScale(scale); + auto *base = dynamic_cast(obj); + if (base) + { + auto *window = dynamic_cast(obj); + if (window && window->flags_.has(DisableCustomScaling)) + { + continue; // stop here + } + base->setScale(scale); + } + + applyScaleRecursive(obj, scale); } } diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index 02101cb6dc0..46ff56e7e38 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -131,6 +131,8 @@ class BaseWindow : public BaseWidget void drawCustomWindowFrame(QPainter &painter); void onFocusLost(); + static void applyScaleRecursive(QObject *root, float scale); + bool handleSHOWWINDOW(MSG *msg); bool handleSIZE(MSG *msg); bool handleMOVE(MSG *msg); diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 8b56f4903cd..2a71593eccf 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -196,7 +196,7 @@ void SettingsDialog::filterElements(const QString &text) auto *item = this->ui_.tabContainer->itemAt(i); if (auto *x = dynamic_cast(item); x) { - x->changeSize(10, shouldShowSpace ? int(16 * this->scale()) : 0); + x->changeSize(10, shouldShowSpace ? 16 : 0); shouldShowSpace = false; } else if (item->widget()) From d753dabb1eb60949d5964b3b196745dc7a746cbf Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Sat, 18 May 2024 11:42:38 +0200 Subject: [PATCH 2/3] fix: stop at any BaseWindow --- src/widgets/BaseWindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index 8c3f4b8c05c..bc8767e4999 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -943,9 +943,10 @@ void BaseWindow::applyScaleRecursive(QObject *root, float scale) if (base) { auto *window = dynamic_cast(obj); - if (window && window->flags_.has(DisableCustomScaling)) + if (window) { - continue; // stop here + // stop here, the window will get the event as well (via uiScale) + continue; } base->setScale(scale); } From 59b2726f6ee2657f1fcf98923f836ea9dfd37a0c Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Sat, 18 May 2024 11:46:49 +0200 Subject: [PATCH 3/3] chore: add changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66d5e9dbaa6..bc36e5d5aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - Minor: Add option to customise Moderation buttons with images. (#5369) - Minor: Colored usernames now update on the fly when changing the "Color @usernames" setting. (#5300) - Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378) -- Dev: Use Qt's high DPI scaling. (#4868) +- Dev: Use Qt's high DPI scaling. (#4868, #5400) - Dev: Add doxygen build target. (#5377) - Dev: Make printing of strings in tests easier. (#5379) - Dev: Refactor and document `Scrollbar`. (#5334, #5393)