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;
QActionGroup *group;
int useNativeMenuBar;
// 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

View File

@ -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 );
}
//----------------------------------------------------

View File

@ -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);
};

View File

@ -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", "");