From b57df44d4e9c80b27bb7983760f84ec498ef7569 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 | 2 + .../configuration/configure_general.cpp | 7 ++- .../configuration/configure_general.ui | 45 +++++++++++++++---- src/citra_qt/uisettings.h | 8 ++++ 5 files changed, 65 insertions(+), 13 deletions(-) diff --git a/src/citra_qt/citra_qt.cpp b/src/citra_qt/citra_qt.cpp index 5257e334c..3bf862c6b 100644 --- a/src/citra_qt/citra_qt.cpp +++ b/src/citra_qt/citra_qt.cpp @@ -173,12 +173,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} { @@ -410,7 +419,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()); } @@ -4072,7 +4082,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 5da4a2da8..f5aac8030 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -571,6 +571,7 @@ void QtConfig::ReadMiscellaneousValues() { #endif #ifdef ENABLE_QT_UPDATE_CHECKER ReadBasicSetting(UISettings::values.check_for_update_on_start); + ReadBasicSetting(UISettings::values.update_check_channel); #endif qt_config->endGroup(); @@ -1148,6 +1149,7 @@ void QtConfig::SaveMiscellaneousValues() { #endif #ifdef ENABLE_QT_UPDATE_CHECKER WriteBasicSetting(UISettings::values.check_for_update_on_start); + WriteBasicSetting(UISettings::values.update_check_channel); #endif qt_config->endGroup(); } diff --git a/src/citra_qt/configuration/configure_general.cpp b/src/citra_qt/configuration/configure_general.cpp index 9b9d77455..ab8eb2a3c 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(); @@ -93,6 +93,8 @@ void ConfigureGeneral::SetConfiguration() { #ifdef ENABLE_QT_UPDATE_CHECKER ui->toggle_update_checker->setChecked( UISettings::values.check_for_update_on_start.GetValue()); + ui->update_channel_combobox->setCurrentIndex( + UISettings::values.update_check_channel.GetValue()); #endif #ifdef __unix__ ui->toggle_gamemode->setChecked(Settings::values.enable_gamemode.GetValue()); @@ -182,6 +184,7 @@ void ConfigureGeneral::ApplyConfiguration() { UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); #ifdef ENABLE_QT_UPDATE_CHECKER UISettings::values.check_for_update_on_start = ui->toggle_update_checker->isChecked(); + UISettings::values.update_check_channel = ui->update_channel_combobox->currentIndex(); #endif #ifdef __unix__ Settings::values.enable_gamemode = ui->toggle_gamemode->isChecked(); @@ -215,5 +218,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 ddd608e29..e027f3ff5 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; @@ -85,6 +91,8 @@ struct Values { Settings::Setting hide_mouse{false, "hideInactiveMouse"}; #ifdef ENABLE_QT_UPDATE_CHECKER Settings::Setting check_for_update_on_start{true, "check_for_update_on_start"}; + Settings::Setting update_check_channel{UpdateCheckChannels::STABLE, + "update_check_channel"}; #endif Settings::Setting inserted_cartridge{"", "inserted_cartridge"};