From e9846de5bec56b6866bbe0d0cd66bd36a59d1d22 Mon Sep 17 00:00:00 2001 From: RedBlackAka <140876408+RedBlackAka@users.noreply.github.com> Date: Tue, 20 Jan 2026 18:31:56 +0100 Subject: [PATCH] qt: Exclude some features logic if disabled at compile time (#1630) * Qt: Exclude more logic if disabled * Fix license * Fix * Exclude stress test logic * Fix RequestStop --- src/citra_qt/citra_qt.cpp | 25 ++++++++++++++----- src/citra_qt/citra_qt.h | 10 +++++++- src/citra_qt/configuration/config.cpp | 13 +++++++++- .../configuration/configure_general.cpp | 4 +++ src/citra_qt/configuration/configure_web.cpp | 7 ++++-- src/citra_qt/configuration/configure_web.h | 3 +-- src/citra_qt/game_list.h | 2 ++ src/citra_qt/uisettings.h | 4 +++ 8 files changed, 56 insertions(+), 12 deletions(-) diff --git a/src/citra_qt/citra_qt.cpp b/src/citra_qt/citra_qt.cpp index 6267c7a93..5257e334c 100644 --- a/src/citra_qt/citra_qt.cpp +++ b/src/citra_qt/citra_qt.cpp @@ -60,7 +60,9 @@ #include "citra_qt/debugger/profiler.h" #include "citra_qt/debugger/registers.h" #include "citra_qt/debugger/wait_tree.h" +#ifdef USE_DISCORD_PRESENCE #include "citra_qt/discord.h" +#endif #include "citra_qt/dumping/dumping_dialog.h" #include "citra_qt/game_list.h" #include "citra_qt/hotkeys.h" @@ -341,8 +343,10 @@ GMainWindow::GMainWindow(Core::System& system_) default_theme_paths = QIcon::themeSearchPaths(); UpdateUITheme(); +#ifdef USE_DISCORD_PRESENCE SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); discord_rpc->Update(); +#endif play_time_manager = std::make_unique(); @@ -1511,7 +1515,10 @@ void GMainWindow::ShutdownGame() { AllowOSSleep(); +#ifdef USE_DISCORD_PRESENCE discord_rpc->Pause(); +#endif + emu_thread->RequestStop(); // Release emu threads from any breakpoints @@ -1539,8 +1546,9 @@ void GMainWindow::ShutdownGame() { OnCloseMovie(); +#ifdef USE_DISCORD_PRESENCE discord_rpc->Update(); - +#endif #ifdef __unix__ Common::Linux::StopGamemode(); #endif @@ -1591,6 +1599,7 @@ void GMainWindow::ShutdownGame() { secondary_window->ReleaseRenderTarget(); } +#ifdef ENABLE_DEVELOPER_OPTIONS void GMainWindow::StartLaunchStressTest(const QString& game_path) { QThreadPool::globalInstance()->start([this, game_path] { do { @@ -1600,6 +1609,7 @@ void GMainWindow::StartLaunchStressTest(const QString& game_path) { } while (emulation_running); }); } +#endif void GMainWindow::StoreRecentFile(const QString& filename) { UISettings::values.recent_files.prepend(filename); @@ -2476,8 +2486,9 @@ void GMainWindow::OnStartGame() { play_time_manager->SetProgramId(game_title_id); play_time_manager->Start(); +#ifdef USE_DISCORD_PRESENCE discord_rpc->Update(); - +#endif #ifdef __unix__ Common::Linux::StartGamemode(); #endif @@ -2801,7 +2812,9 @@ void GMainWindow::OnConfigure() { const int old_input_profile_index = Settings::values.current_input_profile_index; const auto old_input_profiles = Settings::values.input_profiles; const auto old_touch_from_button_maps = Settings::values.touch_from_button_maps; +#ifdef USE_DISCORD_PRESENCE const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue(); +#endif #ifdef __unix__ const bool old_gamemode = Settings::values.enable_gamemode.GetValue(); #endif @@ -2813,9 +2826,11 @@ void GMainWindow::OnConfigure() { if (UISettings::values.theme != old_theme) { UpdateUITheme(); } +#ifdef USE_DISCORD_PRESENCE if (UISettings::values.enable_discord_presence.GetValue() != old_discord_presence) { SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); } +#endif #ifdef __unix__ if (Settings::values.enable_gamemode.GetValue() != old_gamemode) { SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue()); @@ -4171,18 +4186,16 @@ void GMainWindow::RetranslateStatusBar() { multiplayer_state->retranslateUi(); } -void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { #ifdef USE_DISCORD_PRESENCE +void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { if (state) { discord_rpc = std::make_unique(system); } else { discord_rpc = std::make_unique(); } -#else - discord_rpc = std::make_unique(); -#endif discord_rpc->Update(); } +#endif #ifdef __unix__ void GMainWindow::SetGamemodeEnabled(bool state) { diff --git a/src/citra_qt/citra_qt.h b/src/citra_qt/citra_qt.h index f65a7c593..a4fa3c9aa 100644 --- a/src/citra_qt/citra_qt.h +++ b/src/citra_qt/citra_qt.h @@ -66,9 +66,11 @@ namespace Camera { class QtMultimediaCameraHandlerFactory; } +#ifdef USE_DISCORD_PRESENCE namespace DiscordRPC { class DiscordInterface; } +#endif namespace PlayTime { class PlayTimeManager; @@ -107,7 +109,9 @@ public: GameList* game_list; std::unique_ptr play_time_manager; +#ifdef USE_DISCORD_PRESENCE std::unique_ptr discord_rpc; +#endif bool DropAction(QDropEvent* event); void AcceptDropEvent(QDropEvent* event); @@ -168,7 +172,9 @@ private: void BootGame(const QString& filename); void ShutdownGame(); +#ifdef USE_DISCORD_PRESENCE void SetDiscordEnabled(bool state); +#endif void LoadAmiibo(const QString& filename); /** @@ -306,7 +312,9 @@ private slots: #endif void OnSwitchDiskResources(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total); +#ifdef ENABLE_DEVELOPER_OPTIONS void StartLaunchStressTest(const QString& game_path); +#endif private: Q_INVOKABLE void OnMoviePlaybackCompleted(); @@ -436,8 +444,8 @@ private: std::shared_ptr qt_cameras; - // Prompt shown when update check succeeds #ifdef ENABLE_QT_UPDATE_CHECKER + // Prompt shown when update check succeeds QFuture update_future; QFutureWatcher update_watcher; #endif diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 2eb891a75..5da4a2da8 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -566,8 +566,12 @@ void QtConfig::ReadMiscellaneousValues() { ReadBasicSetting(Settings::values.log_filter); ReadBasicSetting(Settings::values.log_regex_filter); +#ifdef __unix__ ReadBasicSetting(Settings::values.enable_gamemode); +#endif +#ifdef ENABLE_QT_UPDATE_CHECKER ReadBasicSetting(UISettings::values.check_for_update_on_start); +#endif qt_config->endGroup(); } @@ -810,7 +814,9 @@ void QtConfig::ReadUIValues() { UISettings::values.theme = ReadSetting(QStringLiteral("theme"), QString::fromUtf8(UISettings::themes[0].second)) .toString(); +#ifdef USE_DISCORD_PRESENCE ReadBasicSetting(UISettings::values.enable_discord_presence); +#endif ReadBasicSetting(UISettings::values.screenshot_resolution_factor); ReadUILayoutValues(); @@ -1137,9 +1143,12 @@ void QtConfig::SaveMiscellaneousValues() { WriteBasicSetting(Settings::values.log_filter); WriteBasicSetting(Settings::values.log_regex_filter); +#ifdef __unix__ WriteBasicSetting(Settings::values.enable_gamemode); +#endif +#ifdef ENABLE_QT_UPDATE_CHECKER WriteBasicSetting(UISettings::values.check_for_update_on_start); - +#endif qt_config->endGroup(); } @@ -1328,7 +1337,9 @@ void QtConfig::SaveUIValues() { if (global) { WriteSetting(QStringLiteral("theme"), UISettings::values.theme, QString::fromUtf8(UISettings::themes[0].second)); +#ifdef USE_DISCORD_PRESENCE WriteBasicSetting(UISettings::values.enable_discord_presence); +#endif WriteBasicSetting(UISettings::values.screenshot_resolution_factor); SaveUILayoutValues(); diff --git a/src/citra_qt/configuration/configure_general.cpp b/src/citra_qt/configuration/configure_general.cpp index 9a2d58a68..9b9d77455 100644 --- a/src/citra_qt/configuration/configure_general.cpp +++ b/src/citra_qt/configuration/configure_general.cpp @@ -90,8 +90,10 @@ void ConfigureGeneral::SetConfiguration() { ui->toggle_background_mute->setChecked( UISettings::values.mute_when_in_background.GetValue()); ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); +#ifdef ENABLE_QT_UPDATE_CHECKER ui->toggle_update_checker->setChecked( UISettings::values.check_for_update_on_start.GetValue()); +#endif #ifdef __unix__ ui->toggle_gamemode->setChecked(Settings::values.enable_gamemode.GetValue()); #endif @@ -178,7 +180,9 @@ void ConfigureGeneral::ApplyConfiguration() { UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked(); 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(); +#endif #ifdef __unix__ Settings::values.enable_gamemode = ui->toggle_gamemode->isChecked(); #endif diff --git a/src/citra_qt/configuration/configure_web.cpp b/src/citra_qt/configuration/configure_web.cpp index 511a06cfe..9d83547df 100644 --- a/src/citra_qt/configuration/configure_web.cpp +++ b/src/citra_qt/configuration/configure_web.cpp @@ -1,4 +1,4 @@ -// Copyright 2017 Citra Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -23,12 +23,15 @@ ConfigureWeb::ConfigureWeb(QWidget* parent) ConfigureWeb::~ConfigureWeb() = default; void ConfigureWeb::SetConfiguration() { - +#ifdef USE_DISCORD_PRESENCE ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence.GetValue()); +#endif } void ConfigureWeb::ApplyConfiguration() { +#ifdef USE_DISCORD_PRESENCE UISettings::values.enable_discord_presence = ui->toggle_discordrpc->isChecked(); +#endif } void ConfigureWeb::RetranslateUI() { diff --git a/src/citra_qt/configuration/configure_web.h b/src/citra_qt/configuration/configure_web.h index 53f7f2b18..92eed0238 100644 --- a/src/citra_qt/configuration/configure_web.h +++ b/src/citra_qt/configuration/configure_web.h @@ -1,11 +1,10 @@ -// Copyright 2017 Citra Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. #pragma once #include -#include #include namespace Ui { diff --git a/src/citra_qt/game_list.h b/src/citra_qt/game_list.h index a28cf4290..f74bc297b 100644 --- a/src/citra_qt/game_list.h +++ b/src/citra_qt/game_list.h @@ -107,7 +107,9 @@ signals: void AddDirectory(); void ShowList(bool show); void PopulatingCompleted(); +#ifdef ENABLE_DEVELOPER_OPTIONS void StartingLaunchStressTest(const QString& game_path); +#endif private slots: void OnItemExpanded(const QModelIndex& item); diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h index f9f42353a..ddd608e29 100644 --- a/src/citra_qt/uisettings.h +++ b/src/citra_qt/uisettings.h @@ -83,12 +83,16 @@ struct Values { Settings::Setting pause_when_in_background{false, "pauseWhenInBackground"}; Settings::Setting mute_when_in_background{false, "muteWhenInBackground"}; Settings::Setting hide_mouse{false, "hideInactiveMouse"}; +#ifdef ENABLE_QT_UPDATE_CHECKER Settings::Setting check_for_update_on_start{true, "check_for_update_on_start"}; +#endif Settings::Setting inserted_cartridge{"", "inserted_cartridge"}; +#ifdef USE_DISCORD_PRESENCE // Discord RPC Settings::Setting enable_discord_presence{true, "enable_discord_presence"}; +#endif // Game List Settings::Setting game_list_icon_size{GameListIconSize::LargeIcon,