From 6fa51c2fe4f4c38e741e41beb9a58e7ad16fec2f Mon Sep 17 00:00:00 2001 From: OpenSauce04 Date: Tue, 20 Jan 2026 23:52:56 +0000 Subject: [PATCH] qt: Implement Update Channel setting --- src/citra_qt/citra_qt.cpp | 16 +++++-- src/citra_qt/configuration/config.cpp | 3 +- .../configuration/configure_general.cpp | 7 ++- .../configuration/configure_general.ui | 45 +++++++++++++++---- src/citra_qt/uisettings.h | 8 ++++ 5 files changed, 65 insertions(+), 14 deletions(-) diff --git a/src/citra_qt/citra_qt.cpp b/src/citra_qt/citra_qt.cpp index 6267c7a93..6bd859ba8 100644 --- a/src/citra_qt/citra_qt.cpp +++ b/src/citra_qt/citra_qt.cpp @@ -171,12 +171,21 @@ void GMainWindow::ShowCommandOutput(std::string title, std::string message) { #endif } -bool IsPrerelease() { +bool IsPrereleaseBuild() { return ((strstr(Common::g_build_fullname, "alpha") != NULL) || (strstr(Common::g_build_fullname, "beta") != NULL) || (strstr(Common::g_build_fullname, "rc") != NULL)); } +#ifdef ENABLE_QT_UPDATE_CHECKER +bool ShouldCheckForPrereleaseUpdates() { + const bool update_channel = UISettings::values.update_check_channel.GetValue(); + const bool using_prerelease_channel = + (update_channel == UISettings::UpdateCheckChannels::PRERELEASE); + return (IsPrereleaseBuild() || using_prerelease_channel); +} +#endif + GMainWindow::GMainWindow(Core::System& system_) : ui{std::make_unique()}, system{system_}, movie{system.Movie()}, user_data_migrator{this}, config{std::make_unique()}, emu_thread{nullptr} { @@ -406,7 +415,8 @@ GMainWindow::GMainWindow(Core::System& system_) if (UISettings::values.check_for_update_on_start) { update_future = QtConcurrent::run([]() -> QString { const std::optional latest_release_tag = - UpdateChecker::GetLatestRelease(IsPrerelease()); + UpdateChecker::GetLatestRelease(ShouldCheckForPrereleaseUpdates()); + if (latest_release_tag && latest_release_tag.value() != Common::g_build_fullname) { return QString::fromStdString(latest_release_tag.value()); } @@ -4057,7 +4067,7 @@ void GMainWindow::OnEmulatorUpdateAvailable() { update_prompt.exec(); if (update_prompt.button(QMessageBox::Yes) == update_prompt.clickedButton()) { std::string update_page_url; - if (IsPrerelease()) { + if (ShouldCheckForPrereleaseUpdates()) { update_page_url = "https://github.com/azahar-emu/azahar/releases"; } else { update_page_url = "https://azahar-emu.org/pages/download/"; diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 2eb891a75..b429cdae0 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -568,6 +568,7 @@ void QtConfig::ReadMiscellaneousValues() { ReadBasicSetting(Settings::values.log_regex_filter); ReadBasicSetting(Settings::values.enable_gamemode); ReadBasicSetting(UISettings::values.check_for_update_on_start); + ReadBasicSetting(UISettings::values.update_check_channel); qt_config->endGroup(); } @@ -1139,7 +1140,7 @@ void QtConfig::SaveMiscellaneousValues() { WriteBasicSetting(Settings::values.log_regex_filter); WriteBasicSetting(Settings::values.enable_gamemode); WriteBasicSetting(UISettings::values.check_for_update_on_start); - + WriteBasicSetting(UISettings::values.update_check_channel); qt_config->endGroup(); } diff --git a/src/citra_qt/configuration/configure_general.cpp b/src/citra_qt/configuration/configure_general.cpp index 9a2d58a68..d6311b20d 100644 --- a/src/citra_qt/configuration/configure_general.cpp +++ b/src/citra_qt/configuration/configure_general.cpp @@ -44,7 +44,7 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) ui->toggle_gamemode->setVisible(false); #endif #ifndef ENABLE_QT_UPDATE_CHECKER - ui->toggle_update_checker->setVisible(false); + ui->updates_group->setVisible(false); #endif SetupPerGameUI(); @@ -92,6 +92,8 @@ void ConfigureGeneral::SetConfiguration() { ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); ui->toggle_update_checker->setChecked( UISettings::values.check_for_update_on_start.GetValue()); + ui->update_channel_combobox->setCurrentIndex( + UISettings::values.update_check_channel.GetValue()); #ifdef __unix__ ui->toggle_gamemode->setChecked(Settings::values.enable_gamemode.GetValue()); #endif @@ -179,6 +181,7 @@ void ConfigureGeneral::ApplyConfiguration() { UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked(); UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); UISettings::values.check_for_update_on_start = ui->toggle_update_checker->isChecked(); + UISettings::values.update_check_channel = ui->update_channel_combobox->currentIndex(); #ifdef __unix__ Settings::values.enable_gamemode = ui->toggle_gamemode->isChecked(); #endif @@ -211,5 +214,5 @@ void ConfigureGeneral::SetupPerGameUI() { ui->general_group->setVisible(false); ui->button_reset_defaults->setVisible(false); ui->toggle_gamemode->setVisible(false); - ui->toggle_update_checker->setVisible(false); + ui->updates_group->setVisible(false); } diff --git a/src/citra_qt/configuration/configure_general.ui b/src/citra_qt/configuration/configure_general.ui index a4fee730a..1c4a05631 100644 --- a/src/citra_qt/configuration/configure_general.ui +++ b/src/citra_qt/configuration/configure_general.ui @@ -16,6 +16,43 @@ + + + + Updates + + + + + + Check for updates + + + + + + + Update Channel + + + + + + + + Stable + + + + + Prerelease + + + + + + + @@ -57,13 +94,6 @@ - - - - Check for updates - - - @@ -315,7 +345,6 @@ toggle_check_exit toggle_background_pause toggle_hide_mouse - toggle_update_checker button_reset_defaults diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h index f9f42353a..1138d6b40 100644 --- a/src/citra_qt/uisettings.h +++ b/src/citra_qt/uisettings.h @@ -59,6 +59,12 @@ enum class GameListText : s32 { ListEnd, ///< Keep this at the end of the enum. }; +class UpdateCheckChannels { +public: + static constexpr int STABLE = 0; + static constexpr int PRERELEASE = 1; +}; + struct Values { QByteArray geometry; QByteArray state; @@ -84,6 +90,8 @@ struct Values { Settings::Setting mute_when_in_background{false, "muteWhenInBackground"}; Settings::Setting hide_mouse{false, "hideInactiveMouse"}; Settings::Setting check_for_update_on_start{true, "check_for_update_on_start"}; + Settings::Setting update_check_channel{UpdateCheckChannels::STABLE, + "update_check_channel"}; Settings::Setting inserted_cartridge{"", "inserted_cartridge"};