mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 20:51:12 -06:00 
			
		
		
		
	Apply command line options to GUI
This commit is contained in:
		
							parent
							
								
									9210c708fc
								
							
						
					
					
						commit
						b37a77ee63
					
				
					 2 changed files with 24 additions and 12 deletions
				
			
		
							
								
								
									
										31
									
								
								slic3r.pl
									
										
									
									
									
								
							
							
						
						
									
										31
									
								
								slic3r.pl
									
										
									
									
									
								
							|  | @ -9,6 +9,7 @@ BEGIN { | |||
| } | ||||
| 
 | ||||
| use Getopt::Long qw(:config no_auto_abbrev); | ||||
| use List::Util qw(first); | ||||
| use Slic3r; | ||||
| $|++; | ||||
| 
 | ||||
|  | @ -57,27 +58,37 @@ if ($opt{load}) { | |||
| } | ||||
| 
 | ||||
| # validate command line options | ||||
| delete $cli_options{$_} for grep !defined $cli_options{$_}, keys %cli_options; | ||||
| Slic3r::Config->validate_cli(\%cli_options); | ||||
| 
 | ||||
| # apply command line options | ||||
| Slic3r::Config->set($_ => $cli_options{$_}) | ||||
|     for grep defined $cli_options{$_}, keys %cli_options; | ||||
| # initialize GUI | ||||
| my $gui; | ||||
| if (!@ARGV && !$opt{save} && eval "require Slic3r::GUI; 1") { | ||||
|     $gui = Slic3r::GUI->new; | ||||
|     $gui->{skeinpanel}->load_config($opt{load}[0]) if $opt{load}; | ||||
| } | ||||
| die $@ if $@ && $opt{gui}; | ||||
| 
 | ||||
| # validate configuration | ||||
| # apply command line options | ||||
| Slic3r::Config->set($_ => $cli_options{$_}) for keys %cli_options; | ||||
| 
 | ||||
| # validate configuration, convert options like --print-center to arrayrefs, init extruders etc. | ||||
| Slic3r::Config->validate; | ||||
| 
 | ||||
| # save configuration | ||||
| Slic3r::Config->save($opt{save}) if $opt{save}; | ||||
| 
 | ||||
| # start GUI | ||||
| if (!@ARGV && !$opt{save} && eval "require Slic3r::GUI; 1") { | ||||
|     no warnings 'once'; | ||||
|     my $gui = Slic3r::GUI->new; | ||||
|     $gui->{skeinpanel}->load_config($opt{load}[0]) if $opt{load}; | ||||
| # apply command line options to GUI as well and start it | ||||
| if ($gui) { | ||||
|     for my $opt_key (keys %cli_options) { | ||||
|         no warnings 'once'; | ||||
|         ( $Slic3r::GUI::OptionsGroup::reload_callbacks{$opt_key} || sub {} )->(); | ||||
|         my $group = first { $opt_key ~~ @$_ } keys %Slic3r::Groups; | ||||
|         $gui->{skeinpanel}{options_tabs}{$group}->set_dirty(1) if $group; | ||||
|     } | ||||
|     $gui->MainLoop; | ||||
|     exit; | ||||
| } | ||||
| die $@ if $@ && $opt{gui}; | ||||
| 
 | ||||
| if (@ARGV) { | ||||
|     while (my $input_file = shift @ARGV) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci