Skip to content

Commit 0680a3f

Browse files
committed
AutoDJProcessor: Trigger reculation of the remaining play time when required
1 parent e32f818 commit 0680a3f

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/library/autodj/autodjprocessor.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ AutoDJProcessor::AutoDJProcessor(
6969
&PlaylistTableModel::playlistTracksChanged,
7070
this,
7171
&AutoDJProcessor::playlistTracksChanged);
72+
connect(pTrackCollectionManager->internalCollection(),
73+
&TrackCollection::tracksChanged,
74+
this,
75+
&AutoDJProcessor::tracksChanged);
76+
connect(pTrackCollectionManager->internalCollection(),
77+
&TrackCollection::multipleTracksChanged,
78+
this,
79+
&AutoDJProcessor::multipleTracksChanged);
7280

7381
connect(pPlayerManager,
7482
&PlayerManagerInterface::numberOfDecksChanged,
@@ -123,6 +131,15 @@ void AutoDJProcessor::playlistTracksChanged() {
123131
updateQueueDuration();
124132
}
125133

134+
void AutoDJProcessor::tracksChanged(const QSet<TrackId>& tracks) {
135+
Q_UNUSED(tracks);
136+
updateQueueDuration();
137+
}
138+
139+
void AutoDJProcessor::multipleTracksChanged() {
140+
updateQueueDuration();
141+
}
142+
126143
int AutoDJProcessor::getQueueTrackCount() const {
127144
return m_pAutoDJTableModel->rowCount();
128145
}
@@ -1800,6 +1817,7 @@ void AutoDJProcessor::setTransitionTime(int time) {
18001817
// User has changed the orientation, disable Auto DJ
18011818
toggleAutoDJ(false);
18021819
emit autoDJError(ADJ_NOT_TWO_DECKS);
1820+
updateQueueDuration();
18031821
return;
18041822
}
18051823
if (pLeftDeck->isPlaying()) {
@@ -1809,6 +1827,10 @@ void AutoDJProcessor::setTransitionTime(int time) {
18091827
calculateTransition(pRightDeck, pLeftDeck, false);
18101828
}
18111829
}
1830+
1831+
// Recalculate the duration of the Auto DJ playlist,
1832+
// which may have been affected by the transition time change
1833+
updateQueueDuration();
18121834
}
18131835

18141836
void AutoDJProcessor::setTransitionMode(TransitionMode newMode) {
@@ -1817,7 +1839,9 @@ void AutoDJProcessor::setTransitionMode(TransitionMode newMode) {
18171839
m_transitionMode = newMode;
18181840

18191841
if (m_eState != ADJ_IDLE) {
1820-
// We don't want to recalculate a running transition
1842+
// We don't want to recalculate a running transition,
1843+
// only the remaining queue play time
1844+
updateQueueDuration();
18211845
return;
18221846
}
18231847

@@ -1829,6 +1853,7 @@ void AutoDJProcessor::setTransitionMode(TransitionMode newMode) {
18291853
// User has changed the orientation, disable Auto DJ
18301854
toggleAutoDJ(false);
18311855
emit autoDJError(ADJ_NOT_TWO_DECKS);
1856+
updateQueueDuration();
18321857
return;
18331858
}
18341859

@@ -1845,6 +1870,10 @@ void AutoDJProcessor::setTransitionMode(TransitionMode newMode) {
18451870
// user has manually started the other deck or stopped both.
18461871
// don't know what to do.
18471872
}
1873+
1874+
// Recalculate the duration of the Auto DJ playlist,
1875+
// which may have been affected by the transition mode change
1876+
updateQueueDuration();
18481877
}
18491878

18501879
DeckAttributes* AutoDJProcessor::getLeftDeck() {

src/library/autodj/autodjprocessor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "library/playlisttablemodel.h"
1616
#include "preferences/usersettings.h"
1717
#include "track/track_decl.h"
18+
#include "track/trackid.h"
1819
#include "util/class.h"
1920
#include "util/duration.h"
2021
#include "util/parented_ptr.h"
@@ -126,6 +127,8 @@ class AutoDJProcessor : public QObject {
126127
void playlistFirstTrackChanged();
127128

128129
void playlistTracksChanged();
130+
void tracksChanged(const QSet<TrackId>& tracks);
131+
void multipleTracksChanged();
129132

130133
void controlEnableChangeRequest(double value);
131134
void controlFadeNow(double value);

0 commit comments

Comments
 (0)