From ecbcf3f7968013159afd2efd68e4001cf1a74b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 22 Apr 2015 01:12:20 +0200 Subject: [PATCH 1/5] Allow to set a value when initalize new COs --- src/control/control.cpp | 13 ++++++------- src/control/control.h | 6 +++--- src/controlobject.cpp | 8 ++++---- src/controlobject.h | 4 ++-- src/controlpushbutton.cpp | 4 ++-- src/controlpushbutton.h | 2 +- src/skin/legacyskinparser.cpp | 18 ++++++------------ 7 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/control/control.cpp b/src/control/control.cpp index 7ba8ac815cf..25ae9c08cf2 100644 --- a/src/control/control.cpp +++ b/src/control/control.cpp @@ -27,7 +27,7 @@ ControlDoublePrivate::ControlDoublePrivate() ControlDoublePrivate::ControlDoublePrivate(ConfigKey key, ControlObject* pCreatorCO, bool bIgnoreNops, bool bTrack, - bool bPersist) + double value, bool bPersist) : m_key(key), m_bPersistInConfiguration(bPersist), m_bIgnoreNops(bIgnoreNops), @@ -38,11 +38,11 @@ ControlDoublePrivate::ControlDoublePrivate(ConfigKey key, Stat::SAMPLE_VARIANCE | Stat::MIN | Stat::MAX), m_confirmRequired(false), m_pCreatorCO(pCreatorCO) { - initialize(); + initialize(value); } -void ControlDoublePrivate::initialize() { - double value = 0; +void ControlDoublePrivate::initialize(double value) { + m_defaultValue.setValue(value); if (m_bPersistInConfiguration) { ConfigObject* pConfig = ControlDoublePrivate::s_pUserConfig; if (pConfig != NULL) { @@ -50,7 +50,6 @@ void ControlDoublePrivate::initialize() { value = pConfig->getValueString(m_key).toDouble(); } } - m_defaultValue.setValue(0); m_value.setValue(value); //qDebug() << "Creating:" << m_trackKey << "at" << &m_value << sizeof(m_value); @@ -101,7 +100,7 @@ void ControlDoublePrivate::insertAlias(const ConfigKey& alias, const ConfigKey& // static QSharedPointer ControlDoublePrivate::getControl( const ConfigKey& key, bool warn, ControlObject* pCreatorCO, - bool bIgnoreNops, bool bTrack, bool bPersist) { + bool bIgnoreNops, bool bTrack, double value, bool bPersist) { if (key.isNull()) { if (warn) { qWarning() << "ControlDoublePrivate::getControl returning NULL" @@ -130,7 +129,7 @@ QSharedPointer ControlDoublePrivate::getControl( if (pCreatorCO) { pControl = QSharedPointer( new ControlDoublePrivate(key, pCreatorCO, bIgnoreNops, - bTrack, bPersist)); + bTrack, value, bPersist)); locker.relock(); //qDebug() << "ControlDoublePrivate::s_qCOHash.insert(" << key.group << "," << key.item << ")"; s_qCOHash.insert(key, pControl); diff --git a/src/control/control.h b/src/control/control.h index c7e849373dc..eb02fc4d96c 100644 --- a/src/control/control.h +++ b/src/control/control.h @@ -36,7 +36,7 @@ class ControlDoublePrivate : public QObject { static QSharedPointer getControl( const ConfigKey& key, bool warn = true, ControlObject* pCreatorCO = NULL, bool bIgnoreNops = true, bool bTrack = false, - bool bPersist = false); + double value = 0.0, bool bPersist = false); // Adds all ControlDoublePrivate that currently exist to pControlList static void getControls(QList >* pControlsList); @@ -126,8 +126,8 @@ class ControlDoublePrivate : public QObject { private: ControlDoublePrivate(ConfigKey key, ControlObject* pCreatorCO, - bool bIgnoreNops, bool bTrack, bool bPersist); - void initialize(); + bool bIgnoreNops, bool bTrack, double value, bool bPersist); + void initialize(double value); void setInner(double value, QObject* pSender); ConfigKey m_key; diff --git a/src/controlobject.cpp b/src/controlobject.cpp index 36f48529cd5..0c3103a8c49 100644 --- a/src/controlobject.cpp +++ b/src/controlobject.cpp @@ -29,8 +29,8 @@ ControlObject::ControlObject() { } ControlObject::ControlObject(ConfigKey key, bool bIgnoreNops, bool bTrack, - bool bPersist) { - initialize(key, bIgnoreNops, bTrack, bPersist); + double value, bool bPersist) { + initialize(key, bIgnoreNops, bTrack, value, bPersist); } ControlObject::~ControlObject() { @@ -40,14 +40,14 @@ ControlObject::~ControlObject() { } void ControlObject::initialize(ConfigKey key, bool bIgnoreNops, bool bTrack, - bool bPersist) { + double value, bool bPersist) { m_key = key; // Don't bother looking up the control if key is NULL. Prevents log spew. if (!m_key.isNull()) { m_pControl = ControlDoublePrivate::getControl(m_key, true, this, bIgnoreNops, bTrack, - bPersist); + value, bPersist); } // getControl can fail and return a NULL control even with the create flag. diff --git a/src/controlobject.h b/src/controlobject.h index 4cb536653ac..cb82f2d8c83 100644 --- a/src/controlobject.h +++ b/src/controlobject.h @@ -36,7 +36,7 @@ class ControlObject : public QObject { // bPersist: Store value on exit, load on startup. ControlObject(ConfigKey key, bool bIgnoreNops=true, bool bTrack=false, - bool bPersist=false); + double value = 0.0, bool bPersist=false); virtual ~ControlObject(); // Returns a pointer to the ControlObject matching the given ConfigKey @@ -164,7 +164,7 @@ class ControlObject : public QObject { private: void initialize(ConfigKey key, bool bIgnoreNops, bool bTrack, - bool bPersist); + double value, bool bPersist); inline bool ignoreNops() const { return m_pControl ? m_pControl->ignoreNops() : true; } diff --git a/src/controlpushbutton.cpp b/src/controlpushbutton.cpp index e0a9102bcc4..edd8fe2caea 100644 --- a/src/controlpushbutton.cpp +++ b/src/controlpushbutton.cpp @@ -21,8 +21,8 @@ Purpose: Creates a new simulated latching push-button. Input: key - Key for the configuration file -------- ------------------------------------------------------ */ -ControlPushButton::ControlPushButton(ConfigKey key, bool bPersist) - : ControlObject(key, false, false, bPersist), +ControlPushButton::ControlPushButton(ConfigKey key, double value, bool bPersist) + : ControlObject(key, false, false, value, bPersist), m_buttonMode(PUSH), m_iNoStates(2) { if (m_pControl) { diff --git a/src/controlpushbutton.h b/src/controlpushbutton.h index ecfe841221b..2eb4278262d 100644 --- a/src/controlpushbutton.h +++ b/src/controlpushbutton.h @@ -53,7 +53,7 @@ class ControlPushButton : public ControlObject { } } - ControlPushButton(ConfigKey key, bool bPersist=false); + ControlPushButton(ConfigKey key, double value = 0.0, bool bPersist = false); virtual ~ControlPushButton(); inline ButtonMode getButtonMode() const { diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 0b3a665be55..998d30e5e64 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -83,7 +83,7 @@ QMutex LegacySkinParser::s_safeStringMutex; static bool sDebug = false; -ControlObject* controlFromConfigKey(ConfigKey key, bool bPersist, +ControlObject* controlFromConfigKey(ConfigKey key, double value, bool bPersist, bool* created) { ControlObject* pControl = ControlObject::getControl(key); @@ -100,7 +100,7 @@ ControlObject* controlFromConfigKey(ConfigKey key, bool bPersist, << "Creating it."; // Since the usual behavior here is to create a skin-defined push // button, actually make it a push button and set it to toggle. - ControlPushButton* controlButton = new ControlPushButton(key, bPersist); + ControlPushButton* controlButton = new ControlPushButton(key, value, bPersist); controlButton->setButtonMode(ControlPushButton::TOGGLE); if (created) { *created = true; @@ -121,7 +121,7 @@ ControlObject* LegacySkinParser::controlFromConfigNode(QDomElement element, bool bPersist = m_pContext->selectAttributeBool(keyElement, "persist", false); - return controlFromConfigKey(key, bPersist, created); + return controlFromConfigKey(key, 0.0, bPersist, created); } LegacySkinParser::LegacySkinParser(ConfigObject* pConfig, @@ -326,14 +326,8 @@ QWidget* LegacySkinParser::parseSkin(QString skinPath, QWidget* pParent) { // If there is no existing value for this CO in the skin, // update the config with the specified value. If the attribute // is set to persist, the value will be read when the control is created. - // TODO: This is a hack, but right now it's the cleanest way to - // get a CO with a specified initial value. We should have a better - // mechanism to provide initial default values for COs. - if (attribute.persist() && - m_pConfig->getValueString(configKey).isEmpty()) { - m_pConfig->set(configKey, ConfigValue(QString::number(value))); - } ControlObject* pControl = controlFromConfigKey(configKey, + value, attribute.persist(), &created); if (created) { @@ -621,7 +615,7 @@ QWidget* LegacySkinParser::parseWidgetStack(QDomElement node) { ConfigKey configKey = ConfigKey::parseCommaSeparated(currentpage_co); QString persist_co = node.attribute("persist"); bool persist = m_pContext->selectAttributeBool(node, "persist", false); - pCurrentPageControl = controlFromConfigKey(configKey, persist, + pCurrentPageControl = controlFromConfigKey(configKey, 0.0, persist, &createdCurrentPage); } @@ -683,7 +677,7 @@ QWidget* LegacySkinParser::parseWidgetStack(QDomElement node) { if (trigger_configkey.length() > 0) { ConfigKey configKey = ConfigKey::parseCommaSeparated(trigger_configkey); bool created; - pControl = controlFromConfigKey(configKey, false, &created); + pControl = controlFromConfigKey(configKey, 0.0, false, &created); if (created) { // If we created the control, parent it to the child widget so // it doesn't leak. From 4f4a2d66bbd47bc433ccc7b0afa56314128c5fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 22 Apr 2015 01:23:27 +0200 Subject: [PATCH 2/5] Remove redundant value set. --- src/skin/legacyskinparser.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 998d30e5e64..2d1a87172d1 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -332,11 +332,6 @@ QWidget* LegacySkinParser::parseSkin(QString skinPath, QWidget* pParent) { &created); if (created) { created_attributes.append(pControl); - if (!attribute.persist()) { - // Only set the value if the control was just created and the - // value wasn't set up through the persist logic. - pControl->set(value); - } } } else { SKIN_WARNING(skinDocument, *m_pContext) From 4c439631af0b202af7050cdf5b26550b0e9d56bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 22 Apr 2015 01:27:28 +0200 Subject: [PATCH 3/5] Pipe default value to ControlPotmeter and set value in some other places --- src/controlpotmeter.cpp | 3 ++- src/controlpotmeter.h | 1 + src/engine/enginedelay.cpp | 2 +- src/engine/enginemaster.cpp | 8 ++++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/controlpotmeter.cpp b/src/controlpotmeter.cpp index f64278ce12f..2e479826939 100644 --- a/src/controlpotmeter.cpp +++ b/src/controlpotmeter.cpp @@ -23,8 +23,9 @@ ControlPotmeter::ControlPotmeter(ConfigKey key, double dMinValue, double dMaxVal bool allowOutOfBounds, bool bIgnoreNops, bool bTrack, + double value, bool bPersist) - : ControlObject(key, bIgnoreNops, bTrack, bPersist), + : ControlObject(key, bIgnoreNops, bTrack, value, bPersist), m_controls(key) { setRange(dMinValue, dMaxValue, allowOutOfBounds); double default_value = dMinValue + 0.5 * (dMaxValue - dMinValue); diff --git a/src/controlpotmeter.h b/src/controlpotmeter.h index 9ea3577f788..224a6b61345 100644 --- a/src/controlpotmeter.h +++ b/src/controlpotmeter.h @@ -77,6 +77,7 @@ class ControlPotmeter : public ControlObject { bool allowOutOfBounds = false, bool bIgnoreNops = true, bool bTrack = false, + double value = 0.0, bool bPersist = false); virtual ~ControlPotmeter(); diff --git a/src/engine/enginedelay.cpp b/src/engine/enginedelay.cpp index 772a2b79ba4..d3e8f271ebb 100644 --- a/src/engine/enginedelay.cpp +++ b/src/engine/enginedelay.cpp @@ -28,7 +28,7 @@ EngineDelay::EngineDelay(const char* group, ConfigKey delayControl) m_iDelay(0) { m_pDelayBuffer = SampleUtil::alloc(kiMaxDelay); SampleUtil::clear(m_pDelayBuffer, kiMaxDelay); - m_pDelayPot = new ControlPotmeter(delayControl, 0, kdMaxDelayPot, false, true, false, true); + m_pDelayPot = new ControlPotmeter(delayControl, 0, kdMaxDelayPot, false, true, false, 0.0, true); m_pDelayPot->setDefaultValue(0); connect(m_pDelayPot, SIGNAL(valueChanged(double)), this, SLOT(slotDelayChanged()), Qt::DirectConnection); diff --git a/src/engine/enginemaster.cpp b/src/engine/enginemaster.cpp index daaf8b714da..c513299d9cc 100644 --- a/src/engine/enginemaster.cpp +++ b/src/engine/enginemaster.cpp @@ -168,16 +168,16 @@ EngineMaster::EngineMaster(ConfigObject* _config, m_pXFaderReverse->setButtonMode(ControlPushButton::TOGGLE); m_pKeylockEngine = new ControlObject(ConfigKey(group, "keylock_engine"), - true, false, true); + true, false, 0.0, true); m_pKeylockEngine->set(_config->getValueString( ConfigKey(group, "keylock_engine")).toDouble()); m_pMasterEnabled = new ControlObject(ConfigKey(group, "enabled"), - true, false, true); // persist = true + true, false, 0.0, true); // persist = true m_pMasterMonoMixdown = new ControlObject(ConfigKey(group, "mono_mixdown"), - true, false, true); // persist = true + true, false, 0.0, true); // persist = true m_pMasterTalkoverMix = new ControlObject(ConfigKey(group, "talkover_mix"), - true, false, true); // persist = true + true, false, 0.0, true); // persist = true m_pHeadphoneEnabled = new ControlObject(ConfigKey(group, "headEnabled")); From 24dab043ba9bd9512da3eb7c6fa4882aa705b008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 22 Apr 2015 22:06:08 +0200 Subject: [PATCH 4/5] Rename value to defaultValue --- src/control/control.cpp | 17 +++++++++-------- src/control/control.h | 7 ++++--- src/controlobject.cpp | 8 ++++---- src/controlobject.h | 4 ++-- src/controlpotmeter.cpp | 4 ++-- src/controlpotmeter.h | 2 +- src/controlpushbutton.cpp | 4 ++-- src/controlpushbutton.h | 3 ++- src/skin/legacyskinparser.cpp | 4 ++-- 9 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/control/control.cpp b/src/control/control.cpp index 25ae9c08cf2..3de7c295b09 100644 --- a/src/control/control.cpp +++ b/src/control/control.cpp @@ -27,7 +27,7 @@ ControlDoublePrivate::ControlDoublePrivate() ControlDoublePrivate::ControlDoublePrivate(ConfigKey key, ControlObject* pCreatorCO, bool bIgnoreNops, bool bTrack, - double value, bool bPersist) + double defaultValue, bool bPersist) : m_key(key), m_bPersistInConfiguration(bPersist), m_bIgnoreNops(bIgnoreNops), @@ -38,19 +38,20 @@ ControlDoublePrivate::ControlDoublePrivate(ConfigKey key, Stat::SAMPLE_VARIANCE | Stat::MIN | Stat::MAX), m_confirmRequired(false), m_pCreatorCO(pCreatorCO) { - initialize(value); + initialize(defaultValue); } -void ControlDoublePrivate::initialize(double value) { - m_defaultValue.setValue(value); +void ControlDoublePrivate::initialize(double defaultValue) { + m_defaultValue.setValue(defaultValue); + double initalValue = defaultValue; if (m_bPersistInConfiguration) { ConfigObject* pConfig = ControlDoublePrivate::s_pUserConfig; if (pConfig != NULL) { // Assume toDouble() returns 0 if conversion fails. - value = pConfig->getValueString(m_key).toDouble(); + initalValue = pConfig->getValueString(m_key).toDouble(); } } - m_value.setValue(value); + m_value.setValue(initalValue); //qDebug() << "Creating:" << m_trackKey << "at" << &m_value << sizeof(m_value); @@ -100,7 +101,7 @@ void ControlDoublePrivate::insertAlias(const ConfigKey& alias, const ConfigKey& // static QSharedPointer ControlDoublePrivate::getControl( const ConfigKey& key, bool warn, ControlObject* pCreatorCO, - bool bIgnoreNops, bool bTrack, double value, bool bPersist) { + bool bIgnoreNops, bool bTrack, double defaulValue, bool bPersist) { if (key.isNull()) { if (warn) { qWarning() << "ControlDoublePrivate::getControl returning NULL" @@ -129,7 +130,7 @@ QSharedPointer ControlDoublePrivate::getControl( if (pCreatorCO) { pControl = QSharedPointer( new ControlDoublePrivate(key, pCreatorCO, bIgnoreNops, - bTrack, value, bPersist)); + bTrack, defaulValue, bPersist)); locker.relock(); //qDebug() << "ControlDoublePrivate::s_qCOHash.insert(" << key.group << "," << key.item << ")"; s_qCOHash.insert(key, pControl); diff --git a/src/control/control.h b/src/control/control.h index eb02fc4d96c..69a673d252c 100644 --- a/src/control/control.h +++ b/src/control/control.h @@ -36,7 +36,7 @@ class ControlDoublePrivate : public QObject { static QSharedPointer getControl( const ConfigKey& key, bool warn = true, ControlObject* pCreatorCO = NULL, bool bIgnoreNops = true, bool bTrack = false, - double value = 0.0, bool bPersist = false); + double defaultValue = 0.0, bool bPersist = false); // Adds all ControlDoublePrivate that currently exist to pControlList static void getControls(QList >* pControlsList); @@ -126,8 +126,9 @@ class ControlDoublePrivate : public QObject { private: ControlDoublePrivate(ConfigKey key, ControlObject* pCreatorCO, - bool bIgnoreNops, bool bTrack, double value, bool bPersist); - void initialize(double value); + bool bIgnoreNops, bool bTrack, double defaultValue, + bool bPersist); + void initialize(double defaultValue); void setInner(double value, QObject* pSender); ConfigKey m_key; diff --git a/src/controlobject.cpp b/src/controlobject.cpp index 0c3103a8c49..23edbec5c0b 100644 --- a/src/controlobject.cpp +++ b/src/controlobject.cpp @@ -29,8 +29,8 @@ ControlObject::ControlObject() { } ControlObject::ControlObject(ConfigKey key, bool bIgnoreNops, bool bTrack, - double value, bool bPersist) { - initialize(key, bIgnoreNops, bTrack, value, bPersist); + double defaultValue, bool bPersist) { + initialize(key, bIgnoreNops, bTrack, defaultValue, bPersist); } ControlObject::~ControlObject() { @@ -40,14 +40,14 @@ ControlObject::~ControlObject() { } void ControlObject::initialize(ConfigKey key, bool bIgnoreNops, bool bTrack, - double value, bool bPersist) { + double defaultValue, bool bPersist) { m_key = key; // Don't bother looking up the control if key is NULL. Prevents log spew. if (!m_key.isNull()) { m_pControl = ControlDoublePrivate::getControl(m_key, true, this, bIgnoreNops, bTrack, - value, bPersist); + defaultValue, bPersist); } // getControl can fail and return a NULL control even with the create flag. diff --git a/src/controlobject.h b/src/controlobject.h index cb82f2d8c83..2d9f5cf8422 100644 --- a/src/controlobject.h +++ b/src/controlobject.h @@ -36,7 +36,7 @@ class ControlObject : public QObject { // bPersist: Store value on exit, load on startup. ControlObject(ConfigKey key, bool bIgnoreNops=true, bool bTrack=false, - double value = 0.0, bool bPersist=false); + double defaultValue = 0.0, bool bPersist=false); virtual ~ControlObject(); // Returns a pointer to the ControlObject matching the given ConfigKey @@ -164,7 +164,7 @@ class ControlObject : public QObject { private: void initialize(ConfigKey key, bool bIgnoreNops, bool bTrack, - double value, bool bPersist); + double defaultValue, bool bPersist); inline bool ignoreNops() const { return m_pControl ? m_pControl->ignoreNops() : true; } diff --git a/src/controlpotmeter.cpp b/src/controlpotmeter.cpp index 2e479826939..0bb0f0498cb 100644 --- a/src/controlpotmeter.cpp +++ b/src/controlpotmeter.cpp @@ -23,9 +23,9 @@ ControlPotmeter::ControlPotmeter(ConfigKey key, double dMinValue, double dMaxVal bool allowOutOfBounds, bool bIgnoreNops, bool bTrack, - double value, + double defaultValue, bool bPersist) - : ControlObject(key, bIgnoreNops, bTrack, value, bPersist), + : ControlObject(key, bIgnoreNops, bTrack, defaultValue, bPersist), m_controls(key) { setRange(dMinValue, dMaxValue, allowOutOfBounds); double default_value = dMinValue + 0.5 * (dMaxValue - dMinValue); diff --git a/src/controlpotmeter.h b/src/controlpotmeter.h index 224a6b61345..80f2fcc9d54 100644 --- a/src/controlpotmeter.h +++ b/src/controlpotmeter.h @@ -77,7 +77,7 @@ class ControlPotmeter : public ControlObject { bool allowOutOfBounds = false, bool bIgnoreNops = true, bool bTrack = false, - double value = 0.0, + double defaultValue = 0.0, bool bPersist = false); virtual ~ControlPotmeter(); diff --git a/src/controlpushbutton.cpp b/src/controlpushbutton.cpp index edd8fe2caea..f88813c869a 100644 --- a/src/controlpushbutton.cpp +++ b/src/controlpushbutton.cpp @@ -21,8 +21,8 @@ Purpose: Creates a new simulated latching push-button. Input: key - Key for the configuration file -------- ------------------------------------------------------ */ -ControlPushButton::ControlPushButton(ConfigKey key, double value, bool bPersist) - : ControlObject(key, false, false, value, bPersist), +ControlPushButton::ControlPushButton(ConfigKey key, double defaultValue, bool bPersist) + : ControlObject(key, false, false, defaultValue, bPersist), m_buttonMode(PUSH), m_iNoStates(2) { if (m_pControl) { diff --git a/src/controlpushbutton.h b/src/controlpushbutton.h index 2eb4278262d..8a13b97e8fb 100644 --- a/src/controlpushbutton.h +++ b/src/controlpushbutton.h @@ -53,7 +53,8 @@ class ControlPushButton : public ControlObject { } } - ControlPushButton(ConfigKey key, double value = 0.0, bool bPersist = false); + ControlPushButton(ConfigKey key, double defaulValue = 0.0, + bool bPersist = false); virtual ~ControlPushButton(); inline ButtonMode getButtonMode() const { diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 2d1a87172d1..0c3ebec4f61 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -83,7 +83,7 @@ QMutex LegacySkinParser::s_safeStringMutex; static bool sDebug = false; -ControlObject* controlFromConfigKey(ConfigKey key, double value, bool bPersist, +ControlObject* controlFromConfigKey(ConfigKey key, double defaulValue, bool bPersist, bool* created) { ControlObject* pControl = ControlObject::getControl(key); @@ -100,7 +100,7 @@ ControlObject* controlFromConfigKey(ConfigKey key, double value, bool bPersist, << "Creating it."; // Since the usual behavior here is to create a skin-defined push // button, actually make it a push button and set it to toggle. - ControlPushButton* controlButton = new ControlPushButton(key, value, bPersist); + ControlPushButton* controlButton = new ControlPushButton(key, defaulValue, bPersist); controlButton->setButtonMode(ControlPushButton::TOGGLE); if (created) { *created = true; From 6c6950296240f788e93895b3ad2158039f9e0e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 22 Apr 2015 22:51:45 +0200 Subject: [PATCH 5/5] Added some comments about the new parameter defaultValue --- src/control/control.h | 2 ++ src/controlobject.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/control/control.h b/src/control/control.h index 69a673d252c..659f72a9f4f 100644 --- a/src/control/control.h +++ b/src/control/control.h @@ -125,6 +125,8 @@ class ControlDoublePrivate : public QObject { void valueChangeRequest(double value); private: + // The defaultValue is adopted as initial value as well + // except it is a persistent CO with a saved value in place ControlDoublePrivate(ConfigKey key, ControlObject* pCreatorCO, bool bIgnoreNops, bool bTrack, double defaultValue, bool bPersist); diff --git a/src/controlobject.h b/src/controlobject.h index 2d9f5cf8422..b605c59cc79 100644 --- a/src/controlobject.h +++ b/src/controlobject.h @@ -33,6 +33,8 @@ class ControlObject : public QObject { // bIgnoreNops: Don't emit a signal if the CO is set to its current value. // bTrack: Record statistics about this control. + // defaultValue: is adopted as initial value as well + // except it is a persistent CO with a saved value in place // bPersist: Store value on exit, load on startup. ControlObject(ConfigKey key, bool bIgnoreNops=true, bool bTrack=false,