From 02c3012215c9e926e55b91d5fd7d1c47a1d8d495 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Tue, 21 Jul 2020 20:06:25 -0400 Subject: [PATCH] Added a checkbox option to the gui config page to allow for the gui to use the native OS menu bar for mac os and certain linux distros. --- src/drivers/Qt/ConsoleWindow.cpp | 7 +++++-- src/drivers/Qt/GuiConf.cpp | 17 ++++++++++++++++- src/drivers/Qt/GuiConf.h | 2 ++ src/drivers/Qt/config.cpp | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index caf31262..d855d141 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -144,9 +144,12 @@ void consoleWin_t::createMainMenu(void) { QMenu *subMenu; QActionGroup *group; + int useNativeMenuBar; - // This is needed for menu bar to show up on MacOS - menuBar()->setNativeMenuBar(false); + // This is needed for menu bar to show up on MacOS + g_config->getOption( "SDL.UseNativeMenuBar", &useNativeMenuBar ); + + menuBar()->setNativeMenuBar( useNativeMenuBar ? true : false ); //----------------------------------------------------------------------- // File diff --git a/src/drivers/Qt/GuiConf.cpp b/src/drivers/Qt/GuiConf.cpp index 4ca60609..256aacb2 100644 --- a/src/drivers/Qt/GuiConf.cpp +++ b/src/drivers/Qt/GuiConf.cpp @@ -8,30 +8,37 @@ #include "Qt/config.h" #include "Qt/keyscan.h" #include "Qt/fceuWrapper.h" +#include "Qt/ConsoleWindow.h" //---------------------------------------------------- GuiConfDialog_t::GuiConfDialog_t(QWidget *parent) : QDialog( parent ) { int useNativeFileDialogVal; + int useNativeMenuBarVal; QVBoxLayout *mainLayout; //resize( 512, 600 ); // sync with config g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption ("SDL.UseNativeMenuBar", &useNativeMenuBarVal); setWindowTitle( tr("GUI Config") ); mainLayout = new QVBoxLayout(); useNativeFileDialog = new QCheckBox( tr("Use Native OS File Dialog") ); + useNativeMenuBar = new QCheckBox( tr("Use Native OS Menu Bar") ); useNativeFileDialog->setChecked( useNativeFileDialogVal ); + useNativeMenuBar->setChecked( useNativeMenuBarVal ); connect(useNativeFileDialog , SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)) ); + connect(useNativeMenuBar , SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)) ); mainLayout->addWidget( useNativeFileDialog ); + mainLayout->addWidget( useNativeMenuBar ); setLayout( mainLayout ); } @@ -53,6 +60,14 @@ void GuiConfDialog_t::useNativeFileDialogChanged(int state) int value = (state == Qt::Unchecked) ? 0 : 1; g_config->setOption ("SDL.UseNativeFileDialog", value); - +} +//---------------------------------------------------- +void GuiConfDialog_t::useNativeMenuBarChanged(int state) +{ + int value = (state == Qt::Unchecked) ? 0 : 1; + + g_config->setOption ("SDL.UseNativeMenuBar", value); + + consoleWindow->menuBar()->setNativeMenuBar( value ); } //---------------------------------------------------- diff --git a/src/drivers/Qt/GuiConf.h b/src/drivers/Qt/GuiConf.h index dcc3d313..032dd4db 100644 --- a/src/drivers/Qt/GuiConf.h +++ b/src/drivers/Qt/GuiConf.h @@ -27,11 +27,13 @@ class GuiConfDialog_t : public QDialog protected: QCheckBox *useNativeFileDialog; + QCheckBox *useNativeMenuBar; private: public slots: void closeWindow(void); private slots: void useNativeFileDialogChanged(int v); + void useNativeMenuBarChanged(int v); }; diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp index fc9a1bc2..cd927b8d 100644 --- a/src/drivers/Qt/config.cpp +++ b/src/drivers/Qt/config.cpp @@ -295,6 +295,7 @@ InitConfig() config->addOption("_lastloadlua", "SDL.LastLoadLua", ""); config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false); + config->addOption("_useNativeMenuBar" , "SDL.UseNativeMenuBar", false); // fcm -> fm2 conversion config->addOption("fcmconvert", "SDL.FCMConvert", "");