Remember the filename and path of the last config file loaded, to use as default for saving

This commit is contained in:
Alessandro Ranellucci 2011-12-26 19:06:57 +01:00
parent f9446b9c6e
commit d6dcb35237

View File

@ -10,6 +10,7 @@ use Wx::Event qw(EVT_BUTTON);
use base 'Wx::Panel'; use base 'Wx::Panel';
my $last_dir; my $last_dir;
my $last_config;
sub new { sub new {
my $class = shift; my $class = shift;
@ -202,11 +203,14 @@ sub do_slice {
sub save_config { sub save_config {
my $self = shift; my $self = shift;
my $dlg = Wx::FileDialog->new($self, 'Save configuration as:', $last_dir || "", "config.ini", my $dir = $last_config ? dirname($last_config) : $last_dir || "";
my $filename = $last_config ? basename($last_config) : "config.ini";
my $dlg = Wx::FileDialog->new($self, 'Save configuration as:', $dir, $filename,
$ini_wildcard, wxFD_SAVE); $ini_wildcard, wxFD_SAVE);
if ($dlg->ShowModal == wxID_OK) { if ($dlg->ShowModal == wxID_OK) {
my $file = $dlg->GetPath; my $file = $dlg->GetPath;
$last_dir = dirname($file); $last_dir = dirname($file);
$last_config = $file;
Slic3r::Config->save($file); Slic3r::Config->save($file);
} }
} }
@ -219,6 +223,7 @@ sub load_config {
if ($dlg->ShowModal == wxID_OK) { if ($dlg->ShowModal == wxID_OK) {
my ($file) = $dlg->GetPaths; my ($file) = $dlg->GetPaths;
$last_dir = dirname($file); $last_dir = dirname($file);
$last_config = $file;
eval { eval {
local $SIG{__WARN__} = $self->catch_warning; local $SIG{__WARN__} = $self->catch_warning;
Slic3r::Config->load($file); Slic3r::Config->load($file);