Added main window context menu for Qt GUI.
This commit is contained in:
parent
fcaadd7e84
commit
6aa0c9fec1
|
@ -122,6 +122,7 @@ consoleWin_t::consoleWin_t(QWidget *parent)
|
||||||
mainMenuPauseWhenActv = false;
|
mainMenuPauseWhenActv = false;
|
||||||
|
|
||||||
g_config->getOption( "SDL.PauseOnMainMenuAccess", &mainMenuPauseWhenActv );
|
g_config->getOption( "SDL.PauseOnMainMenuAccess", &mainMenuPauseWhenActv );
|
||||||
|
g_config->getOption( "SDL.ContextMenuEnable", &contextMenuEnable );
|
||||||
g_config->getOption ("SDL.VideoDriver", &use_SDL_video);
|
g_config->getOption ("SDL.VideoDriver", &use_SDL_video);
|
||||||
|
|
||||||
if ( use_SDL_video )
|
if ( use_SDL_video )
|
||||||
|
@ -498,6 +499,11 @@ void consoleWin_t::setMenuAccessPauseEnable( bool enable )
|
||||||
mainMenuPauseWhenActv = enable;
|
mainMenuPauseWhenActv = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void consoleWin_t::setContextMenuEnable( bool enable )
|
||||||
|
{
|
||||||
|
contextMenuEnable = enable;
|
||||||
|
}
|
||||||
|
|
||||||
void consoleWin_t::loadCursor(void)
|
void consoleWin_t::loadCursor(void)
|
||||||
{
|
{
|
||||||
int cursorVis;
|
int cursorVis;
|
||||||
|
@ -691,6 +697,47 @@ void consoleWin_t::showEvent(QShowEvent *event)
|
||||||
initScreenHandler();
|
initScreenHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void consoleWin_t::contextMenuEvent(QContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
QAction *act;
|
||||||
|
QMenu menu(this);
|
||||||
|
|
||||||
|
if ( !contextMenuEnable )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
act = new QAction(tr("Open ROM"), &menu);
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(openROMFile(void)) );
|
||||||
|
|
||||||
|
menu.addAction( act );
|
||||||
|
|
||||||
|
act = new QAction(tr("Last ROM Used"), &menu);
|
||||||
|
act->setEnabled( romList.size() > 0 );
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(loadMostRecentROM(void)) );
|
||||||
|
|
||||||
|
menu.addAction( act );
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
|
act = new QAction(tr("Online Help"), &menu);
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(openOnlineDocs(void)) );
|
||||||
|
|
||||||
|
menu.addAction( act );
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
|
act = new QAction(tr("Disable Context Menu via Options -> GUI Config"), &menu);
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(openGuiConfWin(void)) );
|
||||||
|
|
||||||
|
menu.addAction( act );
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
|
menu.exec(event->globalPos());
|
||||||
|
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void consoleWin_t::initHotKeys(void)
|
void consoleWin_t::initHotKeys(void)
|
||||||
{
|
{
|
||||||
|
@ -3915,6 +3962,18 @@ void consoleWin_t::syncActionConfig( QAction *act, const char *property )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void consoleWin_t::loadMostRecentROM(void)
|
||||||
|
{
|
||||||
|
if ( romList.size() <= 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fceuWrapperLock();
|
||||||
|
CloseGame ();
|
||||||
|
LoadGame ( (romList.back())->c_str() );
|
||||||
|
fceuWrapperUnLock();
|
||||||
|
}
|
||||||
|
|
||||||
void consoleWin_t::updatePeriodic(void)
|
void consoleWin_t::updatePeriodic(void)
|
||||||
{
|
{
|
||||||
// Process all events before attempting to render viewport
|
// Process all events before attempting to render viewport
|
||||||
|
|
|
@ -165,6 +165,7 @@ class consoleWin_t : public QMainWindow
|
||||||
Qt::CursorShape getViewerCursor(void);
|
Qt::CursorShape getViewerCursor(void);
|
||||||
|
|
||||||
void setMenuAccessPauseEnable(bool enable);
|
void setMenuAccessPauseEnable(bool enable);
|
||||||
|
void setContextMenuEnable(bool enable);
|
||||||
protected:
|
protected:
|
||||||
consoleMenuBar *menubar;
|
consoleMenuBar *menubar;
|
||||||
|
|
||||||
|
@ -249,6 +250,7 @@ class consoleWin_t : public QMainWindow
|
||||||
bool mainMenuEmuWasPaused;
|
bool mainMenuEmuWasPaused;
|
||||||
bool mainMenuPauseWhenActv;
|
bool mainMenuPauseWhenActv;
|
||||||
bool scrHandlerConnected;
|
bool scrHandlerConnected;
|
||||||
|
bool contextMenuEnable;
|
||||||
|
|
||||||
std::list <std::string*> romList;
|
std::list <std::string*> romList;
|
||||||
std::vector <autoFireMenuAction*> afActList;
|
std::vector <autoFireMenuAction*> afActList;
|
||||||
|
@ -256,13 +258,14 @@ class consoleWin_t : public QMainWindow
|
||||||
|
|
||||||
unsigned int updateCounter;
|
unsigned int updateCounter;
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event) override;
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
void keyReleaseEvent(QKeyEvent *event);
|
void keyReleaseEvent(QKeyEvent *event) override;
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
void dropEvent(QDropEvent *event);
|
void dropEvent(QDropEvent *event) override;
|
||||||
void showEvent(QShowEvent *event);
|
void showEvent(QShowEvent *event) override;
|
||||||
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
void syncActionConfig( QAction *act, const char *property );
|
void syncActionConfig( QAction *act, const char *property );
|
||||||
void showErrorMsgWindow(void);
|
void showErrorMsgWindow(void);
|
||||||
|
|
||||||
|
@ -333,6 +336,7 @@ class consoleWin_t : public QMainWindow
|
||||||
void consolePause(void);
|
void consolePause(void);
|
||||||
void toggleGameGenie(bool checked);
|
void toggleGameGenie(bool checked);
|
||||||
void loadGameGenieROM(void);
|
void loadGameGenieROM(void);
|
||||||
|
void loadMostRecentROM(void);
|
||||||
void setRegionNTSC(void);
|
void setRegionNTSC(void);
|
||||||
void setRegionPAL(void);
|
void setRegionPAL(void);
|
||||||
void setRegionDendy(void);
|
void setRegionDendy(void);
|
||||||
|
|
|
@ -50,7 +50,7 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
{
|
{
|
||||||
int useNativeFileDialogVal;
|
int useNativeFileDialogVal;
|
||||||
int useNativeMenuBarVal, pauseOnMenuAccessVal;
|
int useNativeMenuBarVal, pauseOnMenuAccessVal;
|
||||||
int useCustomQssVal, useCustomQPalVal;
|
int useCustomQssVal, useCustomQPalVal, contextMenuEnable;
|
||||||
QVBoxLayout *mainLayout, *vbox1, *vbox2;
|
QVBoxLayout *mainLayout, *vbox1, *vbox2;
|
||||||
QHBoxLayout *hbox, *hbox1;
|
QHBoxLayout *hbox, *hbox1;
|
||||||
QPushButton *closeButton, *button;
|
QPushButton *closeButton, *button;
|
||||||
|
@ -75,6 +75,7 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
g_config->getOption("SDL.UseCustomQss", &useCustomQssVal);
|
g_config->getOption("SDL.UseCustomQss", &useCustomQssVal);
|
||||||
g_config->getOption("SDL.UseCustomQPal", &useCustomQPalVal);
|
g_config->getOption("SDL.UseCustomQPal", &useCustomQPalVal);
|
||||||
g_config->getOption("SDL.PauseOnMainMenuAccess", &pauseOnMenuAccessVal);
|
g_config->getOption("SDL.PauseOnMainMenuAccess", &pauseOnMenuAccessVal);
|
||||||
|
g_config->getOption("SDL.ContextMenuEnable", &contextMenuEnable);
|
||||||
|
|
||||||
setWindowTitle(tr("GUI Config"));
|
setWindowTitle(tr("GUI Config"));
|
||||||
|
|
||||||
|
@ -124,16 +125,19 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
mainLayout->setMenuBar( menuBar );
|
mainLayout->setMenuBar( menuBar );
|
||||||
|
|
||||||
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"));
|
useNativeMenuBar = new QCheckBox(tr("Use Native OS Menu Bar"));
|
||||||
pauseOnMenuAccess = new QCheckBox(tr("Pause On Main Menu Access"));
|
pauseOnMenuAccess = new QCheckBox(tr("Pause On Main Menu Access"));
|
||||||
|
ctxMenuEnable = new QCheckBox(tr("Context Menu Enable"));
|
||||||
|
|
||||||
useNativeFileDialog->setChecked(useNativeFileDialogVal);
|
useNativeFileDialog->setChecked(useNativeFileDialogVal);
|
||||||
useNativeMenuBar->setChecked(useNativeMenuBarVal);
|
useNativeMenuBar->setChecked(useNativeMenuBarVal);
|
||||||
pauseOnMenuAccess->setChecked(pauseOnMenuAccessVal);
|
pauseOnMenuAccess->setChecked(pauseOnMenuAccessVal);
|
||||||
|
ctxMenuEnable->setChecked(contextMenuEnable);
|
||||||
|
|
||||||
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)));
|
connect(useNativeMenuBar , SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)));
|
||||||
connect(pauseOnMenuAccess, SIGNAL(stateChanged(int)), this, SLOT(pauseOnMenuAccessChanged(int)));
|
connect(pauseOnMenuAccess , SIGNAL(stateChanged(int)), this, SLOT(pauseOnMenuAccessChanged(int)));
|
||||||
|
connect(ctxMenuEnable , SIGNAL(stateChanged(int)), this, SLOT(contextMenuEnableChanged(int)));
|
||||||
|
|
||||||
styleComboBox = new QComboBox();
|
styleComboBox = new QComboBox();
|
||||||
|
|
||||||
|
@ -234,6 +238,7 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
vbox1->addWidget(useNativeFileDialog, 1);
|
vbox1->addWidget(useNativeFileDialog, 1);
|
||||||
vbox1->addWidget(useNativeMenuBar, 1);
|
vbox1->addWidget(useNativeMenuBar, 1);
|
||||||
vbox1->addWidget(pauseOnMenuAccess, 1);
|
vbox1->addWidget(pauseOnMenuAccess, 1);
|
||||||
|
vbox1->addWidget(ctxMenuEnable, 1);
|
||||||
vbox1->addStretch(10);
|
vbox1->addStretch(10);
|
||||||
|
|
||||||
closeButton = new QPushButton( tr("Close") );
|
closeButton = new QPushButton( tr("Close") );
|
||||||
|
@ -296,6 +301,15 @@ void GuiConfDialog_t::pauseOnMenuAccessChanged(int state)
|
||||||
consoleWindow->setMenuAccessPauseEnable( value );
|
consoleWindow->setMenuAccessPauseEnable( value );
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void GuiConfDialog_t::contextMenuEnableChanged(int state)
|
||||||
|
{
|
||||||
|
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||||
|
|
||||||
|
g_config->setOption("SDL.ContextMenuEnable", value);
|
||||||
|
|
||||||
|
consoleWindow->setContextMenuEnable( value );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void GuiConfDialog_t::useCustomStyleChanged(int state)
|
void GuiConfDialog_t::useCustomStyleChanged(int state)
|
||||||
{
|
{
|
||||||
int value = (state == Qt::Unchecked) ? 0 : 1;
|
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||||
|
|
|
@ -143,6 +143,7 @@ protected:
|
||||||
QCheckBox *useNativeFileDialog;
|
QCheckBox *useNativeFileDialog;
|
||||||
QCheckBox *useNativeMenuBar;
|
QCheckBox *useNativeMenuBar;
|
||||||
QCheckBox *pauseOnMenuAccess;
|
QCheckBox *pauseOnMenuAccess;
|
||||||
|
QCheckBox *ctxMenuEnable;
|
||||||
QCheckBox *useCustomStyle;
|
QCheckBox *useCustomStyle;
|
||||||
QCheckBox *useCustomPalette;
|
QCheckBox *useCustomPalette;
|
||||||
QComboBox *styleComboBox;
|
QComboBox *styleComboBox;
|
||||||
|
@ -156,6 +157,7 @@ private slots:
|
||||||
void useNativeFileDialogChanged(int v);
|
void useNativeFileDialogChanged(int v);
|
||||||
void useNativeMenuBarChanged(int v);
|
void useNativeMenuBarChanged(int v);
|
||||||
void pauseOnMenuAccessChanged(int v);
|
void pauseOnMenuAccessChanged(int v);
|
||||||
|
void contextMenuEnableChanged(int v);
|
||||||
void useCustomQPaletteChanged(int v);
|
void useCustomQPaletteChanged(int v);
|
||||||
void useCustomStyleChanged(int v);
|
void useCustomStyleChanged(int v);
|
||||||
void styleChanged(int index);
|
void styleChanged(int index);
|
||||||
|
|
|
@ -657,6 +657,7 @@ InitConfig()
|
||||||
config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false);
|
config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false);
|
||||||
config->addOption("_useNativeMenuBar" , "SDL.UseNativeMenuBar", false);
|
config->addOption("_useNativeMenuBar" , "SDL.UseNativeMenuBar", false);
|
||||||
config->addOption("SDL.PauseOnMainMenuAccess", false);
|
config->addOption("SDL.PauseOnMainMenuAccess", false);
|
||||||
|
config->addOption("SDL.ContextMenuEnable", true);
|
||||||
config->addOption("SDL.GuiStyle", "");
|
config->addOption("SDL.GuiStyle", "");
|
||||||
config->addOption("SDL.QtStyleSheet", "");
|
config->addOption("SDL.QtStyleSheet", "");
|
||||||
config->addOption("SDL.QPaletteFile", "");
|
config->addOption("SDL.QPaletteFile", "");
|
||||||
|
|
Loading…
Reference in New Issue