mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
Project dirty state manager -> presets dirty state
This commit is contained in:
parent
5d4b7c03b6
commit
edbb1d0f69
11 changed files with 206 additions and 18 deletions
|
@ -346,6 +346,11 @@ public:
|
|||
Preset& get_edited_preset() { return m_edited_preset; }
|
||||
const Preset& get_edited_preset() const { return m_edited_preset; }
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
// Return the last saved preset.
|
||||
const Preset& get_saved_preset() const { return m_saved_preset; }
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
// Return vendor of the first parent profile, for which the vendor is defined, or null if such profile does not exist.
|
||||
PresetWithVendorProfile get_preset_with_vendor_profile(const Preset &preset) const;
|
||||
PresetWithVendorProfile get_edited_preset_with_vendor_profile() const { return this->get_preset_with_vendor_profile(this->get_edited_preset()); }
|
||||
|
@ -365,8 +370,16 @@ public:
|
|||
// Return a preset by an index. If the preset is active, a temporary copy is returned.
|
||||
Preset& preset(size_t idx) { return (idx == m_idx_selected) ? m_edited_preset : m_presets[idx]; }
|
||||
const Preset& preset(size_t idx) const { return const_cast<PresetCollection*>(this)->preset(idx); }
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
void discard_current_changes() {
|
||||
m_presets[m_idx_selected].reset_dirty();
|
||||
m_edited_preset = m_presets[m_idx_selected];
|
||||
update_saved_preset_from_current_preset();
|
||||
}
|
||||
#else
|
||||
void discard_current_changes() { m_presets[m_idx_selected].reset_dirty(); m_edited_preset = m_presets[m_idx_selected]; }
|
||||
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
// 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* find_preset(const std::string &name, bool first_visible_if_not_found = false);
|
||||
|
@ -440,6 +453,16 @@ public:
|
|||
std::vector<std::string> current_different_from_parent_options(const bool deep_compare = false) const
|
||||
{ return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent(), deep_compare); }
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
// Compare the content of get_saved_preset() with get_edited_preset() configs, return true if they differ.
|
||||
bool saved_is_dirty() const { return !this->saved_dirty_options().empty(); }
|
||||
// Compare the content of get_saved_preset() with get_edited_preset() configs, return the list of keys where they differ.
|
||||
std::vector<std::string> saved_dirty_options(const bool deep_compare = false) const
|
||||
{ return dirty_options(&this->get_edited_preset(), &this->get_saved_preset(), deep_compare); }
|
||||
// Copy edited preset into saved preset.
|
||||
void update_saved_preset_from_current_preset() { m_saved_preset = m_edited_preset; }
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
// Return a sorted list of system preset names.
|
||||
// Used for validating the "inherits" flag when importing user's config bundles.
|
||||
// Returns names of all system presets including the former names of these presets.
|
||||
|
@ -527,6 +550,11 @@ private:
|
|||
std::map<std::string, std::string> m_map_system_profile_renamed;
|
||||
// Initially this preset contains a copy of the selected preset. Later on, this copy may be modified by the user.
|
||||
Preset m_edited_preset;
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
// Contains a copy of the last saved selected preset.
|
||||
Preset m_saved_preset;
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
// Selected preset.
|
||||
size_t m_idx_selected;
|
||||
// Is the "- default -" preset suppressed?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue