From f473780c52d2ee896e7c6ede3ffe9e8fadd37891 Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 16 Jan 2018 15:50:33 +0100 Subject: [PATCH 1/2] Merge citra-emu PR#3001 by Styleoshin(citra-qt : Adding fullscreen mode) --- src/yuzu/configuration/config.cpp | 2 ++ src/yuzu/main.cpp | 43 +++++++++++++++++++++++++++++++ src/yuzu/main.h | 1 + src/yuzu/main.ui | 11 +++++++- src/yuzu/ui_settings.h | 1 + 5 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index ab6ba0ec9f..923a7c53ff 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -137,6 +137,7 @@ void Config::ReadValues() { qt_config->endGroup(); UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool(); + UISettings::values.fullscreen = qt_config->value("fullscreen", false).toBool(); UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool(); UISettings::values.show_filter_bar = qt_config->value("showFilterBar", true).toBool(); UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool(); @@ -216,6 +217,7 @@ void Config::SaveValues() { qt_config->endGroup(); qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode); + qt_config->setValue("fullscreen", UISettings::values.fullscreen); qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar); qt_config->setValue("showFilterBar", UISettings::values.show_filter_bar); qt_config->setValue("showStatusBar", UISettings::values.show_status_bar); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f64e682688..5e321095d5 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,7 @@ void GMainWindow::BootGame(const QString& filename) { render_window->setFocus(); emulation_running = true; + ToggleFullscreen(); OnStartGame(); } @@ -548,6 +567,29 @@ void GMainWindow::OnStopGame() { ShutdownGame(); } +void GMainWindow::ToggleFullscreen() { + if (!emulation_running) { + return; + } + if (ui.action_Fullscreen->isChecked()) { + if (ui.action_Single_Window_Mode->isChecked()) { + ui.menubar->hide(); + statusBar()->hide(); + showFullScreen(); + } else { + render_window->showFullScreen(); + } + } else { + if (ui.action_Single_Window_Mode->isChecked()) { + statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); + ui.menubar->show(); + showNormal(); + } else { + render_window->showNormal(); + } + } +} + void GMainWindow::ToggleWindowMode() { if (ui.action_Single_Window_Mode->isChecked()) { // Render in the main window... @@ -700,6 +742,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(); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 3add882dd2..04bb887aea 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -127,6 +127,7 @@ private slots: void OnAbout(); void OnToggleFilterBar(); void OnDisplayTitleBars(bool); + void ToggleFullscreen(); void ToggleWindowMode(); void OnCoreError(Core::System::ResultStatus, std::string); diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui index 721e769e8f..0fcd93cc25 100644 --- a/src/yuzu/main.ui +++ b/src/yuzu/main.ui @@ -83,6 +83,7 @@ Debugging + @@ -189,6 +190,14 @@ Selects a folder to display in the game list - + + + true + + + Fullscreen + + + diff --git a/src/yuzu/ui_settings.h b/src/yuzu/ui_settings.h index e965f0ba92..d093da6411 100644 --- a/src/yuzu/ui_settings.h +++ b/src/yuzu/ui_settings.h @@ -27,6 +27,7 @@ struct Values { bool microprofile_visible; bool single_window_mode; + bool fullscreen; bool display_titlebar; bool show_filter_bar; bool show_status_bar; From 8cdc1be0df83b6070aed28be15ed0000cc81c05b Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 16 Jan 2018 15:59:30 +0100 Subject: [PATCH 2/2] Merge citra-emu PR#3159 by FearlessTobi(citra-qt : Fix a bug in our fullscreen implementation) --- src/yuzu/main.cpp | 44 +++++++++++++++++++++++++++++--------------- src/yuzu/main.h | 2 ++ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 5e321095d5..51d7f94188 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -420,7 +420,9 @@ void GMainWindow::BootGame(const QString& filename) { render_window->setFocus(); emulation_running = true; - ToggleFullscreen(); + if (ui.action_Fullscreen->isChecked()) { + ShowFullscreen(); + } OnStartGame(); } @@ -572,21 +574,33 @@ void GMainWindow::ToggleFullscreen() { return; } if (ui.action_Fullscreen->isChecked()) { - if (ui.action_Single_Window_Mode->isChecked()) { - ui.menubar->hide(); - statusBar()->hide(); - showFullScreen(); - } else { - render_window->showFullScreen(); - } + ShowFullscreen(); } else { - if (ui.action_Single_Window_Mode->isChecked()) { - statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); - ui.menubar->show(); - showNormal(); - } else { - render_window->showNormal(); - } + 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); } } diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 04bb887aea..4a0d912bbd 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -128,6 +128,8 @@ private slots: void OnToggleFilterBar(); void OnDisplayTitleBars(bool); void ToggleFullscreen(); + void ShowFullscreen(); + void HideFullscreen(); void ToggleWindowMode(); void OnCoreError(Core::System::ResultStatus, std::string);