From 2647fe4bbc36120a391a7c3584334e14478b941b Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Tue, 19 Nov 2013 00:13:45 +0100 Subject: [PATCH] Emit MPRIS notification when we add or remove a playlist. Fixes issue 3962. --- src/core/mpris2.cpp | 13 ++++++++++++- src/core/mpris2.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/mpris2.cpp b/src/core/mpris2.cpp index d0a1ba9ff..2c7f1e853 100644 --- a/src/core/mpris2.cpp +++ b/src/core/mpris2.cpp @@ -104,6 +104,7 @@ Mpris2::Mpris2(Application* app, Mpris1* mpris1, QObject* parent) connect(app_->playlist_manager(), SIGNAL(PlaylistManagerInitialized()), SLOT(PlaylistManagerInitialized())); connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(CurrentSongChanged(Song))); connect(app_->playlist_manager(), SIGNAL(PlaylistChanged(Playlist*)), SLOT(PlaylistChanged(Playlist*))); + connect(app_->playlist_manager(), SIGNAL(CurrentChanged(Playlist*)), SLOT(PlaylistCollectionChanged(Playlist*))); } // when PlaylistManager gets it ready, we connect PlaylistSequence with this @@ -136,12 +137,16 @@ void Mpris2::RepeatModeChanged() { } void Mpris2::EmitNotification(const QString& name, const QVariant& val) { + EmitNotification(name, val, "org.mpris.MediaPlayer2.Player"); +} + +void Mpris2::EmitNotification(const QString& name, const QVariant& val, const QString& mprisEntity) { QDBusMessage msg = QDBusMessage::createSignal( kMprisObjectPath, kFreedesktopPath, "PropertiesChanged"); QVariantMap map; map.insert(name, val); QVariantList args = QVariantList() - << "org.mpris.MediaPlayer2.Player" + << mprisEntity << map << QStringList(); msg.setArguments(args); @@ -576,4 +581,10 @@ void Mpris2::PlaylistChanged(Playlist* playlist) { emit PlaylistChanged(mpris_playlist); } +void Mpris2::PlaylistCollectionChanged(Playlist* playlist){ + + qLog(Debug) << "Playlist collection changed (" << playlist->id() << ")"; + EmitNotification("PlaylistCount", "", "org.mpris.MediaPlayer2.Playlists"); +} + } // namespace mpris diff --git a/src/core/mpris2.h b/src/core/mpris2.h index 999994cd4..06402646e 100644 --- a/src/core/mpris2.h +++ b/src/core/mpris2.h @@ -202,10 +202,12 @@ private slots: void ShuffleModeChanged(); void RepeatModeChanged(); void PlaylistChanged(Playlist* playlist); + void PlaylistCollectionChanged(Playlist* playlist); private: void EmitNotification(const QString& name); void EmitNotification(const QString& name, const QVariant& val); + void EmitNotification(const QString& name, const QVariant& val, const QString& mprisEntity); QString PlaybackStatus(Engine::State state) const;