diff options
| author | Al <26797547+Al12rs@users.noreply.github.com> | 2021-10-13 13:12:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-13 13:12:21 +0200 |
| commit | 081fa3ec93668ef3944c70c5de422d51c667acf4 (patch) | |
| tree | 57deb6f7d3545868d0631cadefd90fd4a042d7ed | |
| parent | b5800435aa0c2396194f9e287d27a20c0e89203d (diff) | |
| parent | b261f3a1e57babc0e05dc7eae037c9dc3adf6ca7 (diff) | |
Merge pull request #1588 from Qudix/menubar_alt
Add a toggle for the Alt key showing the menubar
| -rw-r--r-- | src/mainwindow.cpp | 10 | ||||
| -rw-r--r-- | src/settings.cpp | 10 | ||||
| -rw-r--r-- | src/settings.h | 5 | ||||
| -rw-r--r-- | src/settingsdialog.ui | 47 | ||||
| -rw-r--r-- | src/settingsdialoggeneral.cpp | 2 |
5 files changed, 54 insertions, 20 deletions
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<bool>(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<bool>(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..a4c9cc7e 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -23,7 +23,7 @@ <attribute name="title"> <string>General</string> </attribute> - <layout class="QGridLayout" name="gridLayout" rowstretch="0"> + <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0"> <item row="0" column="0"> <widget class="QScrollArea" name="generalScrollArea"> <property name="styleSheet"> @@ -44,8 +44,8 @@ <rect> <x>0</x> <y>0</y> - <width>778</width> - <height>501</height> + <width>780</width> + <height>502</height> </rect> </property> <property name="autoFillBackground"> @@ -95,16 +95,6 @@ </property> </spacer> </item> - <item row="0" column="0"> - <widget class="QComboBox" name="languageBox"> - <property name="toolTip"> - <string>The language of the user interface.</string> - </property> - <property name="whatsThis"> - <string>The language of the user interface.</string> - </property> - </widget> - </item> <item row="0" column="1"> <widget class="LinkLabel" name="label_33"> <property name="toolTip"> @@ -118,6 +108,16 @@ </property> </widget> </item> + <item row="0" column="0"> + <widget class="QComboBox" name="languageBox"> + <property name="toolTip"> + <string>The language of the user interface.</string> + </property> + <property name="whatsThis"> + <string>The language of the user interface.</string> + </property> + </widget> + </item> </layout> </widget> </item> @@ -243,6 +243,19 @@ </widget> </item> <item> + <widget class="QCheckBox" name="showMenubarOnAlt"> + <property name="toolTip"> + <string>Show the menubar when the Alt key is pressed</string> + </property> + <property name="whatsThis"> + <string>Show the menubar when the Alt key is pressed</string> + </property> + <property name="text"> + <string>Show menubar when pressing Alt</string> + </property> + </widget> + </item> + <item> <widget class="QCheckBox" name="doubleClickPreviews"> <property name="toolTip"> <string>Whether double-clicking on a file opens the preview window or launches the program associated with it. This applies to the Data tab as well as the Conflicts and Filetree tabs in the mod info window.</string> @@ -1009,8 +1022,8 @@ If you disable this feature, MO will only display official DLCs this way. Please <rect> <x>0</x> <y>0</y> - <width>778</width> - <height>501</height> + <width>780</width> + <height>502</height> </rect> </property> <property name="autoFillBackground"> @@ -1689,8 +1702,8 @@ If you disable this feature, MO will only display official DLCs this way. Please <rect> <x>0</x> <y>0</y> - <width>778</width> - <height>482</height> + <width>780</width> + <height>483</height> </rect> </property> <property name="autoFillBackground"> 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()); } |
