Skip to content

Commit

Permalink
Merge pull request #4899 from ronso0/effect-chain-select-after-save-a…
Browse files Browse the repository at this point in the history
…s-new

Effect chain: (re)load & select preset after saving with a new name
  • Loading branch information
daschuer authored Aug 21, 2022
2 parents 6aa07cd + 49e301e commit 593e0b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/effects/presets/effectchainpresetmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,14 @@ void EffectChainPresetManager::setQuickEffectPresetOrder(
emit quickEffectChainPresetListUpdated();
}

void EffectChainPresetManager::savePreset(EffectChainPointer pChainSlot) {
void EffectChainPresetManager::savePresetAndReload(EffectChainPointer pChainSlot) {
auto pPreset = EffectChainPresetPointer::create(pChainSlot.data());
savePreset(pPreset);
if (savePreset(pPreset)) {
pChainSlot->loadChainPreset(pPreset);
}
}

void EffectChainPresetManager::savePreset(EffectChainPresetPointer pPreset) {
bool EffectChainPresetManager::savePreset(EffectChainPresetPointer pPreset) {
QString name;
QString errorText;
while (name.isEmpty() || m_effectChainPresets.contains(name)) {
Expand All @@ -381,7 +383,7 @@ void EffectChainPresetManager::savePreset(EffectChainPresetPointer pPreset) {
&okay)
.trimmed();
if (!okay) {
return;
return false;
}

if (name.isEmpty()) {
Expand All @@ -404,6 +406,7 @@ void EffectChainPresetManager::savePreset(EffectChainPresetPointer pPreset) {
emit quickEffectChainPresetListUpdated();

savePresetXml(pPreset);
return true;
}

void EffectChainPresetManager::updatePreset(EffectChainPointer pChainSlot) {
Expand Down
4 changes: 2 additions & 2 deletions src/effects/presets/effectchainpresetmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class EffectChainPresetManager : public QObject {
return m_effectChainPresets.value(name);
}

void savePreset(EffectChainPresetPointer pPreset);
void savePreset(EffectChainPointer pChainSlot);
void savePresetAndReload(EffectChainPointer pChainSlot);
bool savePreset(EffectChainPresetPointer pPreset);
void updatePreset(EffectChainPointer pChainSlot);

EffectsXmlData readEffectsXml(const QDomDocument& doc, const QStringList& deckStrings);
Expand Down
2 changes: 1 addition & 1 deletion src/widget/weffectchainpresetbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void WEffectChainPresetButton::populateMenu() {
});
}
m_pMenu->addAction(tr("Save As New Preset..."), this, [this]() {
m_pChainPresetManager->savePreset(m_pChain);
m_pChainPresetManager->savePresetAndReload(m_pChain);
});

m_pMenu->addSeparator();
Expand Down

0 comments on commit 593e0b1

Please sign in to comment.