1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-18 12:28:31 +01:00

Emit MPRIS notification when we add or remove a playlist.

Fixes issue 3962.
This commit is contained in:
Aggelos Biboudis 2013-11-19 00:13:45 +01:00 committed by Arnaud Bienner
parent 6e3a456046
commit 2647fe4bbc
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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;