From 004517ad04985c8b4833b9908533b90893758093 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 11 Nov 2013 22:02:12 +0100 Subject: [PATCH] Automatically copy Simple Mode settings into a 'Simple Mode' preset in Expert Mode --- lib/Slic3r/GUI/Preferences.pm | 4 +++- lib/Slic3r/GUI/SkeinPanel.pm | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/Preferences.pm b/lib/Slic3r/GUI/Preferences.pm index 2630745b8..c004d8b01 100644 --- a/lib/Slic3r/GUI/Preferences.pm +++ b/lib/Slic3r/GUI/Preferences.pm @@ -56,7 +56,6 @@ sub new { sub _accept { my $self = shift; - $self->EndModal(wxID_OK); if ($self->{values}{mode}) { 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->save_settings; + + $self->EndModal(wxID_OK); + $self->Close; # needed on Linux } 1; diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 2f3afed0a..3fd246de8 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -46,7 +46,8 @@ sub new { my $class_prefix = $self->{mode} eq 'simple' ? "Slic3r::GUI::SimpleTab::" : "Slic3r::GUI::Tab::"; my $init = 0; 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}, on_value_change => sub { $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') { # save config $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; }