mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-04 20:54:03 +08:00
Remember last opened directory. #106
This commit is contained in:
parent
b92ba67272
commit
c957c27367
@ -3,12 +3,14 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
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
|
use Wx qw(:sizer :progressdialog wxOK wxICON_INFORMATION wxICON_WARNING wxICON_ERROR wxID_OK wxFD_OPEN
|
||||||
wxFD_SAVE wxDEFAULT wxNORMAL);
|
wxFD_SAVE wxDEFAULT wxNORMAL);
|
||||||
use Wx::Event qw(EVT_BUTTON);
|
use Wx::Event qw(EVT_BUTTON);
|
||||||
use base 'Wx::Panel';
|
use base 'Wx::Panel';
|
||||||
|
|
||||||
|
my $last_dir;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my ($parent) = @_;
|
my ($parent) = @_;
|
||||||
@ -135,10 +137,11 @@ sub do_slice {
|
|||||||
Slic3r::Config->validate;
|
Slic3r::Config->validate;
|
||||||
|
|
||||||
# select input file
|
# 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;
|
return unless $dialog->ShowModal == wxID_OK;
|
||||||
my ($input_file) = $dialog->GetPaths;
|
my ($input_file) = $dialog->GetPaths;
|
||||||
my $input_file_basename = basename($input_file);
|
my $input_file_basename = basename($input_file);
|
||||||
|
$last_dir = dirname($input_file);
|
||||||
|
|
||||||
# show processbar dialog
|
# show processbar dialog
|
||||||
$process_dialog = Wx::ProgressDialog->new('Slicing...', "Processing $input_file_basename...",
|
$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 {
|
sub save_config {
|
||||||
my $self = shift;
|
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);
|
$ini_wildcard, wxFD_SAVE);
|
||||||
if ($dlg->ShowModal == wxID_OK) {
|
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 {
|
sub load_config {
|
||||||
my $self = shift;
|
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);
|
$ini_wildcard, wxFD_OPEN);
|
||||||
if ($dlg->ShowModal == wxID_OK) {
|
if ($dlg->ShowModal == wxID_OK) {
|
||||||
my ($file) = $dlg->GetPaths;
|
my ($file) = $dlg->GetPaths;
|
||||||
|
$last_dir = dirname($file);
|
||||||
eval {
|
eval {
|
||||||
Slic3r::Config->load($file);
|
Slic3r::Config->load($file);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user