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.

This commit is contained in:
Matthew Budd 2020-07-21 20:06:25 -04:00
parent 3fc99f7d30
commit 02c3012215
4 changed files with 24 additions and 3 deletions

View File

@ -144,9 +144,12 @@ void consoleWin_t::createMainMenu(void)
{ {
QMenu *subMenu; QMenu *subMenu;
QActionGroup *group; QActionGroup *group;
int useNativeMenuBar;
// This is needed for menu bar to show up on MacOS // This is needed for menu bar to show up on MacOS
menuBar()->setNativeMenuBar(false); g_config->getOption( "SDL.UseNativeMenuBar", &useNativeMenuBar );
menuBar()->setNativeMenuBar( useNativeMenuBar ? true : false );
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// File // File

View File

@ -8,30 +8,37 @@
#include "Qt/config.h" #include "Qt/config.h"
#include "Qt/keyscan.h" #include "Qt/keyscan.h"
#include "Qt/fceuWrapper.h" #include "Qt/fceuWrapper.h"
#include "Qt/ConsoleWindow.h"
//---------------------------------------------------- //----------------------------------------------------
GuiConfDialog_t::GuiConfDialog_t(QWidget *parent) GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
: QDialog( parent ) : QDialog( parent )
{ {
int useNativeFileDialogVal; int useNativeFileDialogVal;
int useNativeMenuBarVal;
QVBoxLayout *mainLayout; QVBoxLayout *mainLayout;
//resize( 512, 600 ); //resize( 512, 600 );
// sync with config // sync with config
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
g_config->getOption ("SDL.UseNativeMenuBar", &useNativeMenuBarVal);
setWindowTitle( tr("GUI Config") ); setWindowTitle( tr("GUI Config") );
mainLayout = new QVBoxLayout(); mainLayout = new QVBoxLayout();
useNativeFileDialog = new QCheckBox( tr("Use Native OS File Dialog") ); useNativeFileDialog = new QCheckBox( tr("Use Native OS File Dialog") );
useNativeMenuBar = new QCheckBox( tr("Use Native OS Menu Bar") );
useNativeFileDialog->setChecked( useNativeFileDialogVal ); useNativeFileDialog->setChecked( useNativeFileDialogVal );
useNativeMenuBar->setChecked( useNativeMenuBarVal );
connect(useNativeFileDialog , SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)) ); connect(useNativeFileDialog , SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)) );
connect(useNativeMenuBar , SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)) );
mainLayout->addWidget( useNativeFileDialog ); mainLayout->addWidget( useNativeFileDialog );
mainLayout->addWidget( useNativeMenuBar );
setLayout( mainLayout ); setLayout( mainLayout );
} }
@ -53,6 +60,14 @@ void GuiConfDialog_t::useNativeFileDialogChanged(int state)
int value = (state == Qt::Unchecked) ? 0 : 1; int value = (state == Qt::Unchecked) ? 0 : 1;
g_config->setOption ("SDL.UseNativeFileDialog", value); 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 );
} }
//---------------------------------------------------- //----------------------------------------------------

View File

@ -27,11 +27,13 @@ class GuiConfDialog_t : public QDialog
protected: protected:
QCheckBox *useNativeFileDialog; QCheckBox *useNativeFileDialog;
QCheckBox *useNativeMenuBar;
private: private:
public slots: public slots:
void closeWindow(void); void closeWindow(void);
private slots: private slots:
void useNativeFileDialogChanged(int v); void useNativeFileDialogChanged(int v);
void useNativeMenuBarChanged(int v);
}; };

View File

@ -295,6 +295,7 @@ InitConfig()
config->addOption("_lastloadlua", "SDL.LastLoadLua", ""); config->addOption("_lastloadlua", "SDL.LastLoadLua", "");
config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false); config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false);
config->addOption("_useNativeMenuBar" , "SDL.UseNativeMenuBar", false);
// fcm -> fm2 conversion // fcm -> fm2 conversion
config->addOption("fcmconvert", "SDL.FCMConvert", ""); config->addOption("fcmconvert", "SDL.FCMConvert", "");