diff options
author | Kenneth Chew <kenneth.c0@protonmail.com> | 2022-04-15 18:25:37 -0400 |
---|---|---|
committer | Kenneth Chew <kenneth.c0@protonmail.com> | 2022-04-15 18:26:41 -0400 |
commit | 1303771b58a213a25faaa1a870c774fbb72e7513 (patch) | |
tree | 597bb563aeb820aba8d70fa5e041eae8f1d3ef81 /launcher/ui | |
parent | f6605bc3f82df4a3f190bb9e1d935de295329b54 (diff) | |
download | PrismLauncher-1303771b58a213a25faaa1a870c774fbb72e7513.tar.gz PrismLauncher-1303771b58a213a25faaa1a870c774fbb72e7513.tar.bz2 PrismLauncher-1303771b58a213a25faaa1a870c774fbb72e7513.zip |
Add option to always show menu bar instead of toolbar
For those who like keyboard navigation at the expense of aesthetics.
Diffstat (limited to 'launcher/ui')
-rw-r--r-- | launcher/ui/MainWindow.cpp | 17 | ||||
-rw-r--r-- | launcher/ui/MainWindow.h | 2 | ||||
-rw-r--r-- | launcher/ui/pages/global/LauncherPage.cpp | 7 | ||||
-rw-r--r-- | launcher/ui/pages/global/LauncherPage.ui | 34 |
4 files changed, 49 insertions, 11 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index a51aea8a..c144231d 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -309,6 +309,7 @@ public: void createMainToolbar(QMainWindow *MainWindow) { mainToolBar = TranslatedToolbar(MainWindow); + mainToolBar->setVisible(menuBar->isNativeMenuBar() || !APPLICATION->settings()->get("MenuBarInsteadOfToolBar").toBool()); mainToolBar->setObjectName(QStringLiteral("mainToolBar")); mainToolBar->setMovable(true); mainToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); @@ -471,8 +472,7 @@ public: void createMenuBar(MainWindow *MainWindow) { menuBar = new QMenuBar(MainWindow); - // There's already a toolbar, so hide this menu bar by default unless 'alt' is pressed on systems without native menu bar - menuBar->setVisible(false); + menuBar->setVisible(APPLICATION->settings()->get("MenuBarInsteadOfToolBar").toBool()); createMenuActions(MainWindow); // TODO: only enable options while an instance is selected (if applicable) @@ -909,10 +909,10 @@ public: MainWindow->setAccessibleName(BuildConfig.LAUNCHER_NAME); #endif - createMainToolbar(MainWindow); - createMenuBar(dynamic_cast<class MainWindow *>(MainWindow)); + createMainToolbar(MainWindow); + centralWidget = new QWidget(MainWindow); centralWidget->setObjectName(QStringLiteral("centralWidget")); horizontalLayout = new QHBoxLayout(centralWidget); @@ -1135,7 +1135,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow #ifndef Q_OS_MAC void MainWindow::keyReleaseEvent(QKeyEvent *event) { - if(event->key()==Qt::Key_Alt) + if(event->key()==Qt::Key_Alt && !APPLICATION->settings()->get("MenuBarInsteadOfToolBar").toBool()) ui->menuBar->setVisible(!ui->menuBar->isVisible()); else QMainWindow::keyReleaseEvent(event); @@ -1294,6 +1294,12 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos) myMenu.exec(view->mapToGlobal(pos)); } +void MainWindow::updateMainToolBar() +{ + ui->menuBar->setVisible(APPLICATION->settings()->get("MenuBarInsteadOfToolBar").toBool()); + ui->mainToolBar->setVisible(ui->menuBar->isNativeMenuBar() || !APPLICATION->settings()->get("MenuBarInsteadOfToolBar").toBool()); +} + void MainWindow::updateToolsMenu() { QToolButton *launchButton = dynamic_cast<QToolButton*>(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstance)); @@ -1966,6 +1972,7 @@ void MainWindow::globalSettingsClosed() APPLICATION->instances()->loadList(); proxymodel->invalidate(); proxymodel->sort(0); + updateMainToolBar(); updateToolsMenu(); updateStatusCenter(); update(); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index c38ee073..5424a4a9 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -151,6 +151,8 @@ private slots: void showInstanceContextMenu(const QPoint &); + void updateMainToolBar(); + void updateToolsMenu(); void instanceActivated(QModelIndex); diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 42ad5ae3..a213eff0 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -41,6 +41,7 @@ #include <QMessageBox> #include <QDir> #include <QTextCharFormat> +#include <QMenuBar> #include "updater/UpdateChecker.h" @@ -322,6 +323,8 @@ void LauncherPage::applySettings() APPLICATION->setApplicationTheme(newAppTheme, false); } + s->set("MenuBarInsteadOfToolBar", ui->preferMenuBarCheckBox->isChecked()); + // Console settings s->set("ShowConsole", ui->showConsoleCheck->isChecked()); s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); @@ -410,6 +413,10 @@ void LauncherPage::loadSettings() } } + // Toolbar/menu bar settings (not applicable if native menu bar is present) + ui->toolsBox->setVisible(!QMenuBar().isNativeMenuBar()); + ui->preferMenuBarCheckBox->setChecked(s->get("MenuBarInsteadOfToolBar").toBool()); + // Console settings ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool()); diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index c110dd09..636aec15 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -290,6 +290,16 @@ </item> </widget> </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Colors</string> + </property> + <property name="buddy"> + <cstring>themeComboBoxColors</cstring> + </property> + </widget> + </item> <item row="1" column="1"> <widget class="QComboBox" name="themeComboBoxColors"> <property name="sizePolicy"> @@ -303,13 +313,25 @@ </property> </widget> </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="toolsBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Tools</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QCheckBox" name="preferMenuBarCheckBox"> <property name="text"> - <string>Colors</string> - </property> - <property name="buddy"> - <cstring>themeComboBoxColors</cstring> + <string>Always show menu bar instead of tool bar (more keyboard friendly, less pretty)</string> </property> </widget> </item> |