diff options
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f64e68268..7c711158a 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -185,12 +185,24 @@ void GMainWindow::InitializeRecentFileMenuActions() { void GMainWindow::InitializeHotkeys() { RegisterHotkey("Main Window", "Load File", QKeySequence::Open); RegisterHotkey("Main Window", "Start Emulation"); + RegisterHotkey( "Main Window", "Fullscreen", QKeySequence::FullScreen ); + RegisterHotkey( "Main Window", "Exit Fullscreen", QKeySequence::Cancel, Qt::ApplicationShortcut ); LoadHotkeys(); connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, SLOT(OnMenuLoadFile())); connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, SLOT(OnStartGame())); + connect(GetHotkey("Main Window", "Fullscreen", render_window), &QShortcut::activated, + ui.action_Fullscreen, &QAction::trigger); + connect(GetHotkey("Main Window", "Fullscreen", render_window), &QShortcut::activatedAmbiguously, + ui.action_Fullscreen, &QAction::trigger); + connect(GetHotkey("Main Window", "Exit Fullscreen", this), &QShortcut::activated, this, [&] { + if (emulation_running) { + ui.action_Fullscreen->setChecked(false); + ToggleFullscreen(); + } + }); } void GMainWindow::SetDefaultUIGeometry() { @@ -219,6 +231,8 @@ void GMainWindow::RestoreUIState() { ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode); ToggleWindowMode(); + ui.action_Fullscreen->setChecked(UISettings::values.fullscreen); + ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar); OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); @@ -263,6 +277,10 @@ void GMainWindow::ConnectMenuEvents() { connect(ui.action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar); connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); + // Fullscreen + ui.action_Fullscreen->setShortcut(GetHotkey("Main Window", "Fullscreen", this)->key()); + connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); + // Help connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnAbout); } @@ -402,6 +420,9 @@ void GMainWindow::BootGame(const QString& filename) { render_window->setFocus(); emulation_running = true; + if (ui.action_Fullscreen->isChecked()) { + ShowFullscreen(); + } OnStartGame(); } @@ -548,6 +569,41 @@ void GMainWindow::OnStopGame() { ShutdownGame(); } +void GMainWindow::ToggleFullscreen() { + if (!emulation_running) { + return; + } + if (ui.action_Fullscreen->isChecked()) { + ShowFullscreen(); + } else { + HideFullscreen(); + } +} + +void GMainWindow::ShowFullscreen() { + if (ui.action_Single_Window_Mode->isChecked()) { + UISettings::values.geometry = saveGeometry(); + ui.menubar->hide(); + statusBar()->hide(); + showFullScreen(); + } else { + UISettings::values.renderwindow_geometry = render_window->saveGeometry(); + render_window->showFullScreen(); + } +} + +void GMainWindow::HideFullscreen() { + if (ui.action_Single_Window_Mode->isChecked()) { + statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); + ui.menubar->show(); + showNormal(); + restoreGeometry(UISettings::values.geometry); + } else { + render_window->showNormal(); + render_window->restoreGeometry(UISettings::values.renderwindow_geometry); + } +} + void GMainWindow::ToggleWindowMode() { if (ui.action_Single_Window_Mode->isChecked()) { // Render in the main window... @@ -670,6 +726,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det } else { // Only show the message if the game is still running. if (emu_thread) { + emu_thread->SetRunning(true); message_label->setText(status_message); message_label->setVisible(true); } @@ -700,6 +757,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) { UISettings::values.microprofile_visible = microProfileDialog->isVisible(); #endif UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked(); + UISettings::values.fullscreen = ui.action_Fullscreen->isChecked(); UISettings::values.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked(); UISettings::values.show_filter_bar = ui.action_Show_Filter_Bar->isChecked(); UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked(); |