diff --git a/src/library/autodj/autodjfeature.cpp b/src/library/autodj/autodjfeature.cpp index 4a943289f32..39a9e5b3f07 100644 --- a/src/library/autodj/autodjfeature.cpp +++ b/src/library/autodj/autodjfeature.cpp @@ -96,6 +96,12 @@ AutoDJFeature::AutoDJFeature(Library* pLibrary, this, &AutoDJFeature::slotCrateChanged); + // Be notified when tracks are added/removed to/from playlist(s). + connect(&m_playlistDao, + &PlaylistDAO::tracksChanged, + this, + &AutoDJFeature::slotPlaylistsChanged); + // Create context-menu items to allow crates to be added to, and removed // from, the auto-DJ queue. m_pRemoveCrateFromAutoDj = new QAction(tr("Remove Crate as Track Source"), this); @@ -111,7 +117,15 @@ AutoDJFeature::~AutoDJFeature() { } QVariant AutoDJFeature::title() { - return tr("Auto DJ"); + QString title = tr("Auto DJ"); + + PlaylistSummary summary; + if (m_pTrackCollection->playlists().readAutoDJPlaylistSummary(&summary) && + summary.getTrackCount() > 0) { + title.append(QString(" (%1)").arg(summary.getTrackDurationText())); + } + + return title; } void AutoDJFeature::bindLibraryWidget( @@ -322,3 +336,10 @@ void AutoDJFeature::slotRandomQueue(int numTracksToAdd) { slotAddRandomTrack(); } } + +void AutoDJFeature::slotPlaylistsChanged(const QSet& playlistIds) { + if (playlistIds.contains(m_iAutoDJPlaylistId)) { + // If AutoDJ playlist was changed, notify that feature title has changed since it contains duration of the AutoDJ playlist. + emit featureIsLoading(this, false); + } +} diff --git a/src/library/autodj/autodjfeature.h b/src/library/autodj/autodjfeature.h index 35ee88e903d..1a1eb3568e8 100644 --- a/src/library/autodj/autodjfeature.h +++ b/src/library/autodj/autodjfeature.h @@ -99,4 +99,6 @@ class AutoDJFeature : public LibraryFeature { // Adds a random track from the queue upon hitting minimum number // of tracks in the playlist void slotRandomQueue(int numTracksToAdd); + + void slotPlaylistsChanged(const QSet& playlistIds); };