diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 5d60e2f30e..dd1e1941a8 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 fc72cb1e1e..763ffab651 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 bbc82f9e70..c598c444fa 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