Skip to content

Commit

Permalink
Merge pull request #4431 from daschuer/effects_refactoring_loaded_chain
Browse files Browse the repository at this point in the history
Effects refactoring: loaded chain
  • Loading branch information
Be-ing authored Oct 18, 2021
2 parents 4f1e771 + 9cb902e commit 21945c3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/effects/chains/quickeffectchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ QuickEffectChain::QuickEffectChain(const QString& group,
&EffectChainPresetManager::effectChainPresetListUpdated,
this,
&QuickEffectChain::slotPresetListUpdated);
m_pControlNumPresetsAvailable->forceSet(m_pChainPresetManager->numQuickEffectPresets());
m_pControlNumChainPresets->forceSet(m_pChainPresetManager->numQuickEffectPresets());
connect(m_pChainPresetManager.data(),
&EffectChainPresetManager::quickEffectChainPresetListUpdated,
this,
Expand Down
52 changes: 20 additions & 32 deletions src/effects/effectchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,15 @@ EffectChain::EffectChain(const QString& group,
ConfigKey(m_group, "num_effectslots"));
m_pControlNumEffectSlots->setReadOnly();

m_pControlNumPresetsAvailable = std::make_unique<ControlObject>(
ConfigKey(m_group, "num_presetsavailable"));
m_pControlNumPresetsAvailable->set(m_pChainPresetManager->numPresets());
m_pControlNumPresetsAvailable->setReadOnly();
m_pControlNumChainPresets = std::make_unique<ControlObject>(
ConfigKey(m_group, "num_chain_presets"));
m_pControlNumChainPresets->set(m_pChainPresetManager->numPresets());
m_pControlNumChainPresets->setReadOnly();
connect(m_pChainPresetManager.data(),
&EffectChainPresetManager::effectChainPresetListUpdated,
this,
&EffectChain::slotPresetListUpdated);

m_pControlChainLoaded =
std::make_unique<ControlObject>(ConfigKey(m_group, "loaded"));
m_pControlChainLoaded->setReadOnly();
if (group != QString()) {
m_pControlChainLoaded->forceSet(1.0);
}

m_pControlChainEnabled =
std::make_unique<ControlPushButton>(ConfigKey(m_group, "enabled"));
m_pControlChainEnabled->setButtonMode(ControlPushButton::POWERWINDOW);
Expand Down Expand Up @@ -101,24 +94,25 @@ EffectChain::EffectChain(const QString& group,
this,
&EffectChain::sendParameterUpdate);

m_pControlLoadedPreset = std::make_unique<ControlObject>(
ConfigKey(m_group, "loaded_preset"), false);
m_pControlLoadedPreset->connectValueChangeRequest(
this, &EffectChain::slotControlLoadedChainPresetRequest);
m_pControlLoadedChainPreset = std::make_unique<ControlObject>(
ConfigKey(m_group, "loaded_chain_preset"), false);
m_pControlLoadedChainPreset->connectValueChangeRequest(
this,
&EffectChain::slotControlLoadedChainPresetRequest);

m_pControlChainNextPreset = std::make_unique<ControlPushButton>(
m_pControlNextChainPreset = std::make_unique<ControlPushButton>(
ConfigKey(m_group, "next_chain"));
connect(m_pControlChainNextPreset.get(),
connect(m_pControlNextChainPreset.get(),
&ControlObject::valueChanged,
this,
&EffectChain::slotControlChainNextPreset);
&EffectChain::slotControlNextChainPreset);

m_pControlChainPrevPreset = std::make_unique<ControlPushButton>(
m_pControlPrevChainPreset = std::make_unique<ControlPushButton>(
ConfigKey(m_group, "prev_chain"));
connect(m_pControlChainPrevPreset.get(),
connect(m_pControlPrevChainPreset.get(),
&ControlObject::valueChanged,
this,
&EffectChain::slotControlChainPrevPreset);
&EffectChain::slotControlPrevChainPreset);

// Ignoring no-ops is important since this is for +/- tickers.
m_pControlChainSelector = std::make_unique<ControlEncoder>(
Expand Down Expand Up @@ -205,11 +199,6 @@ void EffectChain::loadChainPreset(EffectChainPresetPointer pPreset) {
int effectSlotIndex = 0;
for (const auto& pEffectPreset : pPreset->effectPresets()) {
EffectSlotPointer pEffectSlot = m_effectSlots.at(effectSlotIndex);
if (pEffectPreset->isEmpty()) {
pEffectSlot->loadEffectFromPreset(nullptr);
effectSlotIndex++;
continue;
}
pEffectSlot->loadEffectFromPreset(pEffectPreset);
effectSlotIndex++;
}
Expand All @@ -221,7 +210,6 @@ void EffectChain::loadChainPreset(EffectChainPresetPointer pPreset) {
emit presetNameChanged(m_presetName);

setControlLoadedPresetIndex(presetIndex());
m_pControlLoadedPreset->setAndConfirm(presetIndex() + 1);
}

void EffectChain::sendParameterUpdate() {
Expand Down Expand Up @@ -332,7 +320,7 @@ void EffectChain::slotControlChainSelector(double value) {
int index = presetIndex();
if (value > 0) {
index++;
} else {
} else if (value < 0) {
index--;
}
loadChainPreset(presetAtIndex(index));
Expand All @@ -350,16 +338,16 @@ void EffectChain::slotControlLoadedChainPresetRequest(double value) {

void EffectChain::setControlLoadedPresetIndex(uint index) {
// add 1 to make the ControlObject 1-indexed like other ControlObjects
m_pControlLoadedPreset->setAndConfirm(index + 1);
m_pControlLoadedChainPreset->setAndConfirm(index + 1);
}

void EffectChain::slotControlChainNextPreset(double value) {
void EffectChain::slotControlNextChainPreset(double value) {
if (value > 0) {
loadChainPreset(presetAtIndex(presetIndex() + 1));
}
}

void EffectChain::slotControlChainPrevPreset(double value) {
void EffectChain::slotControlPrevChainPreset(double value) {
if (value > 0) {
loadChainPreset(presetAtIndex(presetIndex() - 1));
}
Expand All @@ -376,7 +364,7 @@ void EffectChain::slotChannelStatusChanged(

void EffectChain::slotPresetListUpdated() {
setControlLoadedPresetIndex(presetIndex());
m_pControlNumPresetsAvailable->forceSet(numPresets());
m_pControlNumChainPresets->forceSet(numPresets());
}

void EffectChain::enableForInputChannel(const ChannelHandleAndGroup& handleGroup) {
Expand Down
13 changes: 6 additions & 7 deletions src/effects/effectchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class EffectChain : public QObject {
EffectsMessengerPointer m_pMessenger;
std::unique_ptr<ControlObject> m_pControlChainMix;
std::unique_ptr<ControlObject> m_pControlChainSuperParameter;
std::unique_ptr<ControlObject> m_pControlNumPresetsAvailable;
std::unique_ptr<ControlObject> m_pControlNumChainPresets;
QList<EffectSlotPointer> m_effectSlots;

protected slots:
Expand All @@ -117,8 +117,8 @@ class EffectChain : public QObject {
private slots:
void slotControlLoadedChainPresetRequest(double value);
void slotControlChainSelector(double value);
void slotControlChainNextPreset(double value);
void slotControlChainPrevPreset(double value);
void slotControlNextChainPreset(double value);
void slotControlPrevChainPreset(double value);
void slotChannelStatusChanged(double value, const ChannelHandleAndGroup& handleGroup);

private:
Expand All @@ -133,13 +133,12 @@ class EffectChain : public QObject {

std::unique_ptr<ControlPushButton> m_pControlClear;
std::unique_ptr<ControlObject> m_pControlNumEffectSlots;
std::unique_ptr<ControlObject> m_pControlChainLoaded;
std::unique_ptr<ControlPushButton> m_pControlChainEnabled;
std::unique_ptr<ControlPushButton> m_pControlChainMixMode;
std::unique_ptr<ControlObject> m_pControlLoadedPreset;
std::unique_ptr<ControlObject> m_pControlLoadedChainPreset;
std::unique_ptr<ControlEncoder> m_pControlChainSelector;
std::unique_ptr<ControlPushButton> m_pControlChainNextPreset;
std::unique_ptr<ControlPushButton> m_pControlChainPrevPreset;
std::unique_ptr<ControlPushButton> m_pControlNextChainPreset;
std::unique_ptr<ControlPushButton> m_pControlPrevChainPreset;

void setControlLoadedPresetIndex(uint index);

Expand Down
2 changes: 1 addition & 1 deletion src/effects/effectslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ EffectParameterSlotBasePointer EffectSlot::getEffectParameterSlot(
}

void EffectSlot::loadEffectFromPreset(const EffectPresetPointer pPreset) {
if (!pPreset) {
if (!pPreset || pPreset->isEmpty()) {
loadEffectInner(nullptr, nullptr, true);
return;
}
Expand Down

0 comments on commit 21945c3

Please sign in to comment.