diff --git a/src/mixer/basetrackplayer.cpp b/src/mixer/basetrackplayer.cpp index d377c86d5bf..7b44ced9da0 100644 --- a/src/mixer/basetrackplayer.cpp +++ b/src/mixer/basetrackplayer.cpp @@ -213,26 +213,7 @@ TrackPointer BaseTrackPlayerImpl::loadFakeTrack(bool bPlay, double filebpm) { m_pLoadedTrack = pTrack; if (m_pLoadedTrack) { // Listen for updates to the file's BPM - connect(m_pLoadedTrack.get(), - &Track::bpmUpdated, - m_pFileBPM.get(), - QOverload::of(&ControlObject::set)); - - connect(m_pLoadedTrack.get(), - &Track::keyUpdated, - m_pKey.get(), - &ControlProxy::set); - - // Listen for updates to the file's Replay Gain - connect(m_pLoadedTrack.get(), - &Track::replayGainUpdated, - this, - &BaseTrackPlayerImpl::slotSetReplayGain); - - connect(m_pLoadedTrack.get(), - &Track::colorUpdated, - this, - &BaseTrackPlayerImpl::slotSetTrackColor); + connectLoadedTrack(); } // Request a new track from EngineBuffer @@ -349,17 +330,32 @@ TrackPointer BaseTrackPlayerImpl::unloadTrack() { void BaseTrackPlayerImpl::connectLoadedTrack() { connect(m_pLoadedTrack.get(), - &Track::bpmUpdated, - m_pFileBPM.get(), - QOverload::of(&ControlObject::set)); + &Track::bpmChanged, + this, + [this] { + TrackPointer pTrack = m_pLoadedTrack; + if (pTrack) { + m_pFileBPM->set(pTrack->getBpm()); + } + }); + connect(m_pLoadedTrack.get(), - &Track::keyUpdated, - m_pKey.get(), - &ControlProxy::set); + &Track::keyChanged, + this, + [this] { + TrackPointer pTrack = m_pLoadedTrack; + if (pTrack) { + const auto key = pTrack->getKeys().getGlobalKey(); + m_pKey->set(static_cast(key)); + } + }); + + // Listen for updates to the file's Replay Gain connect(m_pLoadedTrack.get(), &Track::replayGainUpdated, this, &BaseTrackPlayerImpl::slotSetReplayGain); + connect(m_pLoadedTrack.get(), &Track::colorUpdated, this, diff --git a/src/track/track.cpp b/src/track/track.cpp index 5ae33fe3867..54e0552b525 100644 --- a/src/track/track.cpp +++ b/src/track/track.cpp @@ -179,7 +179,6 @@ void Track::replaceMetadataFromSource( beatsAndBpmModified = trySetBpmWhileLocked(importedBpm.getValue()); } modified |= beatsAndBpmModified; - const auto newBpm = getBpmWhileLocked(); auto keysModified = false; if (importedKey != mixxx::track::io::key::INVALID) { @@ -190,7 +189,6 @@ void Track::replaceMetadataFromSource( mixxx::track::io::key::FILE_METADATA); } modified |= keysModified; - const auto newKey = m_record.getGlobalKey(); // Import track color from Serato tags if available const auto newColor = m_record.getMetadata().getTrackInfo().getSeratoTags().getTrackColor(); @@ -206,10 +204,10 @@ void Track::replaceMetadataFromSource( markDirtyAndUnlock(&lock); if (beatsAndBpmModified) { - emitBeatsAndBpmUpdated(newBpm); + emitBeatsAndBpmUpdated(); } if (keysModified) { - emitKeysUpdated(newKey); + emit keyChanged(); } if (oldReplayGain != newReplayGain) { emit replayGainUpdated(newReplayGain); @@ -304,12 +302,10 @@ bool Track::replaceRecord( markDirtyAndUnlock(&locked); if (bpmUpdatedFlag) { - emit bpmUpdated(newBpm.getValue()); - emit beatsUpdated(); - emit bpmTextChanged(); + emitBeatsAndBpmUpdated(); } if (oldKey != newKey) { - emitKeysUpdated(newKey); + emit keyChanged(); } if (oldReplayGain != newReplayGain) { emit replayGainUpdated(newReplayGain); @@ -437,16 +433,13 @@ void Track::afterBeatsAndBpmUpdated( QMutexLocker* pLock) { DEBUG_ASSERT(pLock); - const auto bpm = getBpmWhileLocked(); markDirtyAndUnlock(pLock); - emitBeatsAndBpmUpdated(bpm); + emitBeatsAndBpmUpdated(); } -void Track::emitBeatsAndBpmUpdated( - mixxx::Bpm newBpm) { - emit bpmUpdated(newBpm.getValue()); +void Track::emitBeatsAndBpmUpdated() { + emit bpmChanged(); emit beatsUpdated(); - emit bpmTextChanged(); } void Track::emitMetadataChanged() { @@ -461,12 +454,11 @@ void Track::emitMetadataChanged() { emit trackNumberChanged(getTrackNumber()); emit trackTotalChanged(getTrackTotal()); emit commentChanged(getComment()); - emit bpmTextChanged(); + emit bpmChanged(); emit timesPlayedChanged(); emit durationChanged(); emit infoChanged(); - emit keysUpdated(); - emit bpmUpdated(getBpm()); + emit keyChanged(); } void Track::setMetadataSynchronized(bool metadataSynchronized) { @@ -1328,15 +1320,8 @@ void Track::setRating (int rating) { } void Track::afterKeysUpdated(QMutexLocker* pLock) { - const auto newKey = m_record.getGlobalKey(); markDirtyAndUnlock(pLock); - emitKeysUpdated(newKey); -} - -void Track::emitKeysUpdated(mixxx::track::io::key::ChromaticKey newKey) { - // New key might be INVALID. We don't care. - emit keyUpdated(KeyUtils::keyToNumericValue(newKey)); - emit keysUpdated(); + emit keyChanged(); } void Track::setKeys(const Keys& keys) { diff --git a/src/track/track.h b/src/track/track.h index f68b08037d3..11b5a03f980 100644 --- a/src/track/track.h +++ b/src/track/track.h @@ -61,18 +61,15 @@ class Track : public QObject { Q_PROPERTY(QString trackTotal READ getTrackTotal WRITE setTrackTotal NOTIFY trackTotalChanged) Q_PROPERTY(int timesPlayed READ getTimesPlayed NOTIFY timesPlayedChanged) Q_PROPERTY(QString comment READ getComment WRITE setComment NOTIFY commentChanged) - Q_PROPERTY(double bpm READ getBpm NOTIFY bpmUpdated) - Q_PROPERTY(QString bpmFormatted READ getBpmText STORED false NOTIFY bpmTextChanged) - Q_PROPERTY(QString key READ getKeyText WRITE setKeyText NOTIFY keysUpdated) + Q_PROPERTY(double bpm READ getBpm NOTIFY bpmChanged) + Q_PROPERTY(QString bpmText READ getBpmText STORED false NOTIFY bpmChanged) + Q_PROPERTY(QString keyText READ getKeyText WRITE setKeyText NOTIFY keyChanged) Q_PROPERTY(double duration READ getDuration NOTIFY durationChanged) - Q_PROPERTY(QString durationFormatted READ getDurationTextSeconds + Q_PROPERTY(QString durationText READ getDurationTextSeconds STORED false NOTIFY durationChanged) + Q_PROPERTY(QString durationTextCentiseconds READ getDurationTextCentiseconds + STORED false NOTIFY durationChanged) + Q_PROPERTY(QString durationTextMilliseconds READ getDurationTextMilliseconds STORED false NOTIFY durationChanged) - Q_PROPERTY(QString durationFormattedCentiseconds READ - getDurationTextCentiseconds - STORED false NOTIFY durationChanged) - Q_PROPERTY(QString durationFormattedMilliseconds READ - getDurationTextMilliseconds - STORED false NOTIFY durationChanged) Q_PROPERTY(QString info READ getInfo STORED false NOTIFY infoChanged) Q_PROPERTY(QString titleInfo READ getTitleInfo STORED false NOTIFY infoChanged) @@ -381,7 +378,8 @@ class Track : public QObject { void trackNumberChanged(const QString&); void trackTotalChanged(const QString&); void commentChanged(const QString&); - void bpmTextChanged(); + void bpmChanged(); + void keyChanged(); void timesPlayedChanged(); void durationChanged(); void infoChanged(); @@ -389,10 +387,7 @@ class Track : public QObject { void waveformUpdated(); void waveformSummaryUpdated(); void coverArtUpdated(); - void bpmUpdated(double bpm); void beatsUpdated(); - void keyUpdated(double key); - void keysUpdated(); void replayGainUpdated(mixxx::ReplayGain replayGain); void colorUpdated(const mixxx::RgbColor::optional_t& color); void cuesUpdated(); @@ -424,10 +419,9 @@ class Track : public QObject { void setDirtyAndUnlock(QMutexLocker* pLock, bool bDirty); void afterKeysUpdated(QMutexLocker* pLock); - void emitKeysUpdated(mixxx::track::io::key::ChromaticKey newKey); void afterBeatsAndBpmUpdated(QMutexLocker* pLock); - void emitBeatsAndBpmUpdated(mixxx::Bpm newBpm); + void emitBeatsAndBpmUpdated(); /// Emits a changed signal for each Q_PROPERTY void emitMetadataChanged();