service/mpris: preserve mpris watcher and players across reload

This commit is contained in:
outfoxxed 2024-06-02 16:18:45 -07:00
parent 9d5dd402b9
commit b1f5a5eb94
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 29 additions and 11 deletions

View file

@ -16,7 +16,7 @@ namespace qs::service::mpris {
Q_LOGGING_CATEGORY(logMprisWatcher, "quickshell.service.mpris.watcher", QtWarningMsg);
MprisWatcher::MprisWatcher(QObject* parent): QObject(parent) {
MprisWatcher::MprisWatcher() {
qCDebug(logMprisWatcher) << "Starting MprisWatcher";
auto bus = QDBusConnection::sessionBus();
@ -102,4 +102,13 @@ void MprisWatcher::registerPlayer(const QString& address) {
qCDebug(logMprisWatcher) << "Registered MprisPlayer" << address;
}
MprisWatcher* MprisWatcher::instance() {
static MprisWatcher* instance = new MprisWatcher(); // NOLINT
return instance;
}
ObjectModel<MprisPlayer>* MprisQml::players() { // NOLINT
return MprisWatcher::instance()->players();
}
} // namespace qs::service::mpris