Automatically copy Simple Mode settings into a 'Simple Mode' preset in Expert Mode

This commit is contained in:
Alessandro Ranellucci 2013-11-11 22:02:12 +01:00
parent 33e160c1ed
commit 004517ad04
2 changed files with 11 additions and 2 deletions

View File

@ -56,7 +56,6 @@ sub new {
sub _accept { sub _accept {
my $self = shift; my $self = shift;
$self->EndModal(wxID_OK);
if ($self->{values}{mode}) { if ($self->{values}{mode}) {
Slic3r::GUI::warning_catcher($self)->("You need to restart Slic3r to make the changes effective."); Slic3r::GUI::warning_catcher($self)->("You need to restart Slic3r to make the changes effective.");
@ -64,6 +63,9 @@ sub _accept {
$Slic3r::GUI::Settings->{_}{$_} = $self->{values}{$_} for keys %{$self->{values}}; $Slic3r::GUI::Settings->{_}{$_} = $self->{values}{$_} for keys %{$self->{values}};
Slic3r::GUI->save_settings; Slic3r::GUI->save_settings;
$self->EndModal(wxID_OK);
$self->Close; # needed on Linux
} }
1; 1;

View File

@ -46,7 +46,8 @@ sub new {
my $class_prefix = $self->{mode} eq 'simple' ? "Slic3r::GUI::SimpleTab::" : "Slic3r::GUI::Tab::"; my $class_prefix = $self->{mode} eq 'simple' ? "Slic3r::GUI::SimpleTab::" : "Slic3r::GUI::Tab::";
my $init = 0; my $init = 0;
for my $tab_name (qw(print filament printer)) { for my $tab_name (qw(print filament printer)) {
my $tab = $self->{options_tabs}{$tab_name} = ($class_prefix . ucfirst $tab_name)->new( my $tab;
$tab = $self->{options_tabs}{$tab_name} = ($class_prefix . ucfirst $tab_name)->new(
$self->{tabpanel}, $self->{tabpanel},
on_value_change => sub { on_value_change => sub {
$self->{plater}->on_config_change(@_) if $self->{plater}; # propagate config change events to the plater $self->{plater}->on_config_change(@_) if $self->{plater}; # propagate config change events to the plater
@ -54,6 +55,12 @@ sub new {
if ($self->{mode} eq 'simple') { if ($self->{mode} eq 'simple') {
# save config # save config
$self->config->save("$Slic3r::GUI::datadir/simple.ini"); $self->config->save("$Slic3r::GUI::datadir/simple.ini");
# save a copy into each preset section
# so that user gets the config when switching to expert mode
$tab->config->save(sprintf "$Slic3r::GUI::datadir/%s/%s.ini", $tab->name, 'Simple Mode');
$Slic3r::GUI::Settings->{presets}{$tab->name} = 'Simple Mode.ini';
Slic3r::GUI->save_settings;
} }
$self->config->save($Slic3r::GUI::autosave) if $Slic3r::GUI::autosave; $self->config->save($Slic3r::GUI::autosave) if $Slic3r::GUI::autosave;
} }