From 8e4b806419007e5cc1b4ef8e171e8825fa03c7e7 Mon Sep 17 00:00:00 2001 From: Paulo Faustino Date: Fri, 2 Feb 2018 18:19:49 -0200 Subject: [PATCH] More accessible screen layout settings. (#3340) * Remove borders from status bar items On Ubuntu the status bar didn't look as good as on Windows due to some border being drawn around each status bar cell. * Revert "Remove borders from status bar items" This reverts commit 15fd32bf2b33d72f5c1b589b35c8dd6232ad263c. * Remove borders from status bar items On Ubuntu the status bar didn't look as good as on Windows due to some border being drawn around each status bar cell. * More accessible screen layout settings. Depending on the game I'm playing I find myself needing to switch screen layouts very often and it's currently a hassle to have to open the settings dialog in order to do that so I've added shortcuts for the screen layout options and swap screen option on the main menu plus I added a keyboard shortcut to quickly toggle between the available layouts during game play (F10). I've also updated the swap screen shortcut (F9 now, used to be Ctrl + Tab) so it's next to the layout toggle shortcut by default (F9 and F10). * Clean up. --- src/citra_qt/main.cpp | 93 +++++++++++++++++++++++++++++++++++++++---- src/citra_qt/main.h | 5 ++- src/citra_qt/main.ui | 54 +++++++++++++++++++++++++ 3 files changed, 143 insertions(+), 9 deletions(-) diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 5d60e2f30..dd1e1941a 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -192,7 +192,15 @@ void GMainWindow::InitializeWidgets() { statusBar()->addPermanentWidget(label, 0); } statusBar()->setVisible(true); + + // Removes an ugly inner border from the status bar widgets under Linux setStyleSheet("QStatusBar::item{border: none;}"); + + QActionGroup* actionGroup_ScreenLayouts = new QActionGroup(this); + actionGroup_ScreenLayouts->addAction(ui.action_Screen_Layout_Default); + actionGroup_ScreenLayouts->addAction(ui.action_Screen_Layout_Single_Screen); + actionGroup_ScreenLayouts->addAction(ui.action_Screen_Layout_Large_Screen); + actionGroup_ScreenLayouts->addAction(ui.action_Screen_Layout_Side_by_Side); } void GMainWindow::InitializeDebugWidgets() { @@ -269,8 +277,9 @@ void GMainWindow::InitializeRecentFileMenuActions() { void GMainWindow::InitializeHotkeys() { RegisterHotkey("Main Window", "Load File", QKeySequence::Open); - RegisterHotkey("Main Window", "Swap Screens", QKeySequence::NextChild); RegisterHotkey("Main Window", "Start Emulation"); + RegisterHotkey("Main Window", "Swap Screens", QKeySequence(tr("F9"))); + RegisterHotkey("Main Window", "Toggle Screen Layout", QKeySequence(tr("F10"))); RegisterHotkey("Main Window", "Fullscreen", QKeySequence::FullScreen); RegisterHotkey("Main Window", "Exit Fullscreen", QKeySequence(Qt::Key_Escape), Qt::ApplicationShortcut); @@ -284,8 +293,10 @@ void GMainWindow::InitializeHotkeys() { &GMainWindow::OnMenuLoadFile); connect(GetHotkey("Main Window", "Start Emulation", this), &QShortcut::activated, this, &GMainWindow::OnStartGame); - connect(GetHotkey("Main Window", "Swap Screens", render_window), &QShortcut::activated, this, - &GMainWindow::OnSwapScreens); + connect(GetHotkey("Main Window", "Swap Screens", render_window), &QShortcut::activated, + ui.action_Screen_Layout_Swap_Screens, &QAction::trigger); + connect(GetHotkey("Main Window", "Toggle Screen Layout", render_window), &QShortcut::activated, + this, &GMainWindow::ToggleScreenLayout); connect(GetHotkey("Main Window", "Fullscreen", render_window), &QShortcut::activated, ui.action_Fullscreen, &QAction::trigger); connect(GetHotkey("Main Window", "Fullscreen", render_window), &QShortcut::activatedAmbiguously, @@ -347,6 +358,7 @@ void GMainWindow::RestoreUIState() { ToggleWindowMode(); ui.action_Fullscreen->setChecked(UISettings::values.fullscreen); + SyncMenuUISettings(); ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar); OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); @@ -397,7 +409,20 @@ 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); ui.action_Fullscreen->setShortcut(GetHotkey("Main Window", "Fullscreen", this)->key()); + ui.action_Screen_Layout_Swap_Screens->setShortcut( + GetHotkey("Main Window", "Swap Screens", this)->key()); + ui.action_Screen_Layout_Swap_Screens->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); + connect(ui.action_Screen_Layout_Default, &QAction::triggered, this, + &GMainWindow::ChangeScreenLayout); + connect(ui.action_Screen_Layout_Single_Screen, &QAction::triggered, this, + &GMainWindow::ChangeScreenLayout); + connect(ui.action_Screen_Layout_Large_Screen, &QAction::triggered, this, + &GMainWindow::ChangeScreenLayout); + connect(ui.action_Screen_Layout_Side_by_Side, &QAction::triggered, this, + &GMainWindow::ChangeScreenLayout); + connect(ui.action_Screen_Layout_Swap_Screens, &QAction::triggered, this, + &GMainWindow::OnSwapScreens); // Help connect(ui.action_FAQ, &QAction::triggered, @@ -937,6 +962,50 @@ void GMainWindow::ToggleWindowMode() { } } +void GMainWindow::ChangeScreenLayout() { + Settings::LayoutOption new_layout = Settings::LayoutOption::Default; + + if (ui.action_Screen_Layout_Default->isChecked()) { + new_layout = Settings::LayoutOption::Default; + } else if (ui.action_Screen_Layout_Single_Screen->isChecked()) { + new_layout = Settings::LayoutOption::SingleScreen; + } else if (ui.action_Screen_Layout_Large_Screen->isChecked()) { + new_layout = Settings::LayoutOption::LargeScreen; + } else if (ui.action_Screen_Layout_Side_by_Side->isChecked()) { + new_layout = Settings::LayoutOption::SideScreen; + } + + Settings::values.layout_option = new_layout; + Settings::Apply(); +} + +void GMainWindow::ToggleScreenLayout() { + Settings::LayoutOption new_layout = Settings::LayoutOption::Default; + + switch (Settings::values.layout_option) { + case Settings::LayoutOption::Default: + new_layout = Settings::LayoutOption::SingleScreen; + break; + case Settings::LayoutOption::SingleScreen: + new_layout = Settings::LayoutOption::LargeScreen; + break; + case Settings::LayoutOption::LargeScreen: + new_layout = Settings::LayoutOption::SideScreen; + break; + case Settings::LayoutOption::SideScreen: + new_layout = Settings::LayoutOption::Default; + break; + } + + Settings::values.layout_option = new_layout; + Settings::Apply(); +} + +void GMainWindow::OnSwapScreens() { + Settings::values.swap_screen = ui.action_Screen_Layout_Swap_Screens->isChecked(); + Settings::Apply(); +} + void GMainWindow::OnConfigure() { ConfigureDialog configureDialog(this); connect(&configureDialog, &ConfigureDialog::languageChanged, this, @@ -945,6 +1014,7 @@ void GMainWindow::OnConfigure() { if (result == QDialog::Accepted) { configureDialog.applyConfiguration(); UpdateUITheme(); + SyncMenuUISettings(); config->Save(); } } @@ -958,11 +1028,6 @@ void GMainWindow::OnToggleFilterBar() { } } -void GMainWindow::OnSwapScreens() { - Settings::values.swap_screen = !Settings::values.swap_screen; - Settings::Apply(); -} - void GMainWindow::OnCreateGraphicsSurfaceViewer() { auto graphicsSurfaceViewerWidget = new GraphicsSurfaceWidget(Pica::g_debug_context, this); addDockWidget(Qt::RightDockWidgetArea, graphicsSurfaceViewerWidget); @@ -1201,6 +1266,18 @@ void GMainWindow::SetupUIStrings() { tr("Citra %1| %2-%3").arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); } +void GMainWindow::SyncMenuUISettings() { + ui.action_Screen_Layout_Default->setChecked(Settings::values.layout_option == + Settings::LayoutOption::Default); + ui.action_Screen_Layout_Single_Screen->setChecked(Settings::values.layout_option == + Settings::LayoutOption::SingleScreen); + ui.action_Screen_Layout_Large_Screen->setChecked(Settings::values.layout_option == + Settings::LayoutOption::LargeScreen); + ui.action_Screen_Layout_Side_by_Side->setChecked(Settings::values.layout_option == + Settings::LayoutOption::SideScreen); + ui.action_Screen_Layout_Swap_Screens->setChecked(Settings::values.swap_screen); +} + #ifdef main #undef main #endif diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index fc72cb1e1..763ffab65 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -79,6 +79,7 @@ private: void InitializeHotkeys(); void SetDefaultUIGeometry(); + void SyncMenuUISettings(); void RestoreUIState(); void ConnectWidgetEvents(); @@ -139,11 +140,13 @@ private slots: /// Called whenever a user selects the "File->Select Game List Root" menu item void OnMenuSelectGameListRoot(); void OnMenuRecentFile(); - void OnSwapScreens(); void OnConfigure(); void OnToggleFilterBar(); void OnDisplayTitleBars(bool); void ToggleFullscreen(); + void ChangeScreenLayout(); + void ToggleScreenLayout(); + void OnSwapScreens(); void ShowFullscreen(); void HideFullscreen(); void ToggleWindowMode(); diff --git a/src/citra_qt/main.ui b/src/citra_qt/main.ui index bbc82f9e7..c598c444f 100644 --- a/src/citra_qt/main.ui +++ b/src/citra_qt/main.ui @@ -86,11 +86,25 @@ + + + Screen Layout + + + + + + + + + + + @@ -230,6 +244,46 @@ Opens the maintenance tool to modify your Citra installation + + + true + + + Default + + + + + true + + + Single Screen + + + + + true + + + Large Screen + + + + + true + + + Side by Side + + + + + true + + + Swap Screens + + Check for Updates