Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't attempt to scale windows opted out of scaling #5400

Merged
merged 4 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/widgets/BaseWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,9 +931,26 @@ void BaseWindow::updateScale()

this->setScale(scale);

for (auto *child : this->findChildren<BaseWidget *>())
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<BaseWidget *>(obj);
if (base)
{
auto *window = dynamic_cast<BaseWindow *>(obj);
if (window && window->flags_.has(DisableCustomScaling))
{
continue; // stop here
}
base->setScale(scale);
}

applyScaleRecursive(obj, scale);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/widgets/BaseWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dialogs/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void SettingsDialog::filterElements(const QString &text)
auto *item = this->ui_.tabContainer->itemAt(i);
if (auto *x = dynamic_cast<QSpacerItem *>(item); x)
{
x->changeSize(10, shouldShowSpace ? int(16 * this->scale()) : 0);
x->changeSize(10, shouldShowSpace ? 16 : 0);
shouldShowSpace = false;
}
else if (item->widget())
Expand Down
Loading