~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to lib/Slic3r/GUI/Preferences.pm

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
ImportĀ upstreamĀ versionĀ 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Slic3r::GUI::Preferences;
 
2
use Wx qw(:dialog :id :misc :sizer :systemsettings);
 
3
use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
 
4
use base 'Wx::Dialog';
 
5
 
 
6
sub new {
 
7
    my $class = shift;
 
8
    my ($parent, %params) = @_;
 
9
    my $self = $class->SUPER::new($parent, -1, "Preferences", wxDefaultPosition, [500,200]);
 
10
    $self->{values};
 
11
    
 
12
    my $optgroup = Slic3r::GUI::OptionsGroup->new(
 
13
        parent  => $self,
 
14
        title   => 'General',
 
15
        options => [
 
16
            {
 
17
                opt_key     => 'mode',
 
18
                type        => 'select',
 
19
                label       => 'Mode',
 
20
                tooltip     => 'Choose between a simpler, basic mode and an expert mode with more options and more complicated interface.',
 
21
                labels      => ['Simple','Expert'],
 
22
                values      => ['simple','expert'],
 
23
                default     => $Slic3r::GUI::Settings->{_}{mode},
 
24
            },
 
25
            {
 
26
                opt_key     => 'version_check',
 
27
                type        => 'bool',
 
28
                label       => 'Check for updates',
 
29
                tooltip     => 'If this is enabled, Slic3r will check for updates daily and display a reminder if a newer version is available.',
 
30
                default     => $Slic3r::GUI::Settings->{_}{version_check} // 1,
 
31
                readonly    => !Slic3r::GUI->have_version_check,
 
32
            },
 
33
            {
 
34
                opt_key     => 'remember_output_path',
 
35
                type        => 'bool',
 
36
                label       => 'Remember output directory',
 
37
                tooltip     => 'If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files.',
 
38
                default     => $Slic3r::GUI::Settings->{_}{remember_output_path},
 
39
            },
 
40
            {
 
41
                opt_key     => 'autocenter',
 
42
                type        => 'bool',
 
43
                label       => 'Auto-center parts',
 
44
                tooltip     => 'If this is enabled, Slic3r will auto-center objects around the configured print center.',
 
45
                default     => $Slic3r::GUI::Settings->{_}{autocenter},
 
46
            },
 
47
        ],
 
48
        on_change => sub { $self->{values}{$_[0]} = $_[1] },
 
49
        label_width => 100,
 
50
    );
 
51
    my $sizer = Wx::BoxSizer->new(wxVERTICAL);
 
52
    $sizer->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
 
53
    
 
54
    my $buttons = $self->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
 
55
    EVT_BUTTON($self, wxID_OK, sub { $self->_accept });
 
56
    $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
 
57
    
 
58
    $self->SetSizer($sizer);
 
59
    $sizer->SetSizeHints($self);
 
60
    
 
61
    return $self;
 
62
}
 
63
 
 
64
sub _accept {
 
65
    my $self = shift;
 
66
    
 
67
    if ($self->{values}{mode}) {
 
68
        Slic3r::GUI::warning_catcher($self)->("You need to restart Slic3r to make the changes effective.");
 
69
    }
 
70
    
 
71
    $Slic3r::GUI::Settings->{_}{$_} = $self->{values}{$_} for keys %{$self->{values}};
 
72
    Slic3r::GUI->save_settings;
 
73
    
 
74
    $self->EndModal(wxID_OK);
 
75
    $self->Close;  # needed on Linux
 
76
}
 
77
 
 
78
1;