diff --git a/src/library/autodj/dlgautodj.cpp b/src/library/autodj/dlgautodj.cpp index 43c0dbb94fe..88b73953d73 100644 --- a/src/library/autodj/dlgautodj.cpp +++ b/src/library/autodj/dlgautodj.cpp @@ -207,6 +207,11 @@ DlgAutoDJ::DlgAutoDJ(WLibrary* parent, this, &DlgAutoDJ::transitionTimeChanged); + connect(m_pAutoDJProcessor, + &AutoDJProcessor::remainingTimeChanged, + this, + &DlgAutoDJ::remainingTimeChanged); + connect(m_pAutoDJProcessor, &AutoDJProcessor::autoDJError, this, @@ -317,6 +322,12 @@ void DlgAutoDJ::transitionSliderChanged(int value) { m_pAutoDJProcessor->setTransitionTime(value); } +void DlgAutoDJ::remainingTimeChanged(int numTracks, mixxx::Duration duration) { + Q_UNUSED(numTracks); + Q_UNUSED(duration); + updateSelectionInfo(); +} + void DlgAutoDJ::autoDJStateChanged(AutoDJProcessor::AutoDJState state) { if (state == AutoDJProcessor::ADJ_DISABLED) { pushButtonAutoDJ->setChecked(false); @@ -362,24 +373,34 @@ void DlgAutoDJ::slotRepeatPlaylistChanged(bool checked) { } void DlgAutoDJ::updateSelectionInfo() { + // Obtain the total duration of the whole remaining Auto DJ queue + // from the Auto DJ processor. The calculated time is exact and + // takes transition times, intros, outros etc. into account. + mixxx::Duration totalDuration = m_pAutoDJProcessor->getRemainingTime(); + int totalTracks = m_pAutoDJTableModel->rowCount(); + + // Derive total duration of the selected tracks from the table model. + // This is much faster than getting the duration from individual track + // objects (but does not take transition times into account...) QModelIndexList indices = m_pTrackTableView->selectionModel()->selectedRows(); + mixxx::Duration selectedDuration = m_pAutoDJTableModel->getTotalDuration(indices); + int selectedTracks = indices.size(); - // Derive total duration from the table model. This is much faster than - // getting the duration from individual track objects. - mixxx::Duration duration = m_pAutoDJTableModel->getTotalDuration(indices); - + // Selected tracks QString label; - if (!indices.isEmpty()) { - label.append(mixxx::DurationBase::formatTime(duration.toDoubleSeconds())); - label.append(QString(" (%1)").arg(indices.size())); - labelSelectionInfo->setToolTip(tr("Displays the duration and number of selected tracks.")); - labelSelectionInfo->setText(label); - labelSelectionInfo->setEnabled(true); - } else { - labelSelectionInfo->setText(""); - labelSelectionInfo->setEnabled(false); + label.append(mixxx::DurationBase::formatTime(selectedDuration.toDoubleSeconds())); + label.append(QString(" (%1)").arg(selectedTracks)); + label.append(tr(" / ")); } + + // Total tracks + label.append(mixxx::DurationBase::formatTime(totalDuration.toDoubleSeconds())); + label.append(QString(" (%1)").arg(totalTracks)); + + labelSelectionInfo->setToolTip(tr("Displays the duration and number of selected tracks.")); + labelSelectionInfo->setText(label); + labelSelectionInfo->setEnabled(true); } bool DlgAutoDJ::hasFocus() const { diff --git a/src/library/autodj/dlgautodj.h b/src/library/autodj/dlgautodj.h index a2d976dc774..01b787d59e6 100644 --- a/src/library/autodj/dlgautodj.h +++ b/src/library/autodj/dlgautodj.h @@ -44,6 +44,7 @@ class DlgAutoDJ : public QWidget, public Ui::DlgAutoDJ, public LibraryView { void autoDJError(AutoDJProcessor::AutoDJError error); void transitionTimeChanged(int time); void transitionSliderChanged(int value); + void remainingTimeChanged(int numTracks, mixxx::Duration duration); void autoDJStateChanged(AutoDJProcessor::AutoDJState state); void updateSelectionInfo(); void slotTransitionModeChanged(int comboboxIndex);