Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions res/skins/LateNight/decks/rate_controls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@
<Size>5f,5f</Size>
<Pos>2,59</Pos>
<Connection>
<ConfigKey><Variable name="Group"/>,rate</ConfigKey>
<Transform><IsEqual>0.5</IsEqual></Transform>
<ConfigKey><Variable name="Group"/>,rate_set_default</ConfigKey>
<BindProperty>highlight</BindProperty>
</Connection>
</Label>
Expand Down
6 changes: 2 additions & 4 deletions res/skins/LateNight/decks/rate_controls_compact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@
<Size>5f,5f</Size>
<Pos>2,39</Pos>
<Connection>
<ConfigKey><Variable name="Group"/>,rate</ConfigKey>
<Transform><IsEqual>0.5</IsEqual></Transform>
<ConfigKey><Variable name="Group"/>,rate_set_default</ConfigKey>
<BindProperty>highlight</BindProperty>
</Connection>
</Label>
Expand Down Expand Up @@ -174,8 +173,7 @@
<Size>5f,5f</Size>
<Pos>2,47</Pos>
<Connection>
<ConfigKey><Variable name="Group"/>,rate</ConfigKey>
<Transform><IsEqual>0.5</IsEqual></Transform>
<ConfigKey><Variable name="Group"/>,rate_set_default</ConfigKey>
<BindProperty>highlight</BindProperty>
</Connection>
</Label>
Expand Down
31 changes: 24 additions & 7 deletions src/control/controlpotmeter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "control/controlpotmeter.h"

#include "control/control.h"
#include "control/controlproxy.h"
#include "control/controlpushbutton.h"
#include "moc_controlpotmeter.cpp"
Expand All @@ -20,10 +21,16 @@ ControlPotmeter::ControlPotmeter(const ConfigKey& key,
if (!bPersist) {
set(default_value);
}
//qDebug() << "" << this << ", min " << m_dMinValue << ", max " << m_dMaxValue << ", range " << m_dValueRange << ", val " << m_dValue;
}
//qDebug() << "" << this << ", min " << dMinValue << ", max " << dMaxValue << ", default " << default_value;

ControlPotmeter::~ControlPotmeter() {
if (m_pControl) {
connect(m_pControl.data(),
&ControlDoublePrivate::valueChanged,
this,
&ControlPotmeter::privateValueChanged,
Qt::DirectConnection);
}
m_controls.setIsDefault(get() == default_value);
}

void ControlPotmeter::setStepCount(int count) {
Expand All @@ -44,6 +51,12 @@ void ControlPotmeter::setRange(double dMinValue, double dMaxValue,
}
}

// slot
void ControlPotmeter::privateValueChanged(double dValue, QObject* pSender) {
Q_UNUSED(pSender);
m_controls.setIsDefault(dValue == defaultValue());
}

PotmeterControls::PotmeterControls(const ConfigKey& key)
: m_pControl(new ControlProxy(key, this)),
m_stepCount(10),
Expand Down Expand Up @@ -84,10 +97,10 @@ PotmeterControls::PotmeterControls(const ConfigKey& key)
this,
&PotmeterControls::decSmallValue);

ControlPushButton* controlDefault = new ControlPushButton(
ConfigKey(key.group, QString(key.item) + "_set_default"));
controlDefault->setParent(this);
connect(controlDefault,
m_pControlDefault = new ControlPushButton(
ConfigKey(key.group, QString(key.item) + "_set_default"));
m_pControlDefault->setParent(this);
connect(m_pControlDefault,
&ControlPushButton::valueChanged,
this,
&PotmeterControls::setToDefault);
Expand Down Expand Up @@ -202,3 +215,7 @@ void PotmeterControls::toggleMinusValue(double v) {
m_pControl->set(value > 0.0 ? -1.0 : 1.0);
}
}

void PotmeterControls::setIsDefault(bool isDefault) {
m_pControlDefault->forceSet(isDefault ? 1.0 : 0.0);
}
8 changes: 7 additions & 1 deletion src/control/controlpotmeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ class PotmeterControls : public QObject {
void toggleValue(double);
// Toggles the value between -1.0 and 0.0.
void toggleMinusValue(double);
void setIsDefault(bool isDefault);

private:
ControlProxy* m_pControl;
ControlPushButton* m_pControlDefault;
int m_stepCount;
double m_smallStepCount;
};
Expand All @@ -59,7 +61,7 @@ class ControlPotmeter : public ControlObject {
bool bTrack = false,
bool bPersist = false,
double defaultValue = 0.0);
virtual ~ControlPotmeter();
~ControlPotmeter() override = default;

// Sets the step count of the associated PushButtons.
void setStepCount(int count);
Expand All @@ -71,6 +73,10 @@ class ControlPotmeter : public ControlObject {
// when calling this method
void setRange(double dMinValue, double dMaxValue, bool allowOutOfBounds);

private slots:
// Used to check if the current control value matches the default value.
void privateValueChanged(double dValue, QObject* pSender);

protected:
bool m_bAllowOutOfBounds;
PotmeterControls m_controls;
Expand Down