From c957c273670654ca2761fe5c15255f2a63f9971c Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 9 Dec 2011 14:07:50 +0100 Subject: [PATCH] Remember last opened directory. #106 --- lib/Slic3r/GUI/SkeinPanel.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 1f993df177..5c308674e4 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -3,12 +3,14 @@ use strict; use warnings; use utf8; -use File::Basename qw(basename); +use File::Basename qw(basename dirname); use Wx qw(:sizer :progressdialog wxOK wxICON_INFORMATION wxICON_WARNING wxICON_ERROR wxID_OK wxFD_OPEN wxFD_SAVE wxDEFAULT wxNORMAL); use Wx::Event qw(EVT_BUTTON); use base 'Wx::Panel'; +my $last_dir; + sub new { my $class = shift; my ($parent) = @_; @@ -135,10 +137,11 @@ sub do_slice { Slic3r::Config->validate; # select input file - my $dialog = Wx::FileDialog->new($self, 'Choose a STL file to slice:', "", "", "STL files *.stl|*.stl;*.STL", wxFD_OPEN); + my $dialog = Wx::FileDialog->new($self, 'Choose a STL file to slice:', $last_dir || "", "", "STL files *.stl|*.stl;*.STL", wxFD_OPEN); return unless $dialog->ShowModal == wxID_OK; my ($input_file) = $dialog->GetPaths; my $input_file_basename = basename($input_file); + $last_dir = dirname($input_file); # show processbar dialog $process_dialog = Wx::ProgressDialog->new('Slicing...', "Processing $input_file_basename...", @@ -184,20 +187,23 @@ my $ini_wildcard = "INI files *.ini|*.ini;*.INI"; sub save_config { my $self = shift; - my $dlg = Wx::FileDialog->new($self, 'Save configuration as:', "", "config.ini", + my $dlg = Wx::FileDialog->new($self, 'Save configuration as:', $last_dir || "", "config.ini", $ini_wildcard, wxFD_SAVE); if ($dlg->ShowModal == wxID_OK) { - Slic3r::Config->save($dlg->GetPath); + my $file = $dlg->GetPath; + $last_dir = dirname($file); + Slic3r::Config->save($file); } } sub load_config { my $self = shift; - my $dlg = Wx::FileDialog->new($self, 'Select configuration to load:', "", "config.ini", + my $dlg = Wx::FileDialog->new($self, 'Select configuration to load:', $last_dir || "", "config.ini", $ini_wildcard, wxFD_OPEN); if ($dlg->ShowModal == wxID_OK) { my ($file) = $dlg->GetPaths; + $last_dir = dirname($file); eval { Slic3r::Config->load($file); };