mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Lock window scale hotkeys
This commit is contained in:
parent
2ea3643100
commit
bcd2676754
5 changed files with 26 additions and 11 deletions
|
@ -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};
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,8 @@ void LookPage::addInterfaceTab(LayoutCreator<QVBoxLayout> layout)
|
|||
box.append(this->createUiScaleSlider());
|
||||
}
|
||||
|
||||
layout.append(this->createCheckBox("Lock window scale hotkeys", getSettings()->lockUiScale));
|
||||
|
||||
layout.append(this->createCheckBox(WINDOW_TOPMOST, getSettings()->windowTopMost));
|
||||
|
||||
// --
|
||||
|
|
Loading…
Reference in a new issue