summaryrefslogtreecommitdiffstats
path: root/src/engine/controls
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/controls')
-rw-r--r--src/engine/controls/bpmcontrol.cpp2
-rw-r--r--src/engine/controls/bpmcontrol.h2
-rw-r--r--src/engine/controls/clockcontrol.cpp2
-rw-r--r--src/engine/controls/clockcontrol.h4
-rw-r--r--src/engine/controls/cuecontrol.cpp292
-rw-r--r--src/engine/controls/cuecontrol.h54
-rw-r--r--src/engine/controls/enginecontrol.cpp4
-rw-r--r--src/engine/controls/enginecontrol.h4
-rw-r--r--src/engine/controls/keycontrol.cpp4
-rw-r--r--src/engine/controls/keycontrol.h2
-rw-r--r--src/engine/controls/loopingcontrol.cpp15
-rw-r--r--src/engine/controls/loopingcontrol.h8
-rw-r--r--src/engine/controls/quantizecontrol.cpp4
-rw-r--r--src/engine/controls/quantizecontrol.h2
-rw-r--r--src/engine/controls/ratecontrol.cpp14
-rw-r--r--src/engine/controls/ratecontrol.h282
-rw-r--r--src/engine/controls/vinylcontrolcontrol.cpp2
-rw-r--r--src/engine/controls/vinylcontrolcontrol.h2
18 files changed, 386 insertions, 313 deletions
diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp
index 20285ca89f..52370da16d 100644
--- a/src/engine/controls/bpmcontrol.cpp
+++ b/src/engine/controls/bpmcontrol.cpp
@@ -40,7 +40,7 @@ constexpr int kLocalBpmSpan = 4;
constexpr SINT kSamplesPerFrame = 2;
}
-BpmControl::BpmControl(QString group,
+BpmControl::BpmControl(const QString& group,
UserSettingsPointer pConfig)
: EngineControl(group, pConfig),
m_tapFilter(this, kBpmTapFilterLength, kBpmTapMaxInterval),
diff --git a/src/engine/controls/bpmcontrol.h b/src/engine/controls/bpmcontrol.h
index 4257595dc5..156fdca700 100644
--- a/src/engine/controls/bpmcontrol.h
+++ b/src/engine/controls/bpmcontrol.h
@@ -22,7 +22,7 @@ class BpmControl : public EngineControl {
Q_OBJECT
public:
- BpmControl(QString group, UserSettingsPointer pConfig);
+ BpmControl(const QString& group, UserSettingsPointer pConfig);
~BpmControl() override;
double getBpm() const;
diff --git a/src/engine/controls/clockcontrol.cpp b/src/engine/controls/clockcontrol.cpp
index 2a374aa1b4..f48660bb4c 100644
--- a/src/engine/controls/clockcontrol.cpp
+++ b/src/engine/controls/clockcontrol.cpp
@@ -6,7 +6,7 @@
#include "preferences/usersettings.h"
#include "track/track.h"
-ClockControl::ClockControl(QString group, UserSettingsPointer pConfig)
+ClockControl::ClockControl(const QString& group, UserSettingsPointer pConfig)
: EngineControl(group, pConfig) {
m_pCOBeatActive = new ControlObject(ConfigKey(group, "beat_active"));
m_pCOBeatActive->set(0.0);
diff --git a/src/engine/controls/clockcontrol.h b/src/engine/controls/clockcontrol.h
index 1a26d30d8c..87667db443 100644
--- a/src/engine/controls/clockcontrol.h
+++ b/src/engine/controls/clockcontrol.h
@@ -11,8 +11,8 @@ class ControlObject;
class ClockControl: public EngineControl {
Q_OBJECT
public:
- ClockControl(QString group,
- UserSettingsPointer pConfig);
+ ClockControl(const QString& group,
+ UserSettingsPointer pConfig);
~ClockControl() override;
diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp
index 3a92609105..f8ac0c8e20 100644
--- a/src/engine/controls/cuecontrol.cpp
+++ b/src/engine/controls/cuecontrol.cpp
@@ -26,6 +26,7 @@ constexpr double CUE_MODE_CUP = 5.0;
/// This is the position of a fresh loaded tack without any seek
constexpr double kDefaultLoadPosition = 0.0;
+constexpr int kNoHotCueNumber = 0;
// Helper function to convert control values (i.e. doubles) into RgbColor
// instances (or nullopt if value < 0). This happens by using the integer
@@ -41,9 +42,37 @@ inline mixxx::RgbColor::optional_t doubleToRgbColor(double value) {
return mixxx::RgbColor::optional(colorCode);
}
+/// Convert hot cue index to 1-based number
+///
+/// Works independent of if the hot cue index is either 0-based
+/// or 1..n-based.
+inline int hotcueIndexToHotcueNumber(int hotcueIndex) {
+ if (hotcueIndex >= Cue::kFirstHotCue) {
+ DEBUG_ASSERT(hotcueIndex != Cue::kNoHotCue);
+ return (hotcueIndex - Cue::kFirstHotCue) + 1; // to 1-based numbering
+ } else {
+ DEBUG_ASSERT(hotcueIndex == Cue::kNoHotCue);
+ return kNoHotCueNumber;
+ }
+}
+
+/// Convert 1-based hot cue number to hot cue index.
+///
+/// Works independent of if the hot cue index is either 0-based
+/// or 1..n-based.
+inline int hotcueNumberToHotcueIndex(int hotcueNumber) {
+ if (hotcueNumber >= 1) {
+ DEBUG_ASSERT(hotcueNumber != kNoHotCueNumber);
+ return Cue::kFirstHotCue + (hotcueNumber - 1); // from 1-based numbering
+ } else {
+ DEBUG_ASSERT(hotcueNumber == kNoHotCueNumber);
+ return Cue::kNoHotCue;
+ }
+}
+
} // namespace
-CueControl::CueControl(QString group,
+CueControl::CueControl(const QString& group,
UserSettingsPointer pConfig)
: EngineControl(group, pConfig),
m_pConfig(pConfig),
@@ -132,6 +161,9 @@ CueControl::CueControl(QString group,
m_pCueIndicator = new ControlIndicator(ConfigKey(group, "cue_indicator"));
m_pPlayIndicator = new ControlIndicator(ConfigKey(group, "play_indicator"));
+ m_pPlayLatched = new ControlObject(ConfigKey(group, "play_latched"));
+ m_pPlayLatched->setReadOnly();
+
m_pIntroStartPosition = new ControlObject(ConfigKey(group, "intro_start_position"));
m_pIntroStartPosition->set(Cue::kNoPosition);
@@ -220,7 +252,7 @@ CueControl::CueControl(QString group,
m_pVinylControlMode = new ControlProxy(group, "vinylcontrol_mode");
m_pHotcueFocus = new ControlObject(ConfigKey(group, "hotcue_focus"));
- m_pHotcueFocus->set(Cue::kNoHotCue);
+ setHotcueFocusIndex(Cue::kNoHotCue);
m_pHotcueFocusColorPrev = new ControlObject(ConfigKey(group, "hotcue_focus_color_prev"));
connect(m_pHotcueFocusColorPrev,
@@ -252,6 +284,7 @@ CueControl::~CueControl() {
delete m_pPlayStutter;
delete m_pCueIndicator;
delete m_pPlayIndicator;
+ delete m_pPlayLatched;
delete m_pIntroStartPosition;
delete m_pIntroStartEnabled;
delete m_pIntroStartSet;
@@ -313,7 +346,7 @@ void CueControl::createControls() {
}
}
-void CueControl::attachCue(CuePointer pCue, HotcueControl* pControl) {
+void CueControl::attachCue(const CuePointer& pCue, HotcueControl* pControl) {
VERIFY_OR_DEBUG_ASSERT(pControl) {
return;
}
@@ -355,7 +388,7 @@ void CueControl::trackLoaded(TrackPointer pNewTrack) {
m_pOutroStartEnabled->forceSet(0.0);
m_pOutroEndPosition->set(Cue::kNoPosition);
m_pOutroEndEnabled->forceSet(0.0);
- m_pHotcueFocus->set(Cue::kNoHotCue);
+ setHotcueFocusIndex(Cue::kNoHotCue);
m_pLoadedTrack.reset();
m_usedSeekOnLoadPosition.setValue(kDefaultLoadPosition);
}
@@ -644,15 +677,16 @@ void CueControl::quantizeChanged(double v) {
void CueControl::hotcueSet(HotcueControl* pControl, double value) {
//qDebug() << "CueControl::hotcueSet" << value;
- if (value == 0) {
+ if (value <= 0) {
return;
}
QMutexLocker lock(&m_mutex);
- if (!m_pLoadedTrack)
+ if (!m_pLoadedTrack) {
return;
+ }
- int hotcue = pControl->getHotcueNumber();
+ int hotcueIndex = pControl->getHotcueIndex();
// Note: the cue is just detached from the hotcue control
// It remains in the database for later use
// TODO: find a rule, that allows us to delete the cue as well
@@ -662,14 +696,14 @@ void CueControl::hotcueSet(HotcueControl* pControl, double value) {
CuePointer pCue(m_pLoadedTrack->createAndAddCue());
double cuePosition = getQuantizedCurrentPosition();
pCue->setStartPosition(cuePosition);
- pCue->setHotCue(hotcue);
+ pCue->setHotCue(hotcueIndex);
pCue->setLabel();
pCue->setType(mixxx::CueType::HotCue);
const ColorPalette hotcueColorPalette =
m_colorPaletteSettings.getHotcueColorPalette();
if (getConfig()->getValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false)) {
- pCue->setColor(hotcueColorPalette.colorForHotcueIndex(hotcue));
+ pCue->setColor(hotcueColorPalette.colorForHotcueIndex(hotcueIndex));
} else {
int hotcueDefaultColorIndex = m_pConfig->getValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), -1);
if (hotcueDefaultColorIndex < 0 || hotcueDefaultColorIndex >= hotcueColorPalette.size()) {
@@ -693,7 +727,7 @@ void CueControl::hotcueSet(HotcueControl* pControl, double value) {
}
void CueControl::hotcueGoto(HotcueControl* pControl, double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -716,7 +750,7 @@ void CueControl::hotcueGoto(HotcueControl* pControl, double value) {
}
void CueControl::hotcueGotoAndStop(HotcueControl* pControl, double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -732,14 +766,19 @@ void CueControl::hotcueGotoAndStop(HotcueControl* pControl, double value) {
if (pCue) {
double position = pCue->getPosition();
if (position != Cue::kNoPosition) {
- m_pPlay->set(0.0);
- seekExact(position);
+ if (!m_iCurrentlyPreviewingHotcues && !m_bPreviewing) {
+ m_pPlay->set(0.0);
+ seekExact(position);
+ } else {
+ // this becomes a play latch command if we are previewing
+ m_pPlay->set(0.0);
+ }
}
}
}
void CueControl::hotcueGotoAndPlay(HotcueControl* pControl, double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -784,7 +823,7 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double value) {
lock.unlock();
if (pCue) {
- if (value != 0) {
+ if (value > 0) {
if (pCue->getPosition() == Cue::kNoPosition) {
hotcueSet(pControl, value);
} else {
@@ -801,7 +840,7 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double value) {
}
} else {
// The cue is non-existent ...
- if (value != 0) {
+ if (value > 0) {
// set it to the current position
hotcueSet(pControl, value);
} else if (m_iCurrentlyPreviewingHotcues) {
@@ -813,7 +852,7 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double value) {
}
}
- m_pHotcueFocus->set(pControl->getHotcueNumber());
+ setHotcueFocusIndex(pControl->getHotcueIndex());
}
void CueControl::hotcueActivatePreview(HotcueControl* pControl, double value) {
@@ -823,8 +862,8 @@ void CueControl::hotcueActivatePreview(HotcueControl* pControl, double value) {
}
CuePointer pCue(pControl->getCue());
- if (value != 0) {
- if (pCue && pCue->getPosition() != Cue::kNoPosition) {
+ if (value > 0) {
+ if (pCue && pCue->getPosition() != Cue::kNoPosition && !pControl->isPreviewing()) {
m_iCurrentlyPreviewingHotcues++;
double position = pCue->getPosition();
m_bypassCueSetByPlay = true;
@@ -858,7 +897,7 @@ void CueControl::hotcueActivatePreview(HotcueControl* pControl, double value) {
}
void CueControl::hotcueClear(HotcueControl* pControl, double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -873,7 +912,7 @@ void CueControl::hotcueClear(HotcueControl* pControl, double value) {
}
detachCue(pControl);
m_pLoadedTrack->removeCue(pCue);
- m_pHotcueFocus->set(Cue::kNoHotCue);
+ setHotcueFocusIndex(Cue::kNoHotCue);
}
void CueControl::hotcuePositionChanged(HotcueControl* pControl, double newPosition) {
@@ -919,7 +958,7 @@ void CueControl::hintReader(HintVector* pHintList) {
// Moves the cue point to current position or to closest beat in case
// quantize is enabled
void CueControl::cueSet(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -937,7 +976,7 @@ void CueControl::cueSet(double value) {
}
void CueControl::cueClear(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -952,7 +991,7 @@ void CueControl::cueClear(double value) {
}
void CueControl::cueGoto(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -967,7 +1006,7 @@ void CueControl::cueGoto(double value) {
}
void CueControl::cueGotoAndPlay(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -985,27 +1024,30 @@ void CueControl::cueGotoAndPlay(double value) {
}
void CueControl::cueGotoAndStop(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
- QMutexLocker lock(&m_mutex);
- m_pPlay->set(0.0);
- double cuePoint = m_pCuePoint->get();
-
- // Need to unlock before emitting any signals to prevent deadlock.
- lock.unlock();
-
- seekExact(cuePoint);
+ if (!m_iCurrentlyPreviewingHotcues && !m_bPreviewing) {
+ m_pPlay->set(0.0);
+ double position = m_pCuePoint->get();
+ seekExact(position);
+ } else {
+ // this becomes a play latch command if we are previewing
+ m_pPlay->set(0.0);
+ }
}
void CueControl::cuePreview(double value) {
+ //qDebug() << "CueControl::cuePreview" << value;
QMutexLocker lock(&m_mutex);
- if (value != 0) {
- m_bPreviewing = true;
- m_bypassCueSetByPlay = true;
- m_pPlay->set(1.0);
+ if (value > 0) {
+ if (!m_bPreviewing) {
+ m_bPreviewing = true;
+ m_bypassCueSetByPlay = true;
+ m_pPlay->set(1.0);
+ }
} else if (m_bPreviewing) {
m_bPreviewing = false;
if (m_iCurrentlyPreviewingHotcues) {
@@ -1033,8 +1075,11 @@ void CueControl::cueCDJ(double value) {
const auto freely_playing = m_pPlay->toBool() && !getEngineBuffer()->getScratching();
TrackAt trackAt = getTrackAt();
- if (value != 0) {
- if (m_iCurrentlyPreviewingHotcues) {
+ if (value > 0) {
+ if (m_bPreviewing) {
+ // already previewing, do nothing
+ return;
+ } else if (m_iCurrentlyPreviewingHotcues) {
// we are already previewing by hotcues
// just jump to cue point and continue previewing
m_bPreviewing = true;
@@ -1058,9 +1103,6 @@ void CueControl::cueCDJ(double value) {
} else {
// Pause not at cue point and not at end position
cueSet(value);
- // Just in case.
- m_bPreviewing = false;
- m_pPlay->set(0.0);
// If quantize is enabled, jump to the cue point since it's not
// necessarily where we currently are
@@ -1100,8 +1142,11 @@ void CueControl::cueDenon(double value) {
bool playing = (m_pPlay->toBool());
TrackAt trackAt = getTrackAt();
- if (value != 0) {
- if (m_iCurrentlyPreviewingHotcues) {
+ if (value > 0) {
+ if (m_bPreviewing) {
+ // already previewing, do nothing
+ return;
+ } else if (m_iCurrentlyPreviewingHotcues) {
// we are already previewing by hotcues
// just jump to cue point and continue previewing
m_bPreviewing = true;
@@ -1112,13 +1157,8 @@ void CueControl::cueDenon(double value) {
m_bPreviewing = true;
m_pPlay->set(1.0);
} else {
- // Just in case.
- m_bPreviewing = false;
- m_pPlay->set(0.0);
-
// Need to unlock before emitting any signals to prevent deadlock.
lock.unlock();
-
seekAbs(m_pCuePoint->get());
}
} else if (m_bPreviewing) {
@@ -1146,7 +1186,7 @@ void CueControl::cuePlay(double value) {
TrackAt trackAt = getTrackAt();
// pressed
- if (value != 0) {
+ if (value > 0) {
if (freely_playing) {
m_bPreviewing = false;
m_pPlay->set(0.0);
@@ -1212,7 +1252,7 @@ void CueControl::playStutter(double v) {
}
void CueControl::introStartSet(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1253,7 +1293,7 @@ void CueControl::introStartSet(double value) {
}
void CueControl::introStartClear(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1290,7 +1330,7 @@ void CueControl::introStartActivate(double value) {
}
void CueControl::introEndSet(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1331,7 +1371,7 @@ void CueControl::introEndSet(double value) {
}
void CueControl::introEndClear(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1368,7 +1408,7 @@ void CueControl::introEndActivate(double value) {
}
void CueControl::outroStartSet(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1409,7 +1449,7 @@ void CueControl::outroStartSet(double value) {
}
void CueControl::outroStartClear(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1430,7 +1470,7 @@ void CueControl::outroStartClear(double value) {
}
void CueControl::outroStartActivate(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1446,7 +1486,7 @@ void CueControl::outroStartActivate(double value) {
}
void CueControl::outroEndSet(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1487,7 +1527,7 @@ void CueControl::outroEndSet(double value) {
}
void CueControl::outroEndClear(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1508,7 +1548,7 @@ void CueControl::outroEndClear(double value) {
}
void CueControl::outroEndActivate(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
@@ -1546,8 +1586,10 @@ bool CueControl::updateIndicatorsAndModifyPlay(bool newPlay, bool oldPlay, bool
m_bPreviewing = false;
m_iCurrentlyPreviewingHotcues = 0;
newPlay = true;
+ m_pPlayLatched->forceSet(1.0);
} else {
previewing = true;
+ m_pPlayLatched->forceSet(0.0);
}
}
@@ -1558,13 +1600,16 @@ bool CueControl::updateIndicatorsAndModifyPlay(bool newPlay, bool oldPlay, bool
newPlay = false;
m_pPlayIndicator->setBlinkValue(ControlIndicator::OFF);
m_pStopButton->set(0.0);
+ m_pPlayLatched->forceSet(0.0);
} else if (newPlay && !previewing) {
// Play: Indicates a latched Play
m_pPlayIndicator->setBlinkValue(ControlIndicator::ON);
m_pStopButton->set(0.0);
+ m_pPlayLatched->forceSet(1.0);
} else {
// Pause:
m_pStopButton->set(1.0);
+ m_pPlayLatched->forceSet(0.0);
if (cueMode == CueMode::Denon) {
if (trackAt == TrackAt::Cue || previewing) {
m_pPlayIndicator->setBlinkValue(ControlIndicator::OFF);
@@ -1757,16 +1802,16 @@ SeekOnLoadMode CueControl::getSeekOnLoadPreference() {
}
void CueControl::hotcueFocusColorPrev(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
- int hotcueNumber = static_cast<int>(m_pHotcueFocus->get());
- if (hotcueNumber < 0 || hotcueNumber >= m_hotcueControls.size()) {
+ int hotcueIndex = getHotcueFocusIndex();
+ if (hotcueIndex < 0 || hotcueIndex >= m_hotcueControls.size()) {
return;
}
- HotcueControl* pControl = m_hotcueControls.at(hotcueNumber);
+ HotcueControl* pControl = m_hotcueControls.at(hotcueIndex);
if (!pControl) {
return;
}
@@ -1786,16 +1831,16 @@ void CueControl::hotcueFocusColorPrev(double value) {
}
void CueControl::hotcueFocusColorNext(double value) {
- if (value == 0) {
+ if (value <= 0) {
return;
}
- int hotcueNumber = static_cast<int>(m_pHotcueFocus->get());
- if (hotcueNumber < 0 || hotcueNumber >= m_hotcueControls.size()) {
+ int hotcueIndex = getHotcueFocusIndex();
+ if (hotcueIndex < 0 || hotcueIndex >= m_hotcueControls.size()) {
return;
}
- HotcueControl* pControl = m_hotcueControls.at(hotcueNumber);
+ HotcueControl* pControl = m_hotcueControls.at(hotcueIndex);
if (!pControl) {
return;
}
@@ -1814,89 +1859,108 @@ void CueControl::hotcueFocusColorNext(double value) {
pCue->setColor(colorPalette.nextColor(*color));
}
-ConfigKey HotcueControl::keyForControl(int hotcue, const char* name) {
+void CueControl::setHotcueFocusIndex(int hotcueIndex) {
+ m_pHotcueFocus->set(hotcueIndexToHotcueNumber(hotcueIndex));
+}
+
+int CueControl::getHotcueFocusIndex() const {
+ return hotcueNumberToHotcueIndex(static_cast<int>(m_pHotcueFocus->get()));
+}
+
+ConfigKey HotcueControl::keyForControl(const QString& name) {
ConfigKey key;
key.group = m_group;
// Add one to hotcue so that we don't have a hotcue_0
- key.item = QLatin1String("hotcue_") % QString::number(hotcue+1) % "_" % name;
+ key.item = QStringLiteral("hotcue_") +
+ QString::number(hotcueIndexToHotcueNumber(m_hotcueIndex)) +
+ QChar('_') + name;
return key;
}
-HotcueControl::HotcueControl(QString group, int i)
+HotcueControl::HotcueControl(const QString& group, int hotcueIndex)
: m_group(group),
- m_iHotcueNumber(i),
- m_pCue(NULL),
+ m_hotcueIndex(hotcueIndex),
+ m_pCue(nullptr),
m_bPreviewing(false),
m_previewingPosition(-1) {
- m_hotcuePosition = new ControlObject(keyForControl(i, "position"));
- connect(m_hotcuePosition, &ControlObject::valueChanged,
- this, &HotcueControl::slotHotcuePositionChanged,
+ m_hotcuePosition = std::make_unique<ControlObject>(keyForControl(QStringLiteral("position")));
+ connect(m_hotcuePosition.get(),
+ &ControlObject::valueChanged,
+ this,
+ &HotcueControl::slotHotcuePositionChanged,
Qt::DirectConnection);
m_hotcuePosition->set(Cue::kNoPosition);
- m_hotcueEnabled = new ControlObject(keyForControl(i, "enabled"));
+ m_hotcueEnabled = std::make_unique<ControlObject>(keyForControl(QStringLiteral("enabled")));
m_hotcueEnabled->setReadOnly();
// The rgba value of the color assigned to this color.
- m_hotcueColor = new ControlObject(keyForControl(i, "color"));
+ m_hotcueColor = std::make_unique<ControlObject>(keyForControl(QStringLiteral("color")));
m_hotcueColor->connectValueChangeRequest(
this,
&HotcueControl::slotHotcueColorChangeRequest,
Qt::DirectConnection);
- connect(m_hotcueColor,
+ connect(m_hotcueColor.get(),
&ControlObject::valueChanged,
this,
&HotcueControl::slotHotcueColorChanged,
Qt::DirectConnection);
- m_hotcueSet = new ControlPushButton(keyForControl(i, "set"));
- connect(m_hotcueSet, &ControlObject::valueChanged,
- this, &HotcueControl::slotHotcueSet,
+ m_hotcueSet = std::make_unique<ControlPushButton>(keyForControl(QStringLiteral("set")));
+ connect(m_hotcueSet.get(),
+ &ControlObject::valueChanged,
+ this,
+ &HotcueControl::slotHotcueSet,
Qt::DirectConnection);
- m_hotcueGoto = new ControlPushButton(keyForControl(i, "goto"));
- connect(m_hotcueGoto, &ControlObject::valueChanged,
- this, &HotcueControl::slotHotcueGoto,
+ m_hotcueGoto = std::make_unique<ControlPushButton>(keyForControl(QStringLiteral("goto")));
+ connect(m_hotcueGoto.get(),
+ &ControlObject::valueChanged,
+ this,
+ &HotcueControl::slotHotcueGoto,
Qt::DirectConnection);
- m_hotcueGotoAndPlay = new ControlPushButton(keyForControl(i, "gotoandplay"));
- connect(m_hotcueGotoAndPlay, &ControlObject::valueChanged,
- this, &HotcueControl::slotHotcueGotoAndPlay,
+ m_hotcueGotoAndPlay = std::make_unique<ControlPushButton>(
+ keyForControl(QStringLiteral("gotoandplay")));
+ connect(m_hotcueGotoAndPlay.get(),
+ &ControlObject::valueChanged,
+ this,
+ &HotcueControl::slotHotcueGotoAndPlay,
Qt::DirectConnection);
- m_hotcueGotoAndStop = new ControlPushButton(keyForControl(i, "gotoandstop"));
- connect(m_hotcueGotoAndStop, &ControlObject::valueChanged,
- this, &HotcueControl::slotHotcueGotoAndStop,
+ m_hotcueGotoAndStop = std::make_unique<ControlPushButton>(
+ keyForControl(QStringLiteral("gotoandstop")));
+ connect(m_hotcueGotoAndStop.get(),
+ &ControlObject::valueChanged,
+ this,
+ &HotcueControl::slotHotcueGotoAndStop,
Qt::DirectConnection);
- m_hotcueActivate = new ControlPushButton(keyForControl(i, "activate"));
- connect(m_hotcueActivate, &ControlObject::valueChanged,
- this, &HotcueControl::slotHotcueActivate,
+ m_hotcueActivate = std::make_unique<ControlPushButton>(
+ keyForControl(QStringLiteral("activate")));
+ connect(m_hotcueActivate.get(),
+ &ControlObject::valueChanged,
+ this,
+ &HotcueControl::slotHotcueActivate,
Qt::DirectConnection);
- m_hotcueActivatePreview = new ControlPushButton(keyForControl(i, "activate_preview"));
- connect(m_hotcueActivatePreview, &ControlObject::valueChanged,
- this, &HotcueControl::slotHotcueActivatePreview,
+ m_hotcueActivatePreview = std::make_unique<ControlPushButton>(
+ keyForControl(QStringLiteral("activate_preview")));
+ connect(m_hotcueActivatePreview.get(),
+ &ControlObject::valueChanged,
+ this,
+ &HotcueControl::slotHotcueActivatePreview,
Qt::DirectConnection);
- m_hotcueClear = new ControlPushButton(keyForControl(i, "clear"));
- connect(m_hotcueClear, &ControlObject::valueChanged,
- this, &HotcueControl::slotHotcueClear,
+ m_hotcueClear = std::make_unique<ControlPushButton>(keyForControl(QStringLiteral("clear")));
+ connect(m_hotcueClear.get(),
+ &ControlObject::valueChanged,
+ this,
+ &HotcueControl::slotHotcueClear,
Qt::DirectConnection);
}
-HotcueControl::~HotcueControl() {
- delete m_hotcuePosition;
- delete m_hotcueEnabled;
- delete m_hotcueColor;
- delete m_hotcueSet;
- delete m_hotcueGoto;
- delete m_hotcueGotoAndPlay;
- delete m_hotcueGotoAndStop;
- delete m_hotcueActivate;
- delete m_hotcueActivatePreview;
- delete m_hotcueClear;
-}
+HotcueControl::~HotcueControl() = default;
void HotcueControl::slotHotcueSet(double v) {
emit hotcueSet(this, v);
@@ -1957,7 +2021,7 @@ double HotcueControl::getPosition() const {
return m_hotcuePosition->get();
}
-void HotcueControl::setCue(CuePointer pCue) {
+void HotcueControl::setCue(const CuePointer& pCue) {
setPosition(pCue->getPosition());
setColor(pCue->getColor());
// set pCue only if all other data is in place
diff --git a/src/engine/controls/cuecontrol.h b/src/engine/controls/cuecontrol.h
index 8cd217569d..e71de0123a 100644
--- a/src/engine/controls/cuecontrol.h
+++ b/src/engine/controls/cuecontrol.h
@@ -39,29 +39,34 @@ inline SeekOnLoadMode seekOnLoadModeFromDouble(double value) {
class HotcueControl : public QObject {
Q_OBJECT
public:
- HotcueControl(QString group, int hotcueNumber);
+ HotcueControl(const QString& group, int hotcueIndex);
~HotcueControl() override;
- inline int getHotcueNumber() { return m_iHotcueNumber; }
- inline CuePointer getCue() { return m_pCue; }
+ int getHotcueIndex() const {
+ return m_hotcueIndex;
+ }
+
+ CuePointer getCue() const {
+ return m_pCue;
+ }
double getPosition() const;
- void setCue(CuePointer pCue);
+ void setCue(const CuePointer& pCue);
void resetCue();
void setPosition(double position);
void setColor(mixxx::RgbColor::optional_t newColor);
mixxx::RgbColor::optional_t getColor() const;
// Used for caching the preview state of this hotcue control.
- inline bool isPreviewing() {
+ bool isPreviewing() const {
return m_bPreviewing;
}
- inline void setPreviewing(bool bPreviewing) {
+ void setPreviewing(bool bPreviewing) {
m_bPreviewing = bPreviewing;
}
- inline double getPreviewingPosition() {
+ double getPreviewingPosition() const {
return m_previewingPosition;
}
- inline void setPreviewingPosition(double position) {
+ void setPreviewingPosition(double position) {
m_previewingPosition = position;
}
@@ -90,24 +95,24 @@ class HotcueControl : public QObject {
void hotcuePlay(double v);
private:
- ConfigKey keyForControl(int hotcue, const char* name);
+ ConfigKey keyForControl(const QString& name);
const QString m_group;
- int m_iHotcueNumber;
+ const int m_hotcueIndex;
CuePointer m_pCue;
// Hotcue state controls
- ControlObject* m_hotcuePosition;
- ControlObject* m_hotcueEnabled;
- ControlObject* m_hotcueColor;
+ std::unique_ptr<ControlObject> m_hotcuePosition;
+ std::unique_ptr<ControlObject> m_hotcueEnabled;
+ std::unique_ptr<ControlObject> m_hotcueColor;
// Hotcue button controls
- ControlObject* m_hotcueSet;
- ControlObject* m_hotcueGoto;
- ControlObject* m_hotcueGotoAndPlay;
- ControlObject* m_hotcueGotoAndStop;
- ControlObject* m_hotcueActivate;
- ControlObject* m_hotcueActivatePreview;
- ControlObject* m_hotcueClear;
+ std::unique_ptr<ControlPushButton> m_hotcueSet;
+ std::unique_ptr<ControlPushButton> m_hotcueGoto;
+ std::unique_ptr<ControlPushButton> m_hotcueGotoAndPlay;
+ std::unique_ptr<ControlPushButton> m_hotcueGotoAndStop;
+ std::unique_ptr<ControlPushButton> m_hotcueActivate;
+ std::unique_ptr<ControlPushButton> m_hotcueActivatePreview;
+ std::unique_ptr<ControlPushButton> m_hotcueClear;
bool m_bPreviewing;
double m_previewingPosition;
@@ -116,8 +121,8 @@ class HotcueControl : public QObject {
class CueControl : public EngineControl {
Q_OBJECT
public:
- CueControl(QString group,
- UserSettingsPointer pConfig);
+ CueControl(const QString& group,
+ UserSettingsPointer pConfig);
~CueControl() override;
void hintReader(HintVector* pHintList) override;
@@ -184,13 +189,15 @@ class CueControl : public EngineControl {
// These methods are not thread safe, only call them when the lock is held.
void createControls();
- void attachCue(CuePointer pCue, HotcueControl* pControl);
+ void attachCue(const CuePointer& pCue, HotcueControl* pControl);
void detachCue(HotcueControl* pControl);
void loadCuesFromTrack();
double quantizeCuePoint(double position);
double getQuantizedCurrentPosition();
TrackAt getTrackAt() const;
void seekOnLoad(double seekOnLoadPosition);
+ void setHotcueFocusIndex(int hotcueIndex);
+ int getHotcueFocusIndex() const;
UserSettingsPointer m_pConfig;
ColorPaletteSettings m_colorPaletteSettings;
@@ -216,6 +223,7 @@ class CueControl : public EngineControl {
ControlPushButton* m_pPlayStutter;
ControlIndicator* m_pCueIndicator;
ControlIndicator* m_pPlayIndicator;
+ ControlObject* m_pPlayLatched;
ControlPushButton* m_pCueGoto;
ControlPushButton* m_pCueGotoAndPlay;
ControlPushButton* m_pCuePlay;
diff --