diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index ac0cbf0b8..242e8a2f8 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -36,6 +36,7 @@ public: BoolSetting alternateMessageBackground = {"/appearance/messages/alternateMessageBackground", false}; IntSetting uiScale = {"/appearance/uiScale", 0}; + BoolSetting lockUiScale = {"/appearance/lockUiScale", false}; BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false}; BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true}; BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton", false}; diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 4077200df..5f663a363 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -497,7 +497,7 @@ int WindowManager::clampUiScale(int scale) float WindowManager::getUiScaleValue() { - return getUiScaleValue(getApp()->settings->uiScale.getValue()); + return getUiScaleValue(getSettings()->uiScale.getValue()); } float WindowManager::getUiScaleValue(int scale) diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index 00a841684..b8410032c 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -54,12 +54,16 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags) this->init(); this->connections_.managedConnect( - getApp()->settings->uiScale.getValueChangedSignal(), + getSettings()->uiScale.getValueChangedSignal(), [this](auto, auto) { postToThread([this] { this->updateScale(); }); }); this->updateScale(); - createWindowShortcut(this, "CTRL+0", [] { getApp()->settings->uiScale.setValue(0); }); + createWindowShortcut(this, "CTRL+0", [] { + if (!getSettings()->lockUiScale.getValue()) { + getSettings()->uiScale.setValue(0); + } + }); // QTimer::this->scaleChangedEvent(this->getScale()); } @@ -255,11 +259,15 @@ void BaseWindow::wheelEvent(QWheelEvent *event) if (event->modifiers() & Qt::ControlModifier) { if (event->delta() > 0) { - getApp()->settings->uiScale.setValue( - WindowManager::clampUiScale(getApp()->settings->uiScale.getValue() + 1)); + if (!getSettings()->lockUiScale.getValue()) { + getSettings()->uiScale.setValue( + WindowManager::clampUiScale(getSettings()->uiScale.getValue() + 1)); + } } else { - getApp()->settings->uiScale.setValue( - WindowManager::clampUiScale(getApp()->settings->uiScale.getValue() - 1)); + if (!getSettings()->lockUiScale.getValue()) { + getSettings()->uiScale.setValue( + WindowManager::clampUiScale(getSettings()->uiScale.getValue() - 1)); + } } } } diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 2ba2b9a3b..ef876524d 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -263,8 +263,10 @@ void Window::addShortcuts() auto s = new QShortcut(QKeySequence::ZoomIn, this); s->setContext(Qt::WindowShortcut); QObject::connect(s, &QShortcut::activated, this, [] { - getApp()->settings->uiScale.setValue( - WindowManager::clampUiScale(getApp()->settings->uiScale.getValue() + 1)); + if (!getSettings()->lockUiScale.getValue()) { + getSettings()->uiScale.setValue( + WindowManager::clampUiScale(getSettings()->uiScale.getValue() + 1)); + } }); } @@ -273,8 +275,10 @@ void Window::addShortcuts() auto s = new QShortcut(QKeySequence::ZoomOut, this); s->setContext(Qt::WindowShortcut); QObject::connect(s, &QShortcut::activated, this, [] { - getApp()->settings->uiScale.setValue( - WindowManager::clampUiScale(getApp()->settings->uiScale.getValue() - 1)); + if (!getSettings()->lockUiScale.getValue()) { + getSettings()->uiScale.setValue( + WindowManager::clampUiScale(getSettings()->uiScale.getValue() - 1)); + } }); } diff --git a/src/widgets/settingspages/LookPage.cpp b/src/widgets/settingspages/LookPage.cpp index b0d9baaf2..e2323ee23 100644 --- a/src/widgets/settingspages/LookPage.cpp +++ b/src/widgets/settingspages/LookPage.cpp @@ -86,6 +86,8 @@ void LookPage::addInterfaceTab(LayoutCreator layout) box.append(this->createUiScaleSlider()); } + layout.append(this->createCheckBox("Lock window scale hotkeys", getSettings()->lockUiScale)); + layout.append(this->createCheckBox(WINDOW_TOPMOST, getSettings()->windowTopMost)); // --