New option to remember last output directory. #698

This commit is contained in:
Alessandro Ranellucci 2013-04-27 21:07:30 +02:00
parent f5bda326b8
commit 6db8afe36d
4 changed files with 23 additions and 2 deletions

View File

@ -304,6 +304,15 @@ sub check_version {
})->detach;
}
sub output_path {
my $class = shift;
my ($dir) = @_;
return ($Settings->{_}{last_output_path} && $Settings->{_}{remember_output_path})
? $Settings->{_}{last_output_path}
: $dir;
}
package Slic3r::GUI::ProgressStatusBar;
use Wx qw(:gauge :misc);
use base 'Wx::StatusBar';

View File

@ -531,12 +531,14 @@ sub export_gcode {
$self->{output_file} = $main::opt{output};
{
$self->{output_file} = $print->expanded_output_filepath($self->{output_file}, $self->{objects}[0]->input_file);
my $dlg = Wx::FileDialog->new($self, 'Save G-code file as:', dirname($self->{output_file}),
my $dlg = Wx::FileDialog->new($self, 'Save G-code file as:', Slic3r::GUI->output_path(dirname($self->{output_file})),
basename($self->{output_file}), &Slic3r::GUI::SkeinPanel::FILE_WILDCARDS->{gcode}, wxFD_SAVE);
if ($dlg->ShowModal != wxID_OK) {
$dlg->Destroy;
return;
}
$Slic3r::GUI::Settings->{_}{last_output_path} = dirname($dlg->GetPath);
Slic3r::GUI->save_settings;
$self->{output_file} = $Slic3r::GUI::SkeinPanel::last_output_file = $dlg->GetPath;
$dlg->Destroy;
}

View File

@ -30,6 +30,13 @@ sub new {
default => $Slic3r::GUI::Settings->{_}{version_check} // 1,
readonly => !Slic3r::GUI->have_version_check,
},
{
opt_key => 'remember_output_path',
type => 'bool',
label => 'Remember output directory',
tooltip => 'If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files.',
default => $Slic3r::GUI::Settings->{_}{remember_output_path},
},
],
on_change => sub { $self->{values}{$_[0]} = $_[1] },
label_width => 100,

View File

@ -133,7 +133,8 @@ sub do_slice {
} elsif ($params{save_as}) {
$output_file = $print->expanded_output_filepath($output_file);
$output_file =~ s/\.gcode$/.svg/i if $params{export_svg};
my $dlg = Wx::FileDialog->new($self, 'Save ' . ($params{export_svg} ? 'SVG' : 'G-code') . ' file as:', dirname($output_file),
my $dlg = Wx::FileDialog->new($self, 'Save ' . ($params{export_svg} ? 'SVG' : 'G-code') . ' file as:',
Slic3r::GUI->output_path(dirname($output_file)),
basename($output_file), $params{export_svg} ? FILE_WILDCARDS->{svg} : FILE_WILDCARDS->{gcode}, wxFD_SAVE);
if ($dlg->ShowModal != wxID_OK) {
$dlg->Destroy;
@ -141,6 +142,8 @@ sub do_slice {
}
$output_file = $dlg->GetPath;
$last_output_file = $output_file unless $params{export_svg};
$Slic3r::GUI::Settings->{_}{last_output_path} = dirname($output_file);
Slic3r::GUI->save_settings;
$dlg->Destroy;
}