diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 9afd88da6..e47822e79 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -178,6 +178,7 @@ GMainWindow::GMainWindow() InitializeDebugWidgets(); InitializeRecentFileMenuActions(); InitializeSaveStateMenuActions(); + InitializeScreenResizeMenuActions(); InitializeHotkeys(); ShowUpdaterWidgets(); @@ -315,12 +316,6 @@ void GMainWindow::InitializeWidgets() { 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); - - QActionGroup* actionGroup_ScreenSizes = new QActionGroup(this); - actionGroup_ScreenSizes->addAction(ui->action_Screen_Size_1x); - actionGroup_ScreenSizes->addAction(ui->action_Screen_Size_2x); - actionGroup_ScreenSizes->addAction(ui->action_Screen_Size_3x); - actionGroup_ScreenSizes->addAction(ui->action_Screen_Size_4x); } void GMainWindow::InitializeDebugWidgets() { @@ -759,11 +754,6 @@ void GMainWindow::ConnectMenuEvents() { connect(ui->action_Screen_Layout_Upright_Screens, &QAction::triggered, this, &GMainWindow::OnRotateScreens); - connect(ui->action_Screen_Size_1x, &QAction::triggered, this, &GMainWindow::ChangeScreenSize); - connect(ui->action_Screen_Size_2x, &QAction::triggered, this, &GMainWindow::ChangeScreenSize); - connect(ui->action_Screen_Size_3x, &QAction::triggered, this, &GMainWindow::ChangeScreenSize); - connect(ui->action_Screen_Size_4x, &QAction::triggered, this, &GMainWindow::ChangeScreenSize); - // Movie connect(ui->action_Record_Movie, &QAction::triggered, this, &GMainWindow::OnRecordMovie); connect(ui->action_Play_Movie, &QAction::triggered, this, &GMainWindow::OnPlayMovie); @@ -1677,6 +1667,19 @@ void GMainWindow::ToggleWindowMode() { } } +void GMainWindow::InitializeScreenResizeMenuActions() { + actionGroup_ScreenSizes = new QActionGroup(this); + for (int i = 0; i < 10; i++) { + actions_screen_size[i] = new QAction(this); + actions_screen_size[i]->setData(i + 1); + actions_screen_size[i]->setText(QLatin1String(fmt::format("{}x", i + 1).c_str())); + actions_screen_size[i]->setCheckable(true); + connect(actions_screen_size[i], &QAction::triggered, this, &GMainWindow::ChangeScreenSize); + ui->menu_Screen_Size->addAction(actions_screen_size[i]); + actionGroup_ScreenSizes->addAction(actions_screen_size[i]); + } +} + void GMainWindow::ResizeScreen() { const int scale = UISettings::values.fixed_screen_size; if (!scale || !emulation_running) { @@ -1705,14 +1708,9 @@ void GMainWindow::ResizeScreen() { void GMainWindow::ChangeScreenSize() { int new_scale = 0; - if (ui->action_Screen_Size_1x->isChecked()) { - new_scale = 1; - } else if (ui->action_Screen_Size_2x->isChecked()) { - new_scale = 2; - } else if (ui->action_Screen_Size_3x->isChecked()) { - new_scale = 3; - } else if (ui->action_Screen_Size_4x->isChecked()) { - new_scale = 4; + QAction* checked = actionGroup_ScreenSizes->checkedAction(); + if (checked) { + new_scale = checked->data().toInt(); } const bool needs_workaround = UISettings::values.fixed_screen_size == 1 && new_scale == 1; @@ -2451,10 +2449,10 @@ void GMainWindow::UpdateWindowTitle() { } void GMainWindow::UncheckWindowSize() { - ui->action_Screen_Size_1x->setChecked(false); - ui->action_Screen_Size_2x->setChecked(false); - ui->action_Screen_Size_3x->setChecked(false); - ui->action_Screen_Size_4x->setChecked(false); + QAction* checked = actionGroup_ScreenSizes->checkedAction(); + if (checked) { + checked->setChecked(false); + } UISettings::values.fixed_screen_size = 0; } @@ -2489,10 +2487,9 @@ void GMainWindow::SyncMenuUISettings() { ui->action_Screen_Layout_Swap_Screens->setChecked(Settings::values.swap_screen); ui->action_Screen_Layout_Upright_Screens->setChecked(Settings::values.upright_screen); - ui->action_Screen_Size_1x->setChecked(UISettings::values.fixed_screen_size == 1); - ui->action_Screen_Size_2x->setChecked(UISettings::values.fixed_screen_size == 2); - ui->action_Screen_Size_3x->setChecked(UISettings::values.fixed_screen_size == 3); - ui->action_Screen_Size_4x->setChecked(UISettings::values.fixed_screen_size == 4); + if (UISettings::values.fixed_screen_size) { + actions_screen_size[UISettings::values.fixed_screen_size - 1]->setChecked(true); + } } void GMainWindow::RetranslateStatusBar() { diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 399a91ea1..5ecd16118 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -38,6 +38,7 @@ class MultiplayerState; class ProfilerWidget; template class QFutureWatcher; +class QActionGroup; class QLabel; class QProgressBar; class RegistersWidget; @@ -112,6 +113,7 @@ private: void InitializeDebugWidgets(); void InitializeRecentFileMenuActions(); void InitializeSaveStateMenuActions(); + void InitializeScreenResizeMenuActions(); void SetDefaultUIGeometry(); void SyncMenuUISettings(); @@ -308,6 +310,9 @@ private: u32 newest_slot; u64 newest_slot_time; + QActionGroup* actionGroup_ScreenSizes; + std::array actions_screen_size; + QTranslator translator; // stores default icon theme search paths for the platform diff --git a/src/citra_qt/main.ui b/src/citra_qt/main.ui index 65543ffe5..b5e1aef3f 100644 --- a/src/citra_qt/main.ui +++ b/src/citra_qt/main.ui @@ -133,10 +133,6 @@ Screen Size - - - - @@ -487,38 +483,6 @@ Rotate Upright - - - true - - - 1x - - - - - true - - - 2x - - - - - true - - - 3x - - - - - true - - - 4x - - Check for Updates