RichPresence: Formatting and add settings reload

This commit is contained in:
Jonas Kvinge
2025-03-30 00:06:05 +01:00
parent 34fb289e33
commit d5f7a4b883
6 changed files with 109 additions and 62 deletions

View File

@@ -228,6 +228,10 @@
# include <qtsparkle-qt6/Updater>
#endif // HAVE_QTSPARKLE
#ifdef HAVE_DISCORD_RPC
#include "discord/richpresence.h"
#endif
using std::make_unique;
using std::make_shared;
using namespace std::chrono_literals;
@@ -275,7 +279,13 @@ constexpr char QTSPARKLE_URL[] = "https://www.strawberrymusicplayer.org/sparkle-
} // namespace
#endif // HAVE_QTSPARKLE
MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OSDBase *osd, const CommandlineOptions &options, QWidget *parent)
MainWindow::MainWindow(Application *app,
SharedPtr<SystemTrayIcon> tray_icon, OSDBase *osd,
#ifdef HAVE_DISCORD_RPC
discord::RichPresence *discord_rich_presence,
#endif
const CommandlineOptions &options,
QWidget *parent)
: QMainWindow(parent),
ui_(new Ui_MainWindow),
#ifdef Q_OS_WIN32
@@ -284,6 +294,9 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
app_(app),
tray_icon_(tray_icon),
osd_(osd),
#ifdef HAVE_DISCORD_RPC
discord_rich_presence_(discord_rich_presence),
#endif
console_([app, this]() {
Console *console = new Console(app->database());
QObject::connect(console, &Console::Error, this, &MainWindow::ShowErrorDialog);
@@ -1317,6 +1330,9 @@ void MainWindow::ReloadAllSettings() {
qobuz_view_->ReloadSettings();
qobuz_view_->search_view()->ReloadSettings();
#endif
#ifdef HAVE_DISCORD_RPC
discord_rich_presence_->ReloadSettings();
#endif
}

View File

@@ -99,11 +99,17 @@ class AddStreamDialog;
class LastFMImportDialog;
class RadioViewContainer;
#ifdef HAVE_DISCORD_RPC
namespace discord {
class RichPresence;
}
#endif
class MainWindow : public QMainWindow, public PlatformInterface {
Q_OBJECT
public:
explicit MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OSDBase *osd, const CommandlineOptions &options, QWidget *parent = nullptr);
explicit MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OSDBase *osd, discord::RichPresence *discord_rich_presence, const CommandlineOptions &options, QWidget *parent = nullptr);
~MainWindow() override;
void SetHiddenInTray(const bool hidden);
@@ -296,6 +302,9 @@ class MainWindow : public QMainWindow, public PlatformInterface {
Application *app_;
SharedPtr<SystemTrayIcon> tray_icon_;
OSDBase *osd_;
#ifdef HAVE_DISCORD_RPC
discord::RichPresence *discord_rich_presence_;
#endif
Lazy<About> about_dialog_;
Lazy<Console> console_;
Lazy<EditTagDialog> edit_tag_dialog_;