Preferences.pm 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # Preferences dialog, opens from Menu: File->Preferences
  2. package Slic3r::GUI::Preferences;
  3. use Wx qw(:dialog :id :misc :sizer :systemsettings wxTheApp);
  4. use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
  5. use base 'Wx::Dialog';
  6. sub new {
  7. my ($class, $parent) = @_;
  8. my $self = $class->SUPER::new($parent, -1, "Preferences", wxDefaultPosition, wxDefaultSize);
  9. $self->{values} = {};
  10. my $optgroup;
  11. $optgroup = Slic3r::GUI::OptionsGroup->new(
  12. parent => $self,
  13. title => 'General',
  14. on_change => sub {
  15. my ($opt_id) = @_;
  16. $self->{values}{$opt_id} = $optgroup->get_value($opt_id);
  17. },
  18. label_width => 200,
  19. );
  20. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  21. opt_id => 'version_check',
  22. type => 'bool',
  23. label => 'Check for updates',
  24. tooltip => 'If this is enabled, Slic3r will check for updates daily and display a reminder if a newer version is available.',
  25. default => $Slic3r::GUI::Settings->{_}{version_check} // 1,
  26. readonly => !wxTheApp->have_version_check,
  27. ));
  28. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  29. opt_id => 'remember_output_path',
  30. type => 'bool',
  31. label => 'Remember output directory',
  32. tooltip => 'If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files.',
  33. default => $Slic3r::GUI::Settings->{_}{remember_output_path},
  34. ));
  35. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  36. opt_id => 'autocenter',
  37. type => 'bool',
  38. label => 'Auto-center parts (x,y)',
  39. tooltip => 'If this is enabled, Slic3r will auto-center objects around the print bed center.',
  40. default => $Slic3r::GUI::Settings->{_}{autocenter},
  41. ));
  42. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  43. opt_id => 'autoalignz',
  44. type => 'bool',
  45. label => 'Auto-align parts (z=0)',
  46. tooltip => 'If this is enabled, Slic3r will auto-align objects z value to be on the print bed at z=0.',
  47. default => $Slic3r::GUI::Settings->{_}{autoalignz},
  48. ));
  49. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  50. opt_id => 'invert_zoom',
  51. type => 'bool',
  52. label => 'Invert zoom in previews',
  53. tooltip => 'If this is enabled, Slic3r will invert the direction of mouse-wheel zoom in preview panes.',
  54. default => $Slic3r::GUI::Settings->{_}{invert_zoom},
  55. ));
  56. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  57. opt_id => 'background_processing',
  58. type => 'bool',
  59. label => 'Background processing',
  60. 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.',
  61. default => $Slic3r::GUI::Settings->{_}{background_processing},
  62. readonly => !$Slic3r::have_threads,
  63. ));
  64. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  65. opt_id => 'threads',
  66. type => 'i',
  67. label => 'Threads',
  68. tooltip => $Slic3r::Config::Options->{threads}{tooltip},
  69. default => $Slic3r::GUI::Settings->{_}{threads},
  70. ));
  71. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  72. opt_id => 'tabbed_preset_editors',
  73. type => 'bool',
  74. label => 'Display profile editors as tabs',
  75. tooltip => 'When opening a profile editor, it will be shown in a dialog or in a tab according to this option.',
  76. default => $Slic3r::GUI::Settings->{_}{tabbed_preset_editors},
  77. ));
  78. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  79. opt_id => 'show_host',
  80. type => 'bool',
  81. label => 'Show Controller Tab (requires restart)',
  82. tooltip => 'Shows/Hides the Controller Tab. Requires a restart of Slic3r.',
  83. default => $Slic3r::GUI::Settings->{_}{show_host},
  84. ));
  85. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
  86. opt_id => 'nudge_val',
  87. type => 's',
  88. label => '2D plater nudge value',
  89. tooltip => 'In 2D plater, Move objects using keyboard by nudge value of',
  90. default => $Slic3r::GUI::Settings->{_}{nudge_val},
  91. ));
  92. my $sizer = Wx::BoxSizer->new(wxVERTICAL);
  93. $sizer->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
  94. my $buttons = $self->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
  95. EVT_BUTTON($self, wxID_OK, sub { $self->_accept });
  96. $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
  97. $self->SetSizer($sizer);
  98. $sizer->SetSizeHints($self);
  99. return $self;
  100. }
  101. sub _accept {
  102. my $self = shift;
  103. if ($self->{values}{mode}) {
  104. Slic3r::GUI::warning_catcher($self)->("You need to restart Slic3r to make the changes effective.");
  105. }
  106. $Slic3r::GUI::Settings->{_}{$_} = $self->{values}{$_} for keys %{$self->{values}};
  107. wxTheApp->save_settings;
  108. $self->EndModal(wxID_OK);
  109. $self->Close; # needed on Linux
  110. }
  111. 1;