Skip to content

Commit

Permalink
Create a ControlObject toggle function
Browse files Browse the repository at this point in the history
  • Loading branch information
xeruf committed Jul 6, 2020
1 parent ce0821d commit 56e3e93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/control/controlobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,15 @@ void ControlObject::setParameterFrom(double v, QObject* pSender) {
void ControlObject::set(const ConfigKey& key, const double& value) {
QSharedPointer<ControlDoublePrivate> pCop = ControlDoublePrivate::getControl(key);
if (pCop) {
pCop->set(value, NULL);
pCop->set(value, nullptr);
}
}

void ControlObject::toggle(const ConfigKey& key) {
QSharedPointer<ControlDoublePrivate> pCop = ControlDoublePrivate::getControl(key);
if (pCop) {
pCop->set(1, nullptr);
pCop->set(0, nullptr);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/control/controlobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class ControlObject : public QObject {
// Instantly sets the value of the ControlObject
static void set(const ConfigKey& key, const double& value);

// Instantly sets the value of the ControlObject to 1 and then to 0
static void toggle(const ConfigKey& key);

// Sets the default value
inline void reset() {
if (m_pControl) {
Expand Down

0 comments on commit 56e3e93

Please sign in to comment.