From acf1730093c050a3316047eca66ca0cbb2f88a20 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sat, 11 Sep 2021 20:42:20 -0500 Subject: Add a toggle for the Alt key showing the menubar --- src/mainwindow.cpp | 10 +++++--- src/settings.cpp | 10 ++++++++ src/settings.h | 5 ++++ src/settingsdialog.ui | 53 +++++++++++++++++++++++++++---------------- src/settingsdialoggeneral.cpp | 2 ++ 5 files changed, 57 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4d1c16ac..a7d7bddb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3645,10 +3645,14 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event) { // if the ui is locked, ignore the ALT key event // alt-tabbing out of a game triggers this - if (!UILocker::instance().locked()) { - // if the menubar is hidden, pressing Alt will make it visible + auto& uilocker = UILocker::instance(); + auto& settings = Settings::instance(); + if (!uilocker.locked()) { + // if the menubar is hidden and showMenuBarOnAlt is true, + // pressing Alt will make it visible if (event->key() == Qt::Key_Alt) { - if (!ui->menuBar->isVisible()) { + bool showMenubarOnAlt = settings.interface().showMenubarOnAlt(); + if (showMenubarOnAlt && !ui->menuBar->isVisible()) { ui->menuBar->show(); } } diff --git a/src/settings.cpp b/src/settings.cpp index 1e915603..d3cdc910 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2301,6 +2301,16 @@ void InterfaceSettings::setShowChangeGameConfirmation(bool b) set(m_Settings, "Settings", "show_change_game_confirmation", b); } +bool InterfaceSettings::showMenubarOnAlt() const +{ + return get(m_Settings, "Settings", "show_menubar_on_alt", true); +} + +void InterfaceSettings::setShowMenubarOnAlt(bool b) +{ + set(m_Settings, "Settings", "show_menubar_on_alt", b); +} + bool InterfaceSettings::doubleClicksOpenPreviews() const { return get(m_Settings, "Settings", "double_click_previews", true); diff --git a/src/settings.h b/src/settings.h index 6ddee308..d886e806 100644 --- a/src/settings.h +++ b/src/settings.h @@ -688,6 +688,11 @@ public: bool showChangeGameConfirmation() const; void setShowChangeGameConfirmation(bool b); + // whether to show the menubar when pressing the Alt key + // + bool showMenubarOnAlt() const; + void setShowMenubarOnAlt(bool b); + // whether double-clicks on files should try to open previews first // bool doubleClicksOpenPreviews() const; diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 434136ce..22bdfccd 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -23,8 +23,8 @@ General - - + + #generalScrollArea { background-color: transparent; } @@ -44,8 +44,8 @@ 0 0 - 778 - 501 + 780 + 502 @@ -82,7 +82,7 @@ 9 - + Qt::Horizontal @@ -95,17 +95,7 @@ - - - - The language of the user interface. - - - The language of the user interface. - - - - + https://discord.gg/NRGqdt5suP @@ -118,6 +108,16 @@ + + + + The language of the user interface. + + + The language of the user interface. + + + @@ -242,6 +242,19 @@ + + + + Show the menubar when the Alt key is pressed + + + Show the menubar when the Alt key is pressed + + + Show menubar when pressing Alt + + + @@ -1009,8 +1022,8 @@ If you disable this feature, MO will only display official DLCs this way. Please 0 0 - 778 - 501 + 780 + 502 @@ -1689,8 +1702,8 @@ If you disable this feature, MO will only display official DLCs this way. Please 0 0 - 778 - 482 + 780 + 483 diff --git a/src/settingsdialoggeneral.cpp b/src/settingsdialoggeneral.cpp index 27038918..b0f40882 100644 --- a/src/settingsdialoggeneral.cpp +++ b/src/settingsdialoggeneral.cpp @@ -27,6 +27,7 @@ GeneralSettingsTab::GeneralSettingsTab(Settings& s, SettingsDialog& d) // miscellaneous ui->centerDialogs->setChecked(settings().geometry().centerDialogs()); ui->changeGameConfirmation->setChecked(settings().interface().showChangeGameConfirmation()); + ui->showMenubarOnAlt->setChecked(settings().interface().showMenubarOnAlt()); ui->doubleClickPreviews->setChecked(settings().interface().doubleClicksOpenPreviews()); QObject::connect( @@ -60,6 +61,7 @@ void GeneralSettingsTab::update() // miscellaneous settings().geometry().setCenterDialogs(ui->centerDialogs->isChecked()); settings().interface().setShowChangeGameConfirmation(ui->changeGameConfirmation->isChecked()); + settings().interface().setShowMenubarOnAlt(ui->showMenubarOnAlt->isChecked()); settings().interface().setDoubleClicksOpenPreviews(ui->doubleClickPreviews->isChecked()); } -- cgit v1.3.1 From b261f3a1e57babc0e05dc7eae037c9dc3adf6ca7 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Thu, 16 Sep 2021 15:49:28 -0500 Subject: Revert row changes --- src/settingsdialog.ui | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 22bdfccd..a4c9cc7e 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -24,7 +24,7 @@ General - + #generalScrollArea { background-color: transparent; } @@ -82,7 +82,7 @@ 9 - + Qt::Horizontal @@ -95,7 +95,7 @@ - + https://discord.gg/NRGqdt5suP @@ -108,7 +108,7 @@ - + The language of the user interface. -- cgit v1.3.1