mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 10:17:55 -06:00
Fix of preset selection.
This commit is contained in:
parent
0b6bd3cbde
commit
c3468f2ad9
2 changed files with 12 additions and 13 deletions
|
@ -610,6 +610,8 @@ sub load_configbundle {
|
||||||
|
|
||||||
# Load a provied DynamicConfig into the Print / Filament / Printer tabs, thus modifying the active preset.
|
# Load a provied DynamicConfig into the Print / Filament / Printer tabs, thus modifying the active preset.
|
||||||
# Also update the platter with the new presets.
|
# Also update the platter with the new presets.
|
||||||
|
# This method is used to update the configuration from mainpulations in the 3D scene (for example moving the wipe tower),
|
||||||
|
# and to load the configuration from the config wizard.
|
||||||
sub load_config {
|
sub load_config {
|
||||||
my ($self, $config) = @_;
|
my ($self, $config) = @_;
|
||||||
$_->load_config($config) foreach values %{$self->{options_tabs}};
|
$_->load_config($config) foreach values %{$self->{options_tabs}};
|
||||||
|
@ -639,8 +641,8 @@ sub config_wizard {
|
||||||
}
|
}
|
||||||
if (defined $result->{config}) {
|
if (defined $result->{config}) {
|
||||||
# Wizard returned a config. Add the config to each of the preset types.
|
# Wizard returned a config. Add the config to each of the preset types.
|
||||||
for my $tab (values %{$self->{options_tabs}}) {
|
# Select and load the "-- default --" preset.
|
||||||
# Select the first visible preset, force.
|
foreach my $tab (values %{$self->{options_tabs}}) {
|
||||||
$tab->select_preset(undef, 1);
|
$tab->select_preset(undef, 1);
|
||||||
}
|
}
|
||||||
# Load the config over the previously selected defaults.
|
# Load the config over the previously selected defaults.
|
||||||
|
|
|
@ -272,6 +272,8 @@ sub select_preset {
|
||||||
my ($self, $name, $force) = @_;
|
my ($self, $name, $force) = @_;
|
||||||
$force //= 0;
|
$force //= 0;
|
||||||
my $presets = $self->{presets};
|
my $presets = $self->{presets};
|
||||||
|
# If no name is provided, select the "-- default --" preset.
|
||||||
|
$name //= $presets->default_preset->name;
|
||||||
my $current_dirty = $presets->current_is_dirty;
|
my $current_dirty = $presets->current_is_dirty;
|
||||||
my $canceled = 0;
|
my $canceled = 0;
|
||||||
my $printer_tab = $presets->name eq 'printer';
|
my $printer_tab = $presets->name eq 'printer';
|
||||||
|
@ -283,19 +285,18 @@ sub select_preset {
|
||||||
# are compatible with the new printer.
|
# are compatible with the new printer.
|
||||||
# If they are not compatible and the the current print or filament are dirty, let user decide
|
# If they are not compatible and the the current print or filament are dirty, let user decide
|
||||||
# whether to discard the changes or keep the current printer selection.
|
# whether to discard the changes or keep the current printer selection.
|
||||||
my $new_printer_name = $name // '';
|
my $new_printer_preset = $presets->find_preset($name, 1);
|
||||||
my $new_printer_preset = $presets->find_preset($new_printer_name, 1);
|
|
||||||
my $print_presets = wxTheApp->{preset_bundle}->print;
|
my $print_presets = wxTheApp->{preset_bundle}->print;
|
||||||
my $print_preset_dirty = $print_presets->current_is_dirty;
|
my $print_preset_dirty = $print_presets->current_is_dirty;
|
||||||
my $print_preset_compatible = $print_presets->get_edited_preset->is_compatible_with_printer($new_printer_preset);
|
my $print_preset_compatible = $print_presets->get_edited_preset->is_compatible_with_printer($new_printer_preset);
|
||||||
$canceled = $print_preset_dirty && ! $print_preset_compatible &&
|
$canceled = ! $force && $print_preset_dirty && ! $print_preset_compatible &&
|
||||||
! $self->may_discard_current_dirty_preset($print_presets, $new_printer_name);
|
! $self->may_discard_current_dirty_preset($print_presets, $name);
|
||||||
my $filament_presets = wxTheApp->{preset_bundle}->filament;
|
my $filament_presets = wxTheApp->{preset_bundle}->filament;
|
||||||
my $filament_preset_dirty = $filament_presets->current_is_dirty;
|
my $filament_preset_dirty = $filament_presets->current_is_dirty;
|
||||||
my $filament_preset_compatible = $filament_presets->get_edited_preset->is_compatible_with_printer($new_printer_preset);
|
my $filament_preset_compatible = $filament_presets->get_edited_preset->is_compatible_with_printer($new_printer_preset);
|
||||||
if (! $canceled) {
|
if (! $canceled && ! $force) {
|
||||||
$canceled = $filament_preset_dirty && ! $filament_preset_compatible &&
|
$canceled = $filament_preset_dirty && ! $filament_preset_compatible &&
|
||||||
! $self->may_discard_current_dirty_preset($filament_presets, $new_printer_name);
|
! $self->may_discard_current_dirty_preset($filament_presets, $name);
|
||||||
}
|
}
|
||||||
if (! $canceled) {
|
if (! $canceled) {
|
||||||
if (! $print_preset_compatible) {
|
if (! $print_preset_compatible) {
|
||||||
|
@ -317,11 +318,7 @@ sub select_preset {
|
||||||
$self->_on_presets_changed;
|
$self->_on_presets_changed;
|
||||||
} else {
|
} else {
|
||||||
$presets->discard_current_changes if $current_dirty;
|
$presets->discard_current_changes if $current_dirty;
|
||||||
if (defined $name) {
|
$presets->select_preset_by_name($name);
|
||||||
$presets->select_preset_by_name($name);
|
|
||||||
} else {
|
|
||||||
$presets->select_preset(0);
|
|
||||||
}
|
|
||||||
# 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.
|
||||||
# The following method should not discard changes of current print or filament presets on change of a printer profile,
|
# The following method should not discard changes of current print or filament presets on change of a printer profile,
|
||||||
# if they are compatible with the current printer.
|
# if they are compatible with the current printer.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue