mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 20:51:12 -06:00 
			
		
		
		
	Import config bundle automatically if found in application directory
This commit is contained in:
		
							parent
							
								
									7e1fac8f76
								
							
						
					
					
						commit
						32a333f16a
					
				
					 6 changed files with 50 additions and 9 deletions
				
			
		|  | @ -31,7 +31,8 @@ sub new_from_defaults { | |||
|     my $self = $class->new; | ||||
|     my $defaults = Slic3r::Config::Full->new; | ||||
|     if (@opt_keys) { | ||||
|         $self->set($_, $defaults->get($_)) for @opt_keys; | ||||
|         $self->set($_, $defaults->get($_)) | ||||
|             for grep $defaults->has($_), @opt_keys; | ||||
|     } else { | ||||
|         $self->apply_static($defaults); | ||||
|     } | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ use utf8; | |||
| 
 | ||||
| use File::Basename qw(basename); | ||||
| use FindBin; | ||||
| use List::Util qw(first); | ||||
| use Slic3r::GUI::2DBed; | ||||
| use Slic3r::GUI::AboutDialog; | ||||
| use Slic3r::GUI::BedShapeDialog; | ||||
|  | @ -126,6 +127,22 @@ sub OnInit { | |||
|     ); | ||||
|     $self->SetTopWindow($frame); | ||||
|      | ||||
|     # load init bundle | ||||
|     { | ||||
|         my @dirs = ($FindBin::Bin); | ||||
|         if (&Wx::wxMAC) { | ||||
|             push @dirs, qw(); | ||||
|         } elsif (&Wx::wxMSW) { | ||||
|             push @dirs, qw(); | ||||
|         } | ||||
|         my $init_bundle = first { -e $_ } map "$_/.init_bundle.ini", @dirs; | ||||
|         if ($init_bundle) { | ||||
|             Slic3r::debugf "Loading config bundle from %s\n", $init_bundle; | ||||
|             $self->{mainframe}->load_configbundle($init_bundle, 1); | ||||
|             $run_wizard = 0; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     if (!$run_wizard && (!defined $last_version || $last_version ne $Slic3r::VERSION)) { | ||||
|         # user was running another Slic3r version on this computer | ||||
|         if (!defined $last_version || $last_version =~ /^0\./) { | ||||
|  |  | |||
|  | @ -560,14 +560,16 @@ sub export_configbundle { | |||
| } | ||||
| 
 | ||||
| sub load_configbundle { | ||||
|     my $self = shift; | ||||
|     my ($self, $file, $skip_no_id) = @_; | ||||
|      | ||||
|     my $dir = $last_config ? dirname($last_config) : $Slic3r::GUI::Settings->{recent}{config_directory} || $Slic3r::GUI::Settings->{recent}{skein_directory} || ''; | ||||
|     my $dlg = Wx::FileDialog->new($self, 'Select configuration to load:', $dir, "config.ini",  | ||||
|             &Slic3r::GUI::FILE_WILDCARDS->{ini}, wxFD_OPEN | wxFD_FILE_MUST_EXIST); | ||||
|     return unless $dlg->ShowModal == wxID_OK; | ||||
|     my $file = Slic3r::decode_path($dlg->GetPaths); | ||||
|     $dlg->Destroy; | ||||
|     if (!$file) { | ||||
|         my $dir = $last_config ? dirname($last_config) : $Slic3r::GUI::Settings->{recent}{config_directory} || $Slic3r::GUI::Settings->{recent}{skein_directory} || ''; | ||||
|         my $dlg = Wx::FileDialog->new($self, 'Select configuration to load:', $dir, "config.ini",  | ||||
|                 &Slic3r::GUI::FILE_WILDCARDS->{ini}, wxFD_OPEN | wxFD_FILE_MUST_EXIST); | ||||
|         return unless $dlg->ShowModal == wxID_OK; | ||||
|         $file = Slic3r::decode_path($dlg->GetPaths); | ||||
|         $dlg->Destroy; | ||||
|     } | ||||
|      | ||||
|     $Slic3r::GUI::Settings->{recent}{config_directory} = dirname($file); | ||||
|     wxTheApp->save_settings; | ||||
|  | @ -593,11 +595,23 @@ sub load_configbundle { | |||
|         } | ||||
|     } | ||||
|     my $imported = 0; | ||||
|     foreach my $ini_category (sort keys %$ini) { | ||||
|     INI_BLOCK: foreach my $ini_category (sort keys %$ini) { | ||||
|         next unless $ini_category =~ /^(print|filament|printer):(.+)$/; | ||||
|         my ($section, $preset_name) = ($1, $2); | ||||
|         my $config = Slic3r::Config->load_ini_hash($ini->{$ini_category}); | ||||
|         next if $skip_no_id && !$config->get($section . "_settings_id"); | ||||
|          | ||||
|         { | ||||
|             my %current_presets = Slic3r::GUI->presets($section); | ||||
|             my %current_ids = map { $_ => 1 } | ||||
|                 grep $_, | ||||
|                 map Slic3r::Config->load($_)->get($section . "_settings_id"), | ||||
|                 values %current_presets; | ||||
|             next INI_BLOCK if exists $current_ids{$config->get($section . "_settings_id")}; | ||||
|         } | ||||
|          | ||||
|         $config->save(sprintf "$Slic3r::GUI::datadir/%s/%s.ini", $section, $preset_name); | ||||
|         Slic3r::debugf "Imported %s preset %s\n", $section, $preset_name; | ||||
|         $imported++; | ||||
|     } | ||||
|     if ($self->{mode} eq 'expert') { | ||||
|  |  | |||
|  | @ -493,6 +493,7 @@ sub build { | |||
|         infill_overlap bridge_flow_ratio | ||||
|         xy_size_compensation threads resolution | ||||
|     )); | ||||
|     $self->{config}->set('print_settings_id', ''); | ||||
|      | ||||
|     { | ||||
|         my $page = $self->add_options_page('Layers and perimeters', 'layers.png'); | ||||
|  | @ -856,6 +857,7 @@ sub build { | |||
|         min_fan_speed max_fan_speed bridge_fan_speed disable_fan_first_layers | ||||
|         fan_below_layer_time slowdown_below_layer_time min_print_speed | ||||
|     )); | ||||
|     $self->{config}->set('filament_settings_id', ''); | ||||
|      | ||||
|     { | ||||
|         my $page = $self->add_options_page('Filament', 'spool.png'); | ||||
|  | @ -996,6 +998,7 @@ sub build { | |||
|         retract_length retract_lift retract_speed retract_restart_extra retract_before_travel retract_layer_change wipe | ||||
|         retract_length_toolchange retract_restart_extra_toolchange | ||||
|     )); | ||||
|     $self->{config}->set('printer_settings_id', ''); | ||||
|      | ||||
|     my $bed_shape_widget = sub { | ||||
|         my ($parent) = @_; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci