mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-13 21:25:53 +08:00
Further change. Since we now have shortcuts, and not overrides, remove the + button for adding them on the fly, as it doesn't provide any advantage over actually opening the profile. Oh the other hand, automatically list dirty options in the plater
This commit is contained in:
parent
2efb863a87
commit
0cc9dad14a
@ -366,16 +366,25 @@ sub new {
|
|||||||
{
|
{
|
||||||
my $o = $self->{settings_override_panel} = Slic3r::GUI::Plater::OverrideSettingsPanel->new($self,
|
my $o = $self->{settings_override_panel} = Slic3r::GUI::Plater::OverrideSettingsPanel->new($self,
|
||||||
on_change => sub {
|
on_change => sub {
|
||||||
my ($preset) = $self->selected_presets('print');
|
my ($opt_key) = @_;
|
||||||
|
|
||||||
# Apply the overrides to the current Print preset, potentially making it dirty
|
my ($preset) = $self->selected_presets('print');
|
||||||
$preset->load_config;
|
$preset->load_config;
|
||||||
$preset->_dirty_config->apply($self->{settings_override_config});
|
|
||||||
|
# If this option is not in the override panel it means it was manually deleted,
|
||||||
|
# so let's restore the profile value.
|
||||||
|
if (!$self->{settings_override_config}->has($opt_key)) {
|
||||||
|
$preset->_dirty_config->set($opt_key, $preset->_config->get($opt_key));
|
||||||
|
} else {
|
||||||
|
# Apply the overrides to the current Print preset, potentially making it dirty
|
||||||
|
$preset->_dirty_config->apply($self->{settings_override_config});
|
||||||
|
}
|
||||||
|
|
||||||
$self->load_presets;
|
$self->load_presets;
|
||||||
$self->config_changed;
|
$self->config_changed;
|
||||||
});
|
});
|
||||||
$o->set_editable(1);
|
$o->can_add(0);
|
||||||
|
$o->can_delete(1);
|
||||||
$o->set_opt_keys([ Slic3r::GUI::PresetEditor::Print->options ]);
|
$o->set_opt_keys([ Slic3r::GUI::PresetEditor::Print->options ]);
|
||||||
$self->{settings_override_config} = Slic3r::Config->new;
|
$self->{settings_override_config} = Slic3r::Config->new;
|
||||||
$o->set_default_config($self->{settings_override_config});
|
$o->set_default_config($self->{settings_override_config});
|
||||||
@ -569,30 +578,14 @@ sub _on_select_preset {
|
|||||||
my $o_config = $self->{settings_override_config};
|
my $o_config = $self->{settings_override_config};
|
||||||
my $o_panel = $self->{settings_override_panel};
|
my $o_panel = $self->{settings_override_panel};
|
||||||
|
|
||||||
if ($changed) {
|
|
||||||
# Preserve current options if re-selecting the same preset
|
|
||||||
$o_config->clear;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $shortcuts = $config->get('shortcuts');
|
my $shortcuts = $config->get('shortcuts');
|
||||||
|
|
||||||
# Add/remove options (we do it this way for preserving current options)
|
# Re-populate the override panel with the configured shortcuts
|
||||||
foreach my $opt_key (@{$o_config->get_keys}, @$shortcuts) {
|
# and the dirty options.
|
||||||
# Populate option with the default value taken from configuration
|
$o_config->clear;
|
||||||
# (re-set the override always, because if we here it means user
|
foreach my $opt_key (@$shortcuts, $presets[0]->dirty_options) {
|
||||||
# switched to this preset or opened/closed the editor, so he expects
|
|
||||||
# the new values set in the editor to be used).
|
|
||||||
# Do this for both the current options and the configured shortcuts
|
|
||||||
# to make sure everything gets updated.
|
|
||||||
$o_config->set($opt_key, $config->get($opt_key));
|
$o_config->set($opt_key, $config->get($opt_key));
|
||||||
}
|
}
|
||||||
foreach my $opt_key (@{$o_config->get_keys}) {
|
|
||||||
# Keep options listed among shortcuts and options added on the fly
|
|
||||||
if ((none { $_ eq $opt_key } @$shortcuts)
|
|
||||||
&& (any { $_ eq $opt_key } $o_panel->fixed_options)) {
|
|
||||||
$o_config->erase($opt_key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$o_panel->set_default_config($config);
|
$o_panel->set_default_config($config);
|
||||||
$o_panel->set_fixed_options(\@$shortcuts);
|
$o_panel->set_fixed_options(\@$shortcuts);
|
||||||
|
@ -34,7 +34,8 @@ sub new {
|
|||||||
$self->{default_config} = Slic3r::Config->new;
|
$self->{default_config} = Slic3r::Config->new;
|
||||||
$self->{config} = Slic3r::Config->new;
|
$self->{config} = Slic3r::Config->new;
|
||||||
$self->{on_change} = $params{on_change};
|
$self->{on_change} = $params{on_change};
|
||||||
$self->{editable} = 1;
|
$self->{can_add} = 1;
|
||||||
|
$self->{can_delete} = 1;
|
||||||
$self->{fixed_options} = {};
|
$self->{fixed_options} = {};
|
||||||
|
|
||||||
$self->{sizer} = Wx::BoxSizer->new(wxVERTICAL);
|
$self->{sizer} = Wx::BoxSizer->new(wxVERTICAL);
|
||||||
@ -141,7 +142,7 @@ sub update_optgroup {
|
|||||||
$self->{options_sizer}->Clear(1);
|
$self->{options_sizer}->Clear(1);
|
||||||
return if !defined $self->{config};
|
return if !defined $self->{config};
|
||||||
|
|
||||||
$self->{btn_add}->Show($self->{editable});
|
$self->{btn_add}->Show($self->{can_add});
|
||||||
|
|
||||||
my %categories = ();
|
my %categories = ();
|
||||||
foreach my $opt_key (@{$self->{config}->get_keys}) {
|
foreach my $opt_key (@{$self->{config}->get_keys}) {
|
||||||
@ -170,7 +171,7 @@ sub update_optgroup {
|
|||||||
my ($opt_key, $opt_index) = @{ $optgroup->_opt_map->{$opt_id} };
|
my ($opt_key, $opt_index) = @{ $optgroup->_opt_map->{$opt_id} };
|
||||||
|
|
||||||
# disallow deleting fixed options
|
# disallow deleting fixed options
|
||||||
return undef if $self->{fixed_options}{$opt_key} || !$self->{editable};
|
return undef if $self->{fixed_options}{$opt_key} || !$self->{can_delete};
|
||||||
|
|
||||||
my $btn = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new($Slic3r::var->("delete.png"), wxBITMAP_TYPE_PNG),
|
my $btn = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new($Slic3r::var->("delete.png"), wxBITMAP_TYPE_PNG),
|
||||||
wxDefaultPosition, wxDefaultSize, Wx::wxBORDER_NONE);
|
wxDefaultPosition, wxDefaultSize, Wx::wxBORDER_NONE);
|
||||||
@ -207,11 +208,27 @@ sub disable {
|
|||||||
$self->Disable;
|
$self->Disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Shows or hides the Add button.
|
# Shows or hides the Add/Delete buttons.
|
||||||
sub set_editable {
|
sub set_editable {
|
||||||
my ($self, $editable) = @_;
|
my ($self, $editable) = @_;
|
||||||
|
|
||||||
$self->{editable} = $editable;
|
$self->{can_add} = $self->{can_delete} = $editable;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shows or hides the Add button.
|
||||||
|
sub can_add {
|
||||||
|
my ($self, $can) = @_;
|
||||||
|
|
||||||
|
$self->{can_add} = $can if defined $can;
|
||||||
|
return $can;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shows or hides the Delete button.
|
||||||
|
sub can_delete {
|
||||||
|
my ($self, $can) = @_;
|
||||||
|
|
||||||
|
$self->{can_delete} = $can if defined $can;
|
||||||
|
return $can;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user