Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effects: re-add empty chain preset when resetting to defaults #11705

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 20 additions & 8 deletions src/effects/presets/effectchainpresetmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ EffectChainPresetPointer loadPresetFromFile(const QString& filePath) {
return pEffectChainPreset;
}

EffectChainPresetPointer createEmptyChainPreset() {
EffectManifestPointer pEmptyManifest(new EffectManifest());
pEmptyManifest->setName(kNoEffectString);
// Required for the QuickEffect selector in DlgPrefEQ
pEmptyManifest->setShortName(kNoEffectString);
auto pEmptyChainPreset =
EffectChainPresetPointer(new EffectChainPreset(pEmptyManifest));
pEmptyChainPreset->setReadOnly();

return pEmptyChainPreset;
}

} // anonymous namespace

EffectChainPresetManager::EffectChainPresetManager(UserSettingsPointer pConfig,
Expand Down Expand Up @@ -593,6 +605,11 @@ void EffectChainPresetManager::resetToDefaults() {
generateDefaultQuickEffectPresets();
prependRemainingPresetsToLists();

// Re-add the empty chain preset
EffectChainPresetPointer pEmptyChainPreset = createEmptyChainPreset();
m_effectChainPresets.insert(pEmptyChainPreset->name(), pEmptyChainPreset);
m_quickEffectChainPresetsSorted.prepend(pEmptyChainPreset);

emit effectChainPresetListUpdated();
emit quickEffectChainPresetListUpdated();
}
Expand Down Expand Up @@ -732,14 +749,9 @@ EffectsXmlData EffectChainPresetManager::readEffectsXml(
// It will not be saved to effects/chains nor written to effects.xml
// except as identifier for QuickEffect chains.
// It will not be visible in the effects preferences.
EffectManifestPointer pEmptyChainManifest(new EffectManifest());
pEmptyChainManifest->setName(kNoEffectString);
// Required for the QuickEffect selector in DlgPrefEQ
pEmptyChainManifest->setShortName(kNoEffectString);
auto pEmptyChainPreset =
EffectChainPresetPointer(new EffectChainPreset(pEmptyChainManifest));
pEmptyChainPreset->setReadOnly();

// Note: we also need to take care of this preset in resetToDefaults() and
// setQuickEffectPresetOrder(), both called from DlgPrefEffects
EffectChainPresetPointer pEmptyChainPreset = createEmptyChainPreset();
m_effectChainPresets.insert(pEmptyChainPreset->name(), pEmptyChainPreset);
m_quickEffectChainPresetsSorted.prepend(pEmptyChainPreset);

Expand Down