Lock window scale hotkeys

This commit is contained in:
hemirt 2018-07-07 17:23:24 +02:00
parent 2ea3643100
commit bcd2676754
5 changed files with 26 additions and 11 deletions

View file

@ -36,6 +36,7 @@ public:
BoolSetting alternateMessageBackground = {"/appearance/messages/alternateMessageBackground", BoolSetting alternateMessageBackground = {"/appearance/messages/alternateMessageBackground",
false}; false};
IntSetting uiScale = {"/appearance/uiScale", 0}; IntSetting uiScale = {"/appearance/uiScale", 0};
BoolSetting lockUiScale = {"/appearance/lockUiScale", false};
BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false}; BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false};
BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true}; BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true};
BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton", false}; BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton", false};

View file

@ -497,7 +497,7 @@ int WindowManager::clampUiScale(int scale)
float WindowManager::getUiScaleValue() float WindowManager::getUiScaleValue()
{ {
return getUiScaleValue(getApp()->settings->uiScale.getValue()); return getUiScaleValue(getSettings()->uiScale.getValue());
} }
float WindowManager::getUiScaleValue(int scale) float WindowManager::getUiScaleValue(int scale)

View file

@ -54,12 +54,16 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
this->init(); this->init();
this->connections_.managedConnect( this->connections_.managedConnect(
getApp()->settings->uiScale.getValueChangedSignal(), getSettings()->uiScale.getValueChangedSignal(),
[this](auto, auto) { postToThread([this] { this->updateScale(); }); }); [this](auto, auto) { postToThread([this] { this->updateScale(); }); });
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()); // QTimer::this->scaleChangedEvent(this->getScale());
} }
@ -255,11 +259,15 @@ void BaseWindow::wheelEvent(QWheelEvent *event)
if (event->modifiers() & Qt::ControlModifier) { if (event->modifiers() & Qt::ControlModifier) {
if (event->delta() > 0) { if (event->delta() > 0) {
getApp()->settings->uiScale.setValue( if (!getSettings()->lockUiScale.getValue()) {
WindowManager::clampUiScale(getApp()->settings->uiScale.getValue() + 1)); getSettings()->uiScale.setValue(
WindowManager::clampUiScale(getSettings()->uiScale.getValue() + 1));
}
} else { } else {
getApp()->settings->uiScale.setValue( if (!getSettings()->lockUiScale.getValue()) {
WindowManager::clampUiScale(getApp()->settings->uiScale.getValue() - 1)); getSettings()->uiScale.setValue(
WindowManager::clampUiScale(getSettings()->uiScale.getValue() - 1));
}
} }
} }
} }

View file

@ -263,8 +263,10 @@ void Window::addShortcuts()
auto s = new QShortcut(QKeySequence::ZoomIn, this); auto s = new QShortcut(QKeySequence::ZoomIn, this);
s->setContext(Qt::WindowShortcut); s->setContext(Qt::WindowShortcut);
QObject::connect(s, &QShortcut::activated, this, [] { QObject::connect(s, &QShortcut::activated, this, [] {
getApp()->settings->uiScale.setValue( if (!getSettings()->lockUiScale.getValue()) {
WindowManager::clampUiScale(getApp()->settings->uiScale.getValue() + 1)); getSettings()->uiScale.setValue(
WindowManager::clampUiScale(getSettings()->uiScale.getValue() + 1));
}
}); });
} }
@ -273,8 +275,10 @@ void Window::addShortcuts()
auto s = new QShortcut(QKeySequence::ZoomOut, this); auto s = new QShortcut(QKeySequence::ZoomOut, this);
s->setContext(Qt::WindowShortcut); s->setContext(Qt::WindowShortcut);
QObject::connect(s, &QShortcut::activated, this, [] { QObject::connect(s, &QShortcut::activated, this, [] {
getApp()->settings->uiScale.setValue( if (!getSettings()->lockUiScale.getValue()) {
WindowManager::clampUiScale(getApp()->settings->uiScale.getValue() - 1)); getSettings()->uiScale.setValue(
WindowManager::clampUiScale(getSettings()->uiScale.getValue() - 1));
}
}); });
} }

View file

@ -86,6 +86,8 @@ void LookPage::addInterfaceTab(LayoutCreator<QVBoxLayout> layout)
box.append(this->createUiScaleSlider()); box.append(this->createUiScaleSlider());
} }
layout.append(this->createCheckBox("Lock window scale hotkeys", getSettings()->lockUiScale));
layout.append(this->createCheckBox(WINDOW_TOPMOST, getSettings()->windowTopMost)); layout.append(this->createCheckBox(WINDOW_TOPMOST, getSettings()->windowTopMost));
// -- // --