Apply command line options to GUI
This commit is contained in:
parent
9210c708fc
commit
b37a77ee63
@ -85,11 +85,12 @@ sub new {
|
||||
EVT_BUTTON($self, $self->{btn_save_preset}, sub {
|
||||
my $preset = $self->current_preset;
|
||||
my $default_name = $preset->{default} ? 'Untitled' : basename($preset->{name});
|
||||
$default_name =~ s/\.ini$//i;
|
||||
|
||||
my $dlg = Slic3r::GUI::SavePresetWindow->new($self,
|
||||
title => lc($title),
|
||||
default => $default_name,
|
||||
values => [ map { my $filename = basename($_->{file}); $filename =~ /^(.*?)\.ini$/i; $1 } @{$self->{presets}} ],
|
||||
values => [ map { my $name = $_->{name}; $name =~ s/\.ini$//i; $name } @{$self->{presets}} ],
|
||||
);
|
||||
return unless $dlg->ShowModal == wxID_OK;
|
||||
|
||||
@ -97,7 +98,7 @@ sub new {
|
||||
Slic3r::Config->save($file, $self->{presets_group});
|
||||
$self->set_dirty(0);
|
||||
$self->load_presets;
|
||||
$self->{presets_choice}->SetSelection(first { basename($self->{presets}[$_]{file}) eq $dlg->get_name . ".ini" } 0 .. $#{$self->{presets}});
|
||||
$self->{presets_choice}->SetSelection(first { basename($self->{presets}[$_]{file}) eq $dlg->get_name . ".ini" } 1 .. $#{$self->{presets}});
|
||||
$self->on_select_preset;
|
||||
$self->sync_presets;
|
||||
});
|
||||
|
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…
Reference in New Issue
Block a user