Skip to content
/ mixxx Public
forked from mixxxdj/mixxx

Commit

Permalink
Show total AutoDJ track time in sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
ninomp committed Dec 4, 2022
1 parent 4555fe8 commit 8850afb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/library/autodj/autodjfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand Down Expand Up @@ -322,3 +336,10 @@ void AutoDJFeature::slotRandomQueue(int numTracksToAdd) {
slotAddRandomTrack();
}
}

void AutoDJFeature::slotPlaylistsChanged(const QSet<int>& 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);
}
}
2 changes: 2 additions & 0 deletions src/library/autodj/autodjfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>& playlistIds);
};

0 comments on commit 8850afb

Please sign in to comment.