diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index ab73a10e09..e9ad5399b9 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -93,7 +93,7 @@ sub OnInit { $Settings->{_}{background_processing} //= 1; } $Settings->{_}{version} = $Slic3r::VERSION; - &Wx::wxTheApp->save_settings; + $self->save_settings; # application frame Wx::Image::AddHandler(Wx::PNGHandler->new); @@ -114,8 +114,8 @@ sub OnInit { } $self->{mainframe}->config_wizard if $run_wizard; - &Wx::wxTheApp->check_version - if &Wx::wxTheApp->have_version_check + $self->check_version + if $self->have_version_check && ($Settings->{_}{version_check} // 1) && (!$Settings->{_}{last_version_check} || (time - $Settings->{_}{last_version_check}) >= 86400); @@ -240,7 +240,7 @@ sub check_version { Slic3r::GUI::show_info(undef, "You're using the latest version. No updates are available.") if $p{manual}; } $Settings->{_}{last_version_check} = time(); - &Wx::wxTheApp->save_settings; + $self->save_settings; } else { Slic3r::GUI::show_error(undef, "Failed to check for updates. Try later.") if $p{manual}; } diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 6c666d4503..2f5d3b37f4 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -5,7 +5,7 @@ use utf8; use List::Util qw(min); use Wx qw(:frame :bitmap :id :misc :notebook :panel :sizer :menu :dialog :filedialog - :font :icon); + :font :icon wxTheApp); use Wx::Event qw(EVT_CLOSE EVT_MENU); use base 'Wx::Frame'; @@ -128,7 +128,7 @@ sub _init_tabpanel { # so that user gets the config when switching to expert mode $tab->config->save(sprintf "$Slic3r::GUI::datadir/%s/%s.ini", $tab->name, 'Simple Mode'); $Slic3r::GUI::Settings->{presets}{$tab->name} = 'Simple Mode.ini'; - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; } $self->config->save($Slic3r::GUI::autosave) if $Slic3r::GUI::autosave; } @@ -241,15 +241,15 @@ sub _init_menubar { $helpMenu->AppendSeparator(); $helpMenu->Append(MI_WEBSITE, "Slic3r &Website", 'Open the Slic3r website in your browser'); my $versioncheck = $helpMenu->Append(MI_VERSIONCHECK, "Check for &Updates...", 'Check for new Slic3r versions'); - $versioncheck->Enable(&Wx::wxTheApp->have_version_check); + $versioncheck->Enable(wxTheApp->have_version_check); $helpMenu->Append(MI_DOCUMENTATION, "Slic3r &Manual", 'Open the Slic3r manual in your browser'); $helpMenu->AppendSeparator(); $helpMenu->Append(wxID_ABOUT, "&About Slic3r", 'Show about dialog'); EVT_MENU($self, MI_CONF_WIZARD, sub { $self->config_wizard }); EVT_MENU($self, MI_WEBSITE, sub { Wx::LaunchDefaultBrowser('http://slic3r.org/') }); - EVT_MENU($self, MI_VERSIONCHECK, sub { &Wx::wxTheApp->check_version(manual => 1) }); + EVT_MENU($self, MI_VERSIONCHECK, sub { wxTheApp->check_version(manual => 1) }); EVT_MENU($self, MI_DOCUMENTATION, sub { Wx::LaunchDefaultBrowser('http://manual.slic3r.org/') }); - EVT_MENU($self, wxID_ABOUT, sub { &Wx::wxTheApp->about }); + EVT_MENU($self, wxID_ABOUT, sub { wxTheApp->about }); } # menubar @@ -316,7 +316,7 @@ sub quick_slice { } my $input_file_basename = basename($input_file); $Slic3r::GUI::Settings->{recent}{skein_directory} = dirname($input_file); - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; my $sprint = Slic3r::Print::Simple->new( status_cb => sub { @@ -342,7 +342,7 @@ sub quick_slice { $output_file = $sprint->expanded_output_filepath; $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:', - &Wx::wxTheApp->output_path(dirname($output_file)), + wxTheApp->output_path(dirname($output_file)), basename($output_file), $params{export_svg} ? &Slic3r::GUI::FILE_WILDCARDS->{svg} : &Slic3r::GUI::FILE_WILDCARDS->{gcode}, wxFD_SAVE); if ($dlg->ShowModal != wxID_OK) { $dlg->Destroy; @@ -351,7 +351,7 @@ sub quick_slice { $output_file = $dlg->GetPath; $last_output_file = $output_file unless $params{export_svg}; $Slic3r::GUI::Settings->{_}{last_output_path} = dirname($output_file); - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; $dlg->Destroy; } @@ -377,7 +377,7 @@ sub quick_slice { undef $progress_dialog; my $message = "$input_file_basename was successfully sliced."; - &Wx::wxTheApp->notify($message); + wxTheApp->notify($message); Wx::MessageDialog->new($self, $message, 'Slicing Done!', wxOK | wxICON_INFORMATION)->ShowModal; }; @@ -447,7 +447,7 @@ sub export_config { if ($dlg->ShowModal == wxID_OK) { my $file = $dlg->GetPath; $Slic3r::GUI::Settings->{recent}{config_directory} = dirname($file); - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; $last_config = $file; $config->save($file); } @@ -468,7 +468,7 @@ sub load_config_file { $dlg->Destroy; } $Slic3r::GUI::Settings->{recent}{config_directory} = dirname($file); - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; $last_config = $file; for my $tab (values %{$self->{options_tabs}}) { $tab->load_config_file($file); @@ -491,7 +491,7 @@ sub export_configbundle { if ($dlg->ShowModal == wxID_OK) { my $file = $dlg->GetPath; $Slic3r::GUI::Settings->{recent}{config_directory} = dirname($file); - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; # leave default category empty to prevent the bundle from being parsed as a normal config file my $ini = { _ => {} }; @@ -503,7 +503,7 @@ sub export_configbundle { } foreach my $section (qw(print filament printer)) { - my %presets = &Wx::wxTheApp->presets($section); + my %presets = wxTheApp->presets($section); foreach my $preset_name (keys %presets) { my $config = Slic3r::Config->load($presets{$preset_name}); $ini->{"$section:$preset_name"} = $config->as_ini->{_}; @@ -526,18 +526,18 @@ sub load_configbundle { $dlg->Destroy; $Slic3r::GUI::Settings->{recent}{config_directory} = dirname($file); - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; # load .ini file my $ini = Slic3r::Config->read_ini($file); if ($ini->{settings}) { $Slic3r::GUI::Settings->{_}{$_} = $ini->{settings}{$_} for keys %{$ini->{settings}}; - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; } if ($ini->{presets}) { $Slic3r::GUI::Settings->{presets} = $ini->{presets}; - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; } if ($ini->{simple}) { my $config = Slic3r::Config->load_ini_hash($ini->{simple}); diff --git a/lib/Slic3r/GUI/OptionsGroup.pm b/lib/Slic3r/GUI/OptionsGroup.pm index b614ab9df1..31fda69d75 100644 --- a/lib/Slic3r/GUI/OptionsGroup.pm +++ b/lib/Slic3r/GUI/OptionsGroup.pm @@ -2,7 +2,7 @@ package Slic3r::GUI::OptionsGroup; use Moo; use List::Util qw(first); -use Wx qw(:combobox :font :misc :sizer :systemsettings :textctrl); +use Wx qw(:combobox :font :misc :sizer :systemsettings :textctrl wxTheApp); use Wx::Event qw(EVT_CHECKBOX EVT_COMBOBOX EVT_SPINCTRL EVT_TEXT EVT_KILL_FOCUS EVT_SLIDER); =head1 NAME @@ -208,7 +208,7 @@ sub _build_field { }; EVT_COMBOBOX($self->parent, $field, sub { # Without CallAfter, the field text is not populated on Windows. - &Wx::wxTheApp->CallAfter(sub { + wxTheApp->CallAfter(sub { $field->SetValue($opt->{values}[ $field->GetSelection ]); # set the text field to the selected value $self->_on_change($opt_key, $on_change); }); diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 70fef8b9bd..3f8cbc0bf0 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -9,7 +9,7 @@ use Slic3r::Geometry qw(X Y Z MIN MAX scale unscale); use threads::shared qw(shared_clone); use Thread::Semaphore; use Wx qw(:button :cursor :dialog :filedialog :keycode :icon :font :id :listctrl :misc - :panel :sizer :toolbar :window); + :panel :sizer :toolbar :window wxTheApp); use Wx::Event qw(EVT_BUTTON EVT_COMMAND EVT_KEY_DOWN EVT_LIST_ITEM_ACTIVATED EVT_LIST_ITEM_DESELECTED EVT_LIST_ITEM_SELECTED EVT_MOUSE_EVENTS EVT_PAINT EVT_TOOL EVT_CHOICE EVT_TIMER); @@ -352,7 +352,7 @@ sub on_select_preset { $Slic3r::GUI::Settings->{presets}{filament} = $choice->GetString($filament_presets[0]) . ".ini"; $Slic3r::GUI::Settings->{presets}{"filament_${_}"} = $choice->GetString($filament_presets[$_]) for 1 .. $#filament_presets; - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; return; } $self->GetFrame->{options_tabs}{$group}->select_preset($choice->GetSelection); @@ -385,7 +385,7 @@ sub filament_presets { sub add { my $self = shift; - my @input_files = &Wx::wxTheApp->open_model($self); + my @input_files = wxTheApp->open_model($self); $self->load_file($_) for @input_files; } @@ -394,7 +394,7 @@ sub load_file { my ($input_file) = @_; $Slic3r::GUI::Settings->{recent}{skein_directory} = dirname($input_file); - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; my $process_dialog = Wx::ProgressDialog->new('Loading…', "Processing input file…", 100, $self, 0); $process_dialog->Pulse; @@ -852,7 +852,7 @@ sub export_gcode { $self->{export_gcode_output_file} = $main::opt{output}; { my $default_output_file = $self->{print}->expanded_output_filepath($self->{export_gcode_output_file}); - my $dlg = Wx::FileDialog->new($self, 'Save G-code file as:', &Wx::wxTheApp->output_path(dirname($default_output_file)), + my $dlg = Wx::FileDialog->new($self, 'Save G-code file as:', wxTheApp->output_path(dirname($default_output_file)), basename($default_output_file), &Slic3r::GUI::FILE_WILDCARDS->{gcode}, wxFD_SAVE); if ($dlg->ShowModal != wxID_OK) { $dlg->Destroy; @@ -860,7 +860,7 @@ sub export_gcode { return; } $Slic3r::GUI::Settings->{_}{last_output_path} = dirname($dlg->GetPath); - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; $self->{export_gcode_output_file} = $Slic3r::GUI::MainFrame::last_output_file = $dlg->GetPath; $dlg->Destroy; } @@ -961,7 +961,7 @@ sub on_export_completed { } $self->{export_gcode_output_file} = undef; $self->statusbar->SetStatusText($message); - &Wx::wxTheApp->notify($message); + wxTheApp->notify($message); } sub export_stl { diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 46f37a4d7b..9a6f3cc009 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -4,7 +4,8 @@ use warnings; use utf8; use File::Basename qw(basename); -use Wx qw(:misc :sizer :treectrl :button wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG); +use Wx qw(:misc :sizer :treectrl :button wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG + wxTheApp); use Wx::Event qw(EVT_BUTTON EVT_TREE_ITEM_COLLAPSING EVT_TREE_SEL_CHANGED); use base 'Wx::Panel'; @@ -186,7 +187,7 @@ sub selection_changed { sub on_btn_load { my ($self, $is_modifier) = @_; - my @input_files = &Wx::wxTheApp->open_model($self); + my @input_files = wxTheApp->open_model($self); foreach my $input_file (@input_files) { my $model = eval { Slic3r::Model->read_from_file($input_file) }; if ($@) { diff --git a/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm b/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm index e4dd5958f0..175f006cde 100644 --- a/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm +++ b/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm @@ -4,7 +4,8 @@ use warnings; use utf8; use List::Util qw(first); -use Wx qw(:misc :sizer :button wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG); +use Wx qw(:misc :sizer :button wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG + wxTheApp); use Wx::Event qw(EVT_BUTTON EVT_LEFT_DOWN EVT_MENU); use base 'Wx::ScrolledWindow'; @@ -109,7 +110,7 @@ sub update_optgroup { EVT_BUTTON($self, $btn, sub { $self->{config}->erase($opt_key); $self->{on_change}->() if $self->{on_change}; - &Wx::wxTheApp->CallAfter(sub { $self->update_optgroup }); + wxTheApp->CallAfter(sub { $self->update_optgroup }); }); return $btn; }, diff --git a/lib/Slic3r/GUI/Preferences.pm b/lib/Slic3r/GUI/Preferences.pm index a5abc2414c..f9d36bbb55 100644 --- a/lib/Slic3r/GUI/Preferences.pm +++ b/lib/Slic3r/GUI/Preferences.pm @@ -1,5 +1,5 @@ package Slic3r::GUI::Preferences; -use Wx qw(:dialog :id :misc :sizer :systemsettings); +use Wx qw(:dialog :id :misc :sizer :systemsettings wxTheApp); use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER); use base 'Wx::Dialog'; @@ -28,7 +28,7 @@ sub new { label => 'Check for updates', tooltip => 'If this is enabled, Slic3r will check for updates daily and display a reminder if a newer version is available.', default => $Slic3r::GUI::Settings->{_}{version_check} // 1, - readonly => !&Wx::wxTheApp->have_version_check, + readonly => !wxTheApp->have_version_check, }, { opt_key => 'remember_output_path', @@ -77,7 +77,7 @@ sub _accept { } $Slic3r::GUI::Settings->{_}{$_} = $self->{values}{$_} for keys %{$self->{values}}; - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; $self->EndModal(wxID_OK); $self->Close; # needed on Linux diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 6de7b908b0..811621d4d8 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -5,7 +5,8 @@ use utf8; use File::Basename qw(basename); use List::Util qw(first); -use Wx qw(:bookctrl :dialog :keycode :icon :id :misc :panel :sizer :treectrl :window); +use Wx qw(:bookctrl :dialog :keycode :icon :id :misc :panel :sizer :treectrl :window + wxTheApp); use Wx::Event qw(EVT_BUTTON EVT_CHOICE EVT_KEY_DOWN EVT_TREE_SEL_CHANGED); use base 'Wx::Panel'; @@ -217,7 +218,7 @@ sub on_select_preset { $self->select_default_preset; } - &Wx::wxTheApp->save_settings; + wxTheApp->save_settings; } sub get_preset_config { @@ -347,7 +348,7 @@ sub load_presets { name => '- default -', }]; - my %presets = &Wx::wxTheApp->presets($self->name); + my %presets = wxTheApp->presets($self->name); foreach my $preset_name (sort keys %presets) { push @{$self->{presets}}, { name => $preset_name,