Preset: New flag "respect_active_preset" is added to preset(name).

Return values, when preset i sactive:
 - edited_preset,   when respect_active_preset==true
 - selected_preset, when respect_active_preset==false

+ UnsavedChangedDialog: Implementation for FR #7393 - "Switching Presets: Unsaved Changes" table

+ DiffDialog: Implemented possibility to compare selected and edited presets
This commit is contained in:
YuSanka 2022-09-07 15:45:00 +02:00
parent 0146e8d863
commit 8cc1a58f61
6 changed files with 159 additions and 77 deletions

View file

@ -1055,12 +1055,12 @@ const std::string& PresetCollection::get_suffix_modified() {
// Return a preset by its name. If the preset is active, a temporary copy is returned.
// If a preset is not found by its name, null is returned.
Preset* PresetCollection::find_preset(const std::string &name, bool first_visible_if_not_found)
Preset* PresetCollection::find_preset(const std::string &name, bool first_visible_if_not_found, bool respect_active_preset /*= true*/)
{
Preset key(m_type, name, false);
auto it = this->find_preset_internal(name);
// Ensure that a temporary copy is returned if the preset found is currently selected.
return (it != m_presets.end() && it->name == key.name) ? &this->preset(it - m_presets.begin()) :
return (it != m_presets.end() && it->name == key.name) ? &this->preset(it - m_presets.begin(), respect_active_preset) :
first_visible_if_not_found ? &this->first_visible() : nullptr;
}