From 9f42a12baf2636e1168b34aec413f787203ae881 Mon Sep 17 00:00:00 2001 From: "Alexander Y." Date: Wed, 20 Nov 2024 07:41:35 +0100 Subject: [PATCH] Fix build when -DENABLE_DISCORD_RPC=OFF (#1551) * added ifdef for discordrpc * replaced discordrpc include correctly --- src/common/discord_rpc_handler.cpp | 2 +- src/qt_gui/main_window.cpp | 6 +++++- src/qt_gui/main_window.h | 1 - src/qt_gui/settings_dialog.cpp | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/discord_rpc_handler.cpp b/src/common/discord_rpc_handler.cpp index 91b278a1..ce99d683 100644 --- a/src/common/discord_rpc_handler.cpp +++ b/src/common/discord_rpc_handler.cpp @@ -3,7 +3,7 @@ #include #include -#include "src/common/discord_rpc_handler.h" +#include "discord_rpc_handler.h" namespace DiscordRPCHandler { diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 959b055c..f2ee8789 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -22,6 +22,9 @@ #include "main_window.h" #include "settings_dialog.h" #include "video_core/renderer_vulkan/vk_instance.h" +#ifdef ENABLE_DISCORD_RPC +#include "common/discord_rpc_handler.h" +#endif MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); @@ -76,12 +79,13 @@ bool MainWindow::Init() { "Games: " + QString::number(numGames) + " (" + QString::number(duration.count()) + "ms)"; statusBar->showMessage(statusMessage); - // Initialize Discord RPC +#ifdef ENABLE_DISCORD_RPC if (Config::getEnableDiscordRPC()) { auto* rpc = Common::Singleton::Instance(); rpc->init(); rpc->setStatusIdling(); } +#endif return true; } diff --git a/src/qt_gui/main_window.h b/src/qt_gui/main_window.h index 7dc85f0a..5ae2540e 100644 --- a/src/qt_gui/main_window.h +++ b/src/qt_gui/main_window.h @@ -9,7 +9,6 @@ #include "background_music_player.h" #include "common/config.h" -#include "common/discord_rpc_handler.h" #include "common/path_util.h" #include "core/file_format/psf.h" #include "core/file_sys/fs.h" diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index 83582663..abbd39ed 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -173,6 +173,7 @@ SettingsDialog::SettingsDialog(std::span physical_devices, QWidge BackgroundMusicPlayer::getInstance().setVolume(val); }); +#ifdef ENABLE_DISCORD_RPC connect(ui->discordRPCCheckbox, &QCheckBox::stateChanged, this, [](int val) { Config::setEnableDiscordRPC(val); auto* rpc = Common::Singleton::Instance(); @@ -183,6 +184,7 @@ SettingsDialog::SettingsDialog(std::span physical_devices, QWidge rpc->shutdown(); } }); +#endif } // Input TAB