mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 11:17:51 -06:00
Fixed update of "dirty" profile when the "compatible_printers"
option appears (filter is active) or disappears (no filter active, compatible with any printer).
This commit is contained in:
parent
898c697f13
commit
d47dc5da3e
3 changed files with 16 additions and 11 deletions
|
@ -442,16 +442,9 @@ sub _load_key_value {
|
||||||
$self->{config}->set($opt_key, $value);
|
$self->{config}->set($opt_key, $value);
|
||||||
# Mark the print & filament enabled if they are compatible with the currently selected preset.
|
# Mark the print & filament enabled if they are compatible with the currently selected preset.
|
||||||
if ($opt_key eq 'compatible_printers') {
|
if ($opt_key eq 'compatible_printers') {
|
||||||
my $was_compatible = $self->{presets}->get_edited_preset->compatible;
|
|
||||||
wxTheApp->{preset_bundle}->update_compatible_with_printer(0);
|
wxTheApp->{preset_bundle}->update_compatible_with_printer(0);
|
||||||
if ($was_compatible != $self->{presets}->get_edited_preset->compatible) {
|
|
||||||
# This is certainly not a tab page.
|
|
||||||
# Trigger the on_presets_changed event so that we also update the "compatible" flag at the plater selector.
|
|
||||||
$self->_on_presets_changed;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$self->{presets}->update_dirty_ui($self->{presets_choice});
|
|
||||||
}
|
}
|
||||||
|
$self->{presets}->update_dirty_ui($self->{presets_choice});
|
||||||
$self->_on_presets_changed;
|
$self->_on_presets_changed;
|
||||||
$self->_update;
|
$self->_update;
|
||||||
}
|
}
|
||||||
|
|
|
@ -484,6 +484,18 @@ bool PresetCollection::update_dirty_ui(wxBitmapComboBox *ui)
|
||||||
return was_dirty != is_dirty;
|
return was_dirty != is_dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> PresetCollection::current_dirty_options() const
|
||||||
|
{
|
||||||
|
std::vector<std::string> changed = this->get_selected_preset().config.diff(this->get_edited_preset().config);
|
||||||
|
// The "compatible_printers" option key is handled differently from the others:
|
||||||
|
// It is not mandatory. If the key is missing, it means it is compatible with any printer.
|
||||||
|
// If the key exists and it is empty, it means it is compatible with no printer.
|
||||||
|
const char compatible_printers[] = "compatible_printers";
|
||||||
|
if (this->get_selected_preset().config.has(compatible_printers) != this->get_edited_preset().config.has(compatible_printers))
|
||||||
|
changed.emplace_back(compatible_printers);
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
// Select a new preset. This resets all the edits done to the currently selected preset.
|
// Select a new preset. This resets all the edits done to the currently selected preset.
|
||||||
// If the preset with index idx does not exist, a first visible preset is selected.
|
// If the preset with index idx does not exist, a first visible preset is selected.
|
||||||
Preset& PresetCollection::select_preset(size_t idx)
|
Preset& PresetCollection::select_preset(size_t idx)
|
||||||
|
|
|
@ -159,7 +159,7 @@ public:
|
||||||
// Return a preset by an index. If the preset is active, a temporary copy is returned.
|
// Return a preset by an index. If the preset is active, a temporary copy is returned.
|
||||||
Preset& preset(size_t idx) { return (int(idx) == m_idx_selected) ? m_edited_preset : m_presets[idx]; }
|
Preset& preset(size_t idx) { return (int(idx) == m_idx_selected) ? m_edited_preset : m_presets[idx]; }
|
||||||
const Preset& preset(size_t idx) const { return const_cast<PresetCollection*>(this)->preset(idx); }
|
const Preset& preset(size_t idx) const { return const_cast<PresetCollection*>(this)->preset(idx); }
|
||||||
void discard_current_changes() { m_edited_preset = m_presets[m_idx_selected]; }
|
void discard_current_changes() { m_presets[m_idx_selected].reset_dirty(); m_edited_preset = m_presets[m_idx_selected]; }
|
||||||
|
|
||||||
// Return a preset by its name. If the preset is active, a temporary copy is returned.
|
// 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.
|
// If a preset is not found by its name, null is returned.
|
||||||
|
@ -185,9 +185,9 @@ public:
|
||||||
size_t num_visible() const { return std::count_if(m_presets.begin(), m_presets.end(), [](const Preset &preset){return preset.is_visible;}); }
|
size_t num_visible() const { return std::count_if(m_presets.begin(), m_presets.end(), [](const Preset &preset){return preset.is_visible;}); }
|
||||||
|
|
||||||
// Compare the content of get_selected_preset() with get_edited_preset() configs, return true if they differ.
|
// Compare the content of get_selected_preset() with get_edited_preset() configs, return true if they differ.
|
||||||
bool current_is_dirty() { return ! this->current_dirty_options().empty(); }
|
bool current_is_dirty() const { return ! this->current_dirty_options().empty(); }
|
||||||
// Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ.
|
// Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ.
|
||||||
std::vector<std::string> current_dirty_options() { return this->get_selected_preset().config.diff(this->get_edited_preset().config); }
|
std::vector<std::string> current_dirty_options() const;
|
||||||
|
|
||||||
// Update the choice UI from the list of presets.
|
// Update the choice UI from the list of presets.
|
||||||
// If show_incompatible, all presets are shown, otherwise only the compatible presets are shown.
|
// If show_incompatible, all presets are shown, otherwise only the compatible presets are shown.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue