Added logic to Qt GUI to allow for the main menu bar to be hidden. (#296)

This commit is contained in:
mjbudd77 2021-01-05 21:50:37 -05:00 committed by GitHub
parent 6d8cd5f64b
commit 427daa3543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 15 deletions

View File

@ -491,12 +491,20 @@ void consoleWin_t::createMainMenu(void)
fullscreen = new QAction(tr("Fullscreen"), this); fullscreen = new QAction(tr("Fullscreen"), this);
fullscreen->setShortcut( QKeySequence(tr("Alt+Return"))); fullscreen->setShortcut( QKeySequence(tr("Alt+Return")));
fullscreen->setStatusTip(tr("Fullscreen")); fullscreen->setStatusTip(tr("Fullscreen"));
//fullscreen->setIcon( style->standardIcon( QStyle::SP_TitleBarMaxButton ) );
fullscreen->setIcon( QIcon(":icons/view-fullscreen.png") ); fullscreen->setIcon( QIcon(":icons/view-fullscreen.png") );
connect(fullscreen, SIGNAL(triggered()), this, SLOT(toggleFullscreen(void)) ); connect(fullscreen, SIGNAL(triggered()), this, SLOT(toggleFullscreen(void)) );
optMenu->addAction(fullscreen); optMenu->addAction(fullscreen);
// Options -> Hide Menu Screen
act = new QAction(tr("Hide Menu"), this);
act->setShortcut( QKeySequence(tr("Alt+M")));
act->setStatusTip(tr("Hide Menu"));
act->setIcon( style->standardIcon( QStyle::SP_TitleBarMaxButton ) );
connect(act, SIGNAL(triggered()), this, SLOT(toggleMenuVis(void)) );
optMenu->addAction(act);
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Emulation // Emulation
emuMenu = menuBar()->addMenu(tr("Emulation")); emuMenu = menuBar()->addMenu(tr("Emulation"));
@ -841,6 +849,18 @@ void consoleWin_t::createMainMenu(void)
helpMenu->addAction(msgLogAct); helpMenu->addAction(msgLogAct);
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void consoleWin_t::toggleMenuVis(void)
{
if ( menuBar()->isVisible() )
{
menuBar()->setVisible( false );
}
else
{
menuBar()->setVisible( true );
}
}
//---------------------------------------------------------------------------
void consoleWin_t::closeApp(void) void consoleWin_t::closeApp(void)
{ {
nes_shm->runEmulator = 0; nes_shm->runEmulator = 0;

View File

@ -168,6 +168,8 @@ class consoleWin_t : public QMainWindow
void openDebugWindow(void); void openDebugWindow(void);
void openHexEditor(void); void openHexEditor(void);
void openGamePadConfWin(void); void openGamePadConfWin(void);
void toggleFullscreen(void);
void toggleMenuVis(void);
private slots: private slots:
void closeApp(void); void closeApp(void);
void openROMFile(void); void openROMFile(void);
@ -192,7 +194,6 @@ class consoleWin_t : public QMainWindow
void openCodeDataLogger(void); void openCodeDataLogger(void);
void openTraceLogger(void); void openTraceLogger(void);
void toggleAutoResume(void); void toggleAutoResume(void);
void toggleFullscreen(void);
void updatePeriodic(void); void updatePeriodic(void);
void changeState0(void); void changeState0(void);
void changeState1(void); void changeState1(void);

View File

@ -588,21 +588,33 @@ static void KeyboardCommands (void)
} }
// Alt-Enter to toggle full-screen // Alt-Enter to toggle full-screen
// This is already handled by GTK Accelerator // This is already handled by Qt Menu Actions
//if (keyonly (ENTER) && is_alt) // So only process if menu is hidden or disabled.
//{ if ( is_alt )
// ToggleFS (); {
//} if (keyonly (ENTER))
// {
if ( consoleWindow )
{
if ( !consoleWindow->menuBar()->isVisible() )
{
consoleWindow->toggleFullscreen();
}
}
}
}
// Alt-M to toggle Main Menu Visibility // Alt-M to toggle Main Menu Visibility
//if ( is_alt ) if ( is_alt )
//{ {
// if (keyonly (M)) if (keyonly (M))
// { {
// toggleMenuVis(); // TODO if ( consoleWindow )
// } {
//} consoleWindow->toggleMenuVis();
}
}
}
// Toggle Movie auto-backup // Toggle Movie auto-backup
if ( is_shift ) if ( is_shift )