mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 16:55:59 +08:00
Rename 'overridable' to 'shortcuts' and change semantics accordingly: options in plater update the selected preset automatically instead of overriding it
This commit is contained in:
parent
3ca6ff38e8
commit
19a36cfda5
@ -49,7 +49,7 @@ sub new {
|
||||
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
$self->{config} = Slic3r::Config->new_from_defaults(qw(
|
||||
bed_shape complete_objects extruder_clearance_radius skirts skirt_distance brim_width
|
||||
serial_port serial_speed octoprint_host octoprint_apikey overridable filament_colour
|
||||
serial_port serial_speed octoprint_host octoprint_apikey shortcuts filament_colour
|
||||
));
|
||||
$self->{model} = Slic3r::Model->new;
|
||||
$self->{print} = Slic3r::Print->new;
|
||||
@ -367,6 +367,13 @@ sub new {
|
||||
{
|
||||
my $o = $self->{settings_override_panel} = Slic3r::GUI::Plater::OverrideSettingsPanel->new($self,
|
||||
on_change => sub {
|
||||
my ($preset) = $self->selected_presets('print');
|
||||
|
||||
# Apply the overrides to the current Print preset, potentially making it dirty
|
||||
$preset->load_config;
|
||||
$preset->_dirty_config->apply($self->{settings_override_config});
|
||||
|
||||
$self->load_presets;
|
||||
$self->config_changed;
|
||||
});
|
||||
$o->set_editable(1);
|
||||
@ -568,10 +575,10 @@ sub _on_select_preset {
|
||||
$o_config->clear;
|
||||
}
|
||||
|
||||
my $overridable = $config->get('overridable');
|
||||
my $shortcuts = $config->get('shortcuts');
|
||||
|
||||
# Add/remove options (we do it this way for preserving current options)
|
||||
foreach my $opt_key (@$overridable) {
|
||||
foreach my $opt_key (@$shortcuts) {
|
||||
# Populate option with the default value taken from configuration
|
||||
# (re-set the override always, because if we here it means user
|
||||
# switched to this preset or opened/closed the editor, so he expects
|
||||
@ -579,15 +586,15 @@ sub _on_select_preset {
|
||||
$o_config->set($opt_key, $config->get($opt_key));
|
||||
}
|
||||
foreach my $opt_key (@{$o_config->get_keys}) {
|
||||
# Keep options listed among overridable and options added on the fly
|
||||
if ((none { $_ eq $opt_key } @$overridable)
|
||||
# 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_fixed_options(\@$overridable);
|
||||
$o_panel->set_fixed_options(\@$shortcuts);
|
||||
$o_panel->update_optgroup;
|
||||
} elsif ($group eq 'printer') {
|
||||
# reload print and filament settings to honor their compatible_printer options
|
||||
@ -766,7 +773,7 @@ sub config {
|
||||
my $config = Slic3r::Config->new_from_defaults;
|
||||
|
||||
# get defaults also for the values tracked by the Plater's config
|
||||
# (for example 'overridable')
|
||||
# (for example 'shortcuts')
|
||||
$config->apply(Slic3r::Config->new_from_defaults(@{$self->{config}->get_keys}));
|
||||
|
||||
my %classes = map { $_ => "Slic3r::GUI::PresetEditor::".ucfirst($_) }
|
||||
|
@ -167,6 +167,8 @@ sub dirty_config {
|
||||
sub load_config {
|
||||
my ($self) = @_;
|
||||
|
||||
return if $self->_loaded;
|
||||
|
||||
my @keys = $self->_group_class->options;
|
||||
my @extra_keys = $self->_group_class->overriding_options;
|
||||
|
||||
|
@ -441,7 +441,7 @@ sub options {
|
||||
external_perimeter_extrusion_width infill_extrusion_width solid_infill_extrusion_width
|
||||
top_infill_extrusion_width support_material_extrusion_width
|
||||
infill_overlap bridge_flow_ratio
|
||||
xy_size_compensation resolution overridable compatible_printers
|
||||
xy_size_compensation resolution shortcuts compatible_printers
|
||||
print_settings_id
|
||||
)
|
||||
}
|
||||
@ -449,7 +449,7 @@ sub options {
|
||||
sub build {
|
||||
my $self = shift;
|
||||
|
||||
my $overridable_widget = sub {
|
||||
my $shortcuts_widget = sub {
|
||||
my ($parent) = @_;
|
||||
|
||||
my $Options = $Slic3r::Config::Options;
|
||||
@ -458,15 +458,15 @@ sub build {
|
||||
grep { exists $Options->{$_} && $Options->{$_}{category} } $self->options
|
||||
);
|
||||
my @opt_keys = sort { $options{$a} cmp $options{$b} } keys %options;
|
||||
$self->{overridable_opt_keys} = [ @opt_keys ];
|
||||
$self->{shortcuts_opt_keys} = [ @opt_keys ];
|
||||
|
||||
my $listbox = $self->{overridable_list} = Wx::CheckListBox->new($parent, -1,
|
||||
my $listbox = $self->{shortcuts_list} = Wx::CheckListBox->new($parent, -1,
|
||||
wxDefaultPosition, [-1, 320], [ map $options{$_}, @opt_keys ]);
|
||||
|
||||
EVT_CHECKLISTBOX($self, $listbox, sub {
|
||||
my $value = [ map $opt_keys[$_], grep $listbox->IsChecked($_), 0..$#opt_keys ];
|
||||
$self->config->set('overridable', $value);
|
||||
$self->_on_value_change('overridable');
|
||||
$self->config->set('shortcuts', $value);
|
||||
$self->_on_value_change('shortcuts');
|
||||
});
|
||||
|
||||
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
@ -715,7 +715,7 @@ sub build {
|
||||
}
|
||||
|
||||
{
|
||||
my $page = $self->add_options_page('Overrides', 'wrench.png');
|
||||
my $page = $self->add_options_page('Shortcuts', 'wrench.png');
|
||||
{
|
||||
my $optgroup = $page->new_optgroup('Profile preferences');
|
||||
{
|
||||
@ -727,10 +727,10 @@ sub build {
|
||||
}
|
||||
}
|
||||
{
|
||||
my $optgroup = $page->new_optgroup('Overridable settings (they will be displayed in the plater for quick changes)');
|
||||
my $optgroup = $page->new_optgroup('Show shortcuts for the following settings');
|
||||
{
|
||||
my $line = Slic3r::GUI::OptionsGroup::Line->new(
|
||||
widget => $overridable_widget,
|
||||
widget => $shortcuts_widget,
|
||||
full_width => 1,
|
||||
);
|
||||
$optgroup->append_line($line);
|
||||
@ -745,9 +745,9 @@ sub reload_config {
|
||||
$self->_reload_compatible_printers_widget;
|
||||
|
||||
{
|
||||
my %overridable = map { $_ => 1 } @{ $self->config->get('overridable') };
|
||||
for my $i (0..$#{$self->{overridable_opt_keys}}) {
|
||||
$self->{overridable_list}->Check($i, $overridable{ $self->{overridable_opt_keys}[$i] });
|
||||
my %shortcuts = map { $_ => 1 } @{ $self->config->get('shortcuts') };
|
||||
for my $i (0..$#{$self->{shortcuts_opt_keys}}) {
|
||||
$self->{shortcuts_list}->Check($i, $shortcuts{ $self->{shortcuts_opt_keys}[$i] });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -853,8 +853,9 @@ PrintConfigDef::PrintConfigDef()
|
||||
def->cli = "overhangs|detect-bridging-perimeters!";
|
||||
def->default_value = new ConfigOptionBool(true);
|
||||
|
||||
def = this->add("overridable", coStrings);
|
||||
def->label = "Overridable options";
|
||||
def = this->add("shortcuts", coStrings);
|
||||
def->label = "Shortcuts";
|
||||
def->aliases.push_back("overridable");
|
||||
{
|
||||
ConfigOptionStrings* opt = new ConfigOptionStrings();
|
||||
opt->values.push_back("support_material");
|
||||
|
Loading…
x
Reference in New Issue
Block a user