Added auto hide main menu on fullscreen functionality to Qt GUI. Issue #454.

This commit is contained in:
mjbudd77 2022-01-29 12:55:41 -05:00
parent e42a966afc
commit 95d2ca7982
3 changed files with 46 additions and 5 deletions

View File

@ -114,19 +114,23 @@ consoleWin_t::consoleWin_t(QWidget *parent)
initHotKeys(); initHotKeys();
createMainMenu();
firstResize = true; firstResize = true;
closeRequested = false; closeRequested = false;
errorMsgValid = false; errorMsgValid = false;
viewport_GL = NULL; viewport_GL = NULL;
viewport_SDL = NULL; viewport_SDL = NULL;
contextMenuEnable = false;
soundUseGlobalFocus = false;
mainMenuEmuPauseSet = false; mainMenuEmuPauseSet = false;
mainMenuEmuWasPaused = false; mainMenuEmuWasPaused = false;
mainMenuPauseWhenActv = false; mainMenuPauseWhenActv = false;
autoHideMenuFullscreen = false;
createMainMenu();
g_config->getOption( "SDL.PauseOnMainMenuAccess", &mainMenuPauseWhenActv ); g_config->getOption( "SDL.PauseOnMainMenuAccess", &mainMenuPauseWhenActv );
g_config->getOption( "SDL.AutoHideMenuFullsreen", &autoHideMenuFullscreen );
g_config->getOption( "SDL.ContextMenuEnable", &contextMenuEnable ); g_config->getOption( "SDL.ContextMenuEnable", &contextMenuEnable );
g_config->getOption( "SDL.Sound.UseGlobalFocus", &soundUseGlobalFocus ); g_config->getOption( "SDL.Sound.UseGlobalFocus", &soundUseGlobalFocus );
g_config->getOption ("SDL.VideoDriver", &use_SDL_video); g_config->getOption ("SDL.VideoDriver", &use_SDL_video);
@ -225,6 +229,10 @@ consoleWin_t::consoleWin_t(QWidget *parent)
if ( setFullScreen ) if ( setFullScreen )
{ {
if ( autoHideMenuFullscreen )
{
menubar->setVisible(false);
}
this->showFullScreen(); this->showFullScreen();
} }
@ -1221,6 +1229,19 @@ void consoleWin_t::createMainMenu(void)
Hotkeys[ HK_MAIN_MENU_HIDE ].setAction( act ); Hotkeys[ HK_MAIN_MENU_HIDE ].setAction( act );
connect( Hotkeys[ HK_MAIN_MENU_HIDE ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleMenuVis(void)) ); connect( Hotkeys[ HK_MAIN_MENU_HIDE ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleMenuVis(void)) );
// Options -> Auto Hide Menu on Fullscreen
g_config->getOption( "SDL.AutoHideMenuFullsreen", &autoHideMenuFullscreen );
act = new QAction(tr("&Auto Hide Menu on Fullscreen"), this);
//act->setShortcut( QKeySequence(tr("Alt+/")));
act->setCheckable(true);
act->setChecked( autoHideMenuFullscreen );
act->setStatusTip(tr("Auto Hide Menu on Fullscreen"));
//act->setIcon( style()->standardIcon( QStyle::SP_TitleBarMaxButton ) );
connect(act, SIGNAL(triggered(bool)), this, SLOT(toggleMenuAutoHide(bool)) );
optMenu->addAction(act);
// Options -> Video BG Color // Options -> Video BG Color
fceuLoadConfigColor( "SDL.VideoBgColor", &videoBgColor ); fceuLoadConfigColor( "SDL.VideoBgColor", &videoBgColor );
@ -2098,6 +2119,14 @@ void consoleWin_t::toggleMenuVis(void)
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void consoleWin_t::toggleMenuAutoHide(bool checked)
{
autoHideMenuFullscreen = checked;
g_config->setOption( "SDL.AutoHideMenuFullsreen", autoHideMenuFullscreen );
g_config->save();
}
//---------------------------------------------------------------------------
void consoleWin_t::closeApp(void) void consoleWin_t::closeApp(void)
{ {
nes_shm->runEmulator = 0; nes_shm->runEmulator = 0;
@ -3102,9 +3131,18 @@ void consoleWin_t::toggleFullscreen(void)
if ( isFullScreen() ) if ( isFullScreen() )
{ {
showNormal(); showNormal();
if ( autoHideMenuFullscreen )
{
menubar->setVisible(true);
}
} }
else else
{ {
if ( autoHideMenuFullscreen )
{
menubar->setVisible(false);
}
showFullScreen(); showFullScreen();
} }
} }

View File

@ -271,6 +271,7 @@ class consoleWin_t : public QMainWindow
bool scrHandlerConnected; bool scrHandlerConnected;
bool contextMenuEnable; bool contextMenuEnable;
bool soundUseGlobalFocus; bool soundUseGlobalFocus;
bool autoHideMenuFullscreen;
std::list <std::string*> romList; std::list <std::string*> romList;
std::vector <autoFireMenuAction*> afActList; std::vector <autoFireMenuAction*> afActList;
@ -449,6 +450,7 @@ class consoleWin_t : public QMainWindow
void winScreenChanged( QScreen *scr ); void winScreenChanged( QScreen *scr );
void winActiveChanged(void); void winActiveChanged(void);
void emuFrameFinish(void); void emuFrameFinish(void);
void toggleMenuAutoHide(bool);
void videoBgColorChanged( QColor &c ); void videoBgColorChanged( QColor &c );
void loadRomRequestCB( QString s ); void loadRomRequestCB( QString s );

View File

@ -817,6 +817,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.AutoHideMenuFullsreen", false);
config->addOption("SDL.ContextMenuEnable", true); config->addOption("SDL.ContextMenuEnable", true);
config->addOption("SDL.GuiStyle", ""); config->addOption("SDL.GuiStyle", "");
config->addOption("SDL.QtStyleSheet", ""); config->addOption("SDL.QtStyleSheet", "");