Preferences.pm 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Preferences dialog, opens from Menu: File->Preferences
  2. package Slic3r::GUI::Preferences;
  3. use List::Util qw(any);
  4. use Wx qw(:dialog :id :misc :sizer :systemsettings wxTheApp);
  5. use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
  6. use base 'Wx::Dialog';
  7. sub new {
  8. my ($class, $parent) = @_;
  9. my $self = $class->SUPER::new($parent, -1, "Preferences", wxDefaultPosition, wxDefaultSize);
  10. $self->{values} = {};
  11. my $optgroup;
  12. $optgroup = Slic3r::GUI::OptionsGroup->new(
  13. parent => $self,
  14. title => 'General',
  15. on_change => sub {
  16. my ($opt_id) = @_;
  17. $self->{values}{$opt_id} = $optgroup->get_value($opt_id);
  18. },
  19. label_width => 200,
  20. );
  21. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # version_check
  22. opt_id => 'version_check',
  23. type => 'bool',
  24. label => 'Check for updates',
  25. tooltip => 'If this is enabled, Slic3r will check for updates daily and display a reminder if a newer version is available.',
  26. default => $Slic3r::GUI::Settings->{_}{version_check} // 1,
  27. readonly => !wxTheApp->have_version_check,
  28. ));
  29. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # remember_output_path
  30. opt_id => 'remember_output_path',
  31. type => 'bool',
  32. label => 'Remember output directory',
  33. tooltip => 'If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files.',
  34. default => $Slic3r::GUI::Settings->{_}{remember_output_path},
  35. ));
  36. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # autocenter
  37. opt_id => 'autocenter',
  38. type => 'bool',
  39. label => 'Auto-center parts (x,y)',
  40. tooltip => 'If this is enabled, Slic3r will auto-center objects around the print bed center.',
  41. default => $Slic3r::GUI::Settings->{_}{autocenter},
  42. ));
  43. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # autoalignz
  44. opt_id => 'autoalignz',
  45. type => 'bool',
  46. label => 'Auto-align parts (z=0)',
  47. tooltip => 'If this is enabled, Slic3r will auto-align objects z value to be on the print bed at z=0.',
  48. default => $Slic3r::GUI::Settings->{_}{autoalignz},
  49. ));
  50. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # invert_zoom
  51. opt_id => 'invert_zoom',
  52. type => 'bool',
  53. label => 'Invert zoom in previews',
  54. tooltip => 'If this is enabled, Slic3r will invert the direction of mouse-wheel zoom in preview panes.',
  55. default => $Slic3r::GUI::Settings->{_}{invert_zoom},
  56. ));
  57. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # background_processing
  58. opt_id => 'background_processing',
  59. type => 'bool',
  60. label => 'Background processing',
  61. 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.',
  62. default => $Slic3r::GUI::Settings->{_}{background_processing},
  63. readonly => !$Slic3r::have_threads,
  64. ));
  65. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # threads
  66. opt_id => 'threads',
  67. type => 'i',
  68. label => 'Threads',
  69. tooltip => $Slic3r::Config::Options->{threads}{tooltip},
  70. default => $Slic3r::GUI::Settings->{_}{threads},
  71. ));
  72. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # tabbed_preset_editors
  73. opt_id => 'tabbed_preset_editors',
  74. type => 'bool',
  75. label => 'Display profile editors as tabs',
  76. tooltip => 'When opening a profile editor, it will be shown in a dialog or in a tab according to this option.',
  77. default => $Slic3r::GUI::Settings->{_}{tabbed_preset_editors},
  78. ));
  79. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # show_host
  80. opt_id => 'show_host',
  81. type => 'bool',
  82. label => 'Show Controller Tab (requires restart)',
  83. tooltip => 'Shows/Hides the Controller Tab. (Restart of Slic3r required.)',
  84. default => $Slic3r::GUI::Settings->{_}{show_host},
  85. ));
  86. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # nudge_val
  87. opt_id => 'nudge_val',
  88. type => 's',
  89. label => '2D plater nudge value',
  90. tooltip => 'In 2D plater, Move objects using keyboard by nudge value of',
  91. default => $Slic3r::GUI::Settings->{_}{nudge_val},
  92. ));
  93. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # reload hide dialog
  94. opt_id => 'reload_hide_dialog',
  95. type => 'bool',
  96. label => 'Hide Dialog on Reload',
  97. tooltip => 'When checked, the dialog on reloading files with added parts & modifiers is suppressed. The reload is performed according to the option given in \'Default Reload Behavior\'',
  98. default => $Slic3r::GUI::Settings->{_}{reload_hide_dialog},
  99. ));
  100. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # default reload behavior
  101. opt_id => 'reload_behavior',
  102. type => 'select',
  103. label => 'Default Reload Behavior',
  104. tooltip => 'Choose the default behavior of the \'Reload from disk\' function regarding additional parts and modifiers.',
  105. labels => ['Reload all','Reload main, copy added','Reload main, discard added'],
  106. values => [0, 1, 2],
  107. default => $Slic3r::GUI::Settings->{_}{reload_behavior},
  108. width => 180,
  109. ));
  110. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # Extended GUI - Context and/or Toolbar
  111. opt_id => 'rotation_controls',
  112. type => 'select',
  113. label => 'Rotation controls in toolbar',
  114. tooltip => 'What rotation controls to show in the toolbar. (Restart of Slic3r required.)',
  115. labels => ['Z only', 'X,Y,Z', 'X,Y,Z (big buttons)'],
  116. values => ['z', 'xyz', 'xyz-big'],
  117. default => $Slic3r::GUI::Settings->{_}{rotation_controls},
  118. width => 180,
  119. ));
  120. $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( # colorscheme
  121. opt_id => 'colorscheme',
  122. type => 'select',
  123. label => 'Color Scheme',
  124. tooltip => 'Choose between color schemes. (Restart of Slic3r required.)',
  125. labels => ['Default','Solarized'], # add more schemes, if you want in ColorScheme.pm.
  126. values => ['getDefault','getSolarized'], # add more schemes, if you want - those are the names of the corresponding function in ColorScheme.pm.
  127. default => $Slic3r::GUI::Settings->{_}{colorscheme},
  128. width => 180,
  129. ));
  130. my $sizer = Wx::BoxSizer->new(wxVERTICAL);
  131. $sizer->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
  132. my $buttons = $self->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
  133. EVT_BUTTON($self, wxID_OK, sub { $self->_accept });
  134. $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
  135. $self->SetSizer($sizer);
  136. $sizer->SetSizeHints($self);
  137. return $self;
  138. }
  139. sub _accept {
  140. my $self = shift;
  141. if (any { exists $self->{values}{$_} } qw(show_host rotation_controls colorscheme)) {
  142. Slic3r::GUI::warning_catcher($self)->("You need to restart Slic3r to make the changes effective.");
  143. }
  144. $Slic3r::GUI::Settings->{_}{$_} = $self->{values}{$_} for keys %{$self->{values}};
  145. wxTheApp->save_settings;
  146. $self->EndModal(wxID_OK);
  147. $self->Close; # needed on Linux
  148. }
  149. 1;