2016-09-14 09:22:41 +00:00
# Preferences dialog, opens from Menu: File->Preferences
2013-01-02 19:30:48 +00:00
package Slic3r::GUI::Preferences ;
2014-06-14 17:59:59 +00:00
use Wx qw( :dialog :id :misc :sizer :systemsettings wxTheApp ) ;
2013-01-02 19:30:48 +00:00
use Wx::Event qw( EVT_BUTTON EVT_TEXT_ENTER ) ;
use base 'Wx::Dialog' ;
sub new {
2014-07-01 14:40:56 +00:00
my ( $ class , $ parent ) = @ _ ;
2014-12-30 12:24:00 +00:00
my $ self = $ class - > SUPER:: new ( $ parent , - 1 , "Preferences" , wxDefaultPosition , wxDefaultSize ) ;
2014-07-01 14:40:56 +00:00
$ self - > { values } = { } ;
2013-01-02 19:30:48 +00:00
2017-11-02 15:21:34 +00:00
my $ app_config = wxTheApp - > { app_config } ;
2014-07-01 14:40:56 +00:00
my $ optgroup ;
$ optgroup = Slic3r::GUI::OptionsGroup - > new (
2013-01-02 19:30:48 +00:00
parent = > $ self ,
title = > 'General' ,
2014-07-01 14:40:56 +00:00
on_change = > sub {
my ( $ opt_id ) = @ _ ;
$ self - > { values } { $ opt_id } = $ optgroup - > get_value ( $ opt_id ) ;
} ,
2014-12-30 12:24:00 +00:00
label_width = > 200 ,
2013-01-02 19:30:48 +00:00
) ;
2017-06-12 12:25:35 +00:00
# $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
# opt_id => 'version_check',
# type => 'bool',
# 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.',
2017-11-02 15:21:34 +00:00
# default => $app_config->get("version_check") // 1,
2017-06-12 12:25:35 +00:00
# readonly => !wxTheApp->have_version_check,
# ));
2014-07-01 14:40:56 +00:00
$ optgroup - > append_single_option_line ( Slic3r::GUI::OptionsGroup::Option - > new (
opt_id = > '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.' ,
2017-11-02 15:21:34 +00:00
default = > $ app_config - > get ( "remember_output_path" ) ,
2014-07-01 14:40:56 +00:00
) ) ;
$ optgroup - > append_single_option_line ( Slic3r::GUI::OptionsGroup::Option - > new (
opt_id = > 'autocenter' ,
type = > 'bool' ,
label = > 'Auto-center parts' ,
2014-07-01 16:19:13 +00:00
tooltip = > 'If this is enabled, Slic3r will auto-center objects around the print bed center.' ,
2017-11-02 15:21:34 +00:00
default = > $ app_config - > get ( "autocenter" ) ,
2014-07-01 14:40:56 +00:00
) ) ;
$ optgroup - > append_single_option_line ( Slic3r::GUI::OptionsGroup::Option - > new (
opt_id = > 'background_processing' ,
type = > 'bool' ,
label = > 'Background processing' ,
tooltip = > 'If this is enabled, Slic3r will pre-process objects as soon as they\'re loaded in order to save time when exporting G-code.' ,
2017-11-02 15:21:34 +00:00
default = > $ app_config - > get ( "background_processing" ) ,
2014-07-01 14:40:56 +00:00
) ) ;
2016-05-16 21:40:24 +00:00
$ optgroup - > append_single_option_line ( Slic3r::GUI::OptionsGroup::Option - > new (
opt_id = > 'no_controller' ,
type = > 'bool' ,
label = > 'Disable USB/serial connection' ,
tooltip = > 'Disable communication with the printer over a serial / USB cable. This simplifies the user interface in case the printer is never attached to the computer.' ,
2017-11-02 15:21:34 +00:00
default = > $ app_config - > get ( "no_controller" ) ,
2016-05-16 21:40:24 +00:00
) ) ;
2016-10-24 14:07:36 +00:00
$ optgroup - > append_single_option_line ( Slic3r::GUI::OptionsGroup::Option - > new (
opt_id = > 'no_defaults' ,
type = > 'bool' ,
label = > 'Suppress "- default -" presets' ,
tooltip = > 'Suppress "- default -" presets in the Print / Filament / Printer selections once there are any other valid presets available.' ,
2017-11-02 15:21:34 +00:00
default = > $ app_config - > get ( "no_defaults" ) ,
2016-10-24 14:07:36 +00:00
) ) ;
2017-11-10 16:27:05 +00:00
$ optgroup - > append_single_option_line ( Slic3r::GUI::OptionsGroup::Option - > new (
opt_id = > 'show_incompatible_presets' ,
type = > 'bool' ,
label = > 'Show incompatible print and filament presets' ,
tooltip = > 'When checked, the print and filament presets are shown in the preset editor even ' .
'if they are marked as incompatible with the active printer' ,
default = > $ app_config - > get ( "show_incompatible_presets" ) ,
) ) ;
2017-12-11 17:00:51 +00:00
$ optgroup - > append_single_option_line ( Slic3r::GUI::OptionsGroup::Option - > new (
opt_id = > 'use_legacy_opengl' ,
type = > 'bool' ,
label = > 'Use legacy OpenGL 1.1 rendering' ,
2017-12-12 19:47:36 +00:00
tooltip = > 'If you have rendering issues caused by a buggy OpenGL 2.0 driver, you may try to check this checkbox. This will disable the layer height editing and anti aliasing, so it is likely better to upgrade your graphics driver.' ,
2017-12-11 17:00:51 +00:00
default = > $ app_config - > get ( "use_legacy_opengl" ) ,
) ) ;
2014-07-01 14:40:56 +00:00
2013-01-02 19:30:48 +00:00
my $ sizer = Wx::BoxSizer - > new ( wxVERTICAL ) ;
$ sizer - > Add ( $ optgroup - > sizer , 0 , wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT , 10 ) ;
my $ buttons = $ self - > CreateStdDialogButtonSizer ( wxOK | wxCANCEL ) ;
2013-01-03 14:49:20 +00:00
EVT_BUTTON ( $ self , wxID_OK , sub { $ self - > _accept } ) ;
2013-01-02 19:30:48 +00:00
$ sizer - > Add ( $ buttons , 0 , wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT , 10 ) ;
$ self - > SetSizer ( $ sizer ) ;
$ sizer - > SetSizeHints ( $ self ) ;
return $ self ;
}
2013-01-03 14:49:20 +00:00
sub _accept {
2017-11-02 15:21:34 +00:00
my ( $ self ) = @ _ ;
2013-01-03 14:49:20 +00:00
2017-10-26 15:17:39 +00:00
if ( defined ( $ self - > { values } { no_controller } ) ||
2017-12-11 17:00:51 +00:00
defined ( $ self - > { values } { no_defaults } ) ||
defined ( $ self - > { values } { use_legacy_opengl } ) ) {
2013-01-03 14:49:20 +00:00
Slic3r::GUI:: warning_catcher ( $ self ) - > ( "You need to restart Slic3r to make the changes effective." ) ;
}
2017-11-02 15:21:34 +00:00
my $ app_config = wxTheApp - > { app_config } ;
$ app_config - > set ( $ _ , $ self - > { values } { $ _ } ) for keys % { $ self - > { values } } ;
2013-11-11 21:02:12 +00:00
$ self - > EndModal ( wxID_OK ) ;
$ self - > Close ; # needed on Linux
2016-10-25 11:24:42 +00:00
# Nothify the UI to update itself from the ini file.
wxTheApp - > update_ui_from_settings ;
2013-01-03 14:49:20 +00:00
}
2013-01-02 19:30:48 +00:00
1 ;