diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 28612bbd0..6337d921d 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -606,6 +606,8 @@ void Config::ReadUIValues() { ReadShortcutValues(); ReadMultiplayerValues(); + UISettings::values.fixed_screen_size = + ReadSetting(QStringLiteral("FixedScreenSize"), 0).toInt(); UISettings::values.single_window_mode = ReadSetting(QStringLiteral("singleWindowMode"), true).toBool(); UISettings::values.fullscreen = ReadSetting(QStringLiteral("fullscreen"), false).toBool(); @@ -1096,6 +1098,7 @@ void Config::SaveUIValues() { SaveShortcutValues(); SaveMultiplayerValues(); + WriteSetting(QStringLiteral("FixedScreenSize"), UISettings::values.fixed_screen_size, 0); WriteSetting(QStringLiteral("singleWindowMode"), UISettings::values.single_window_mode, true); WriteSetting(QStringLiteral("fullscreen"), UISettings::values.fullscreen, false); WriteSetting(QStringLiteral("displayTitleBars"), UISettings::values.display_titlebar, true); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index f4ae1cb98..5a26d6c53 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -314,6 +314,12 @@ 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() { @@ -752,6 +758,11 @@ 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); @@ -1665,6 +1676,37 @@ void GMainWindow::ToggleWindowMode() { } } +void GMainWindow::ResizeScreen(const int scale) { + const auto size = Layout::GetMinimumSizeFromLayout(Settings::values.layout_option, + Settings::values.upright_screen); + + auto_resized = true; + + render_window->setMinimumSize(scale * size.first, scale * size.second); + render_window->UpdateCurrentFramebufferLayout(scale * size.first, scale * size.second); + ui->centralwidget->resize(scale * size.first, scale * size.second); + resize(sizeHint()); + render_window->setMinimumSize(size.first, size.second); +} + +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; + } + + UISettings::values.fixed_screen_size = new_scale; + + ResizeScreen(new_scale); +} + void GMainWindow::ChangeScreenLayout() { Settings::LayoutOption new_layout = Settings::LayoutOption::Default; @@ -2126,6 +2168,15 @@ void GMainWindow::mouseReleaseEvent([[maybe_unused]] QMouseEvent* event) { OnMouseActivity(); } +void GMainWindow::resizeEvent(QResizeEvent* event) { + // This resize event was not triggered by the user + if (auto_resized) { + auto_resized = false; + } else { + UncheckWindowSize(); + } +} + void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { QString status_message; @@ -2372,6 +2423,13 @@ 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); +} + void GMainWindow::UpdateUISettings() { if (!ui->action_Fullscreen->isChecked()) { UISettings::values.geometry = saveGeometry(); @@ -2401,6 +2459,11 @@ void GMainWindow::SyncMenuUISettings() { Settings::LayoutOption::SideScreen); 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); } void GMainWindow::RetranslateStatusBar() { diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 241365a38..9e6f9f648 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -120,6 +120,9 @@ private: void ConnectWidgetEvents(); void ConnectMenuEvents(); + void ResizeScreen(int scale); + void UncheckWindowSize(); + void PreventOSSleep(); void AllowOSSleep(); @@ -197,6 +200,7 @@ private slots: void OnDisplayTitleBars(bool); void InitializeHotkeys(); void ToggleFullscreen(); + void ChangeScreenSize(); void ChangeScreenLayout(); void ToggleScreenLayout(); void OnSwapScreens(); @@ -261,8 +265,10 @@ private: // The path to the game currently running QString game_path; + // Internal states of misc features bool auto_paused = false; QTimer mouse_hide_timer; + bool auto_resized = false; // Movie bool movie_record_on_start = false; @@ -316,6 +322,7 @@ protected: void mouseMoveEvent(QMouseEvent* event) override; void mousePressEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; + void resizeEvent(QResizeEvent* event) override; }; Q_DECLARE_METATYPE(std::size_t); diff --git a/src/citra_qt/main.ui b/src/citra_qt/main.ui index 2eff98083..65543ffe5 100644 --- a/src/citra_qt/main.ui +++ b/src/citra_qt/main.ui @@ -129,9 +129,19 @@ + + + Screen Size + + + + + + + @@ -477,6 +487,38 @@ Rotate Upright + + + true + + + 1x + + + + + true + + + 2x + + + + + true + + + 3x + + + + + true + + + 4x + + Check for Updates diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h index 2031eb384..07d162207 100644 --- a/src/citra_qt/uisettings.h +++ b/src/citra_qt/uisettings.h @@ -72,6 +72,7 @@ struct Values { bool display_titlebar; bool show_filter_bar; bool show_status_bar; + int fixed_screen_size; bool confirm_before_closing; bool first_start;