|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Application configuration page. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from .ConfigurationPageBase import ConfigurationPageBase |
|
13 from .Ui_ApplicationPage import Ui_ApplicationPage |
|
14 |
|
15 import Preferences |
|
16 import Globals |
|
17 |
|
18 |
|
19 class ApplicationPage(ConfigurationPageBase, Ui_ApplicationPage): |
|
20 """ |
|
21 Class implementing the Application configuration page. |
|
22 """ |
|
23 def __init__(self): |
|
24 """ |
|
25 Constructor |
|
26 """ |
|
27 super(ApplicationPage, self).__init__() |
|
28 self.setupUi(self) |
|
29 self.setObjectName("ApplicationPage") |
|
30 |
|
31 self.backgroundServicesLabel.setText(self.tr( |
|
32 "eric is using background services for certain things like" |
|
33 " syntax checks or code style checks. Per default the number" |
|
34 " of processes to use for these checks is determined" |
|
35 " automatically based on the number of CPUs. Please note, that" |
|
36 " this is an advanced setting." |
|
37 )) |
|
38 |
|
39 # set initial values |
|
40 self.singleApplicationCheckBox.setChecked( |
|
41 Preferences.getUI("SingleApplicationMode")) |
|
42 self.splashScreenCheckBox.setChecked( |
|
43 Preferences.getUI("ShowSplash")) |
|
44 self.crashSessionEnabledCheckBox.setChecked( |
|
45 Preferences.getUI("CrashSessionEnabled")) |
|
46 self.globalMenuCheckBox.setChecked( |
|
47 Preferences.getUI("UseNativeMenuBar")) |
|
48 if not Globals.isLinuxPlatform(): |
|
49 self.globalMenuCheckBox.hide() |
|
50 |
|
51 openOnStartup = Preferences.getUI("OpenOnStartup") |
|
52 if openOnStartup == 0: |
|
53 self.noOpenRadioButton.setChecked(True) |
|
54 elif openOnStartup == 1: |
|
55 self.lastFileRadioButton.setChecked(True) |
|
56 elif openOnStartup == 2: |
|
57 self.lastProjectRadioButton.setChecked(True) |
|
58 elif openOnStartup == 3: |
|
59 self.lastMultiprojectRadioButton.setChecked(True) |
|
60 elif openOnStartup == 4: |
|
61 self.globalSessionRadioButton.setChecked(True) |
|
62 self.openCrashSessionCheckBox.setChecked( |
|
63 Preferences.getUI("OpenCrashSessionOnStartup")) |
|
64 |
|
65 period = Preferences.getUI("PerformVersionCheck") |
|
66 if period == 0: |
|
67 self.noCheckRadioButton.setChecked(True) |
|
68 elif period == 1: |
|
69 self.alwaysCheckRadioButton.setChecked(True) |
|
70 elif period == 2: |
|
71 self.dailyCheckRadioButton.setChecked(True) |
|
72 elif period == 3: |
|
73 self.weeklyCheckRadioButton.setChecked(True) |
|
74 elif period == 4: |
|
75 self.monthlyCheckRadioButton.setChecked(True) |
|
76 |
|
77 self.systemEmailClientCheckBox.setChecked( |
|
78 Preferences.getUser("UseSystemEmailClient")) |
|
79 |
|
80 self.errorlogCheckBox.setChecked( |
|
81 Preferences.getUI("CheckErrorLog")) |
|
82 |
|
83 self.intervalSpinBox.setValue( |
|
84 Preferences.getUI("KeyboardInputInterval")) |
|
85 |
|
86 self.backgroundServicesSpinBox.setValue( |
|
87 Preferences.getUI("BackgroundServiceProcesses")) |
|
88 |
|
89 def save(self): |
|
90 """ |
|
91 Public slot to save the Application configuration. |
|
92 """ |
|
93 Preferences.setUI( |
|
94 "SingleApplicationMode", |
|
95 self.singleApplicationCheckBox.isChecked()) |
|
96 Preferences.setUI( |
|
97 "ShowSplash", |
|
98 self.splashScreenCheckBox.isChecked()) |
|
99 Preferences.setUI( |
|
100 "CrashSessionEnabled", |
|
101 self.crashSessionEnabledCheckBox.isChecked()) |
|
102 if Globals.isLinuxPlatform(): |
|
103 Preferences.setUI( |
|
104 "UseNativeMenuBar", |
|
105 self.globalMenuCheckBox.isChecked()) |
|
106 |
|
107 if self.noOpenRadioButton.isChecked(): |
|
108 openOnStartup = 0 |
|
109 elif self.lastFileRadioButton.isChecked(): |
|
110 openOnStartup = 1 |
|
111 elif self.lastProjectRadioButton.isChecked(): |
|
112 openOnStartup = 2 |
|
113 elif self.lastMultiprojectRadioButton.isChecked(): |
|
114 openOnStartup = 3 |
|
115 elif self.globalSessionRadioButton.isChecked(): |
|
116 openOnStartup = 4 |
|
117 Preferences.setUI("OpenOnStartup", openOnStartup) |
|
118 Preferences.setUI("OpenCrashSessionOnStartup", |
|
119 self.openCrashSessionCheckBox.isChecked()) |
|
120 |
|
121 if self.noCheckRadioButton.isChecked(): |
|
122 period = 0 |
|
123 elif self.alwaysCheckRadioButton.isChecked(): |
|
124 period = 1 |
|
125 elif self.dailyCheckRadioButton.isChecked(): |
|
126 period = 2 |
|
127 elif self.weeklyCheckRadioButton.isChecked(): |
|
128 period = 3 |
|
129 elif self.monthlyCheckRadioButton.isChecked(): |
|
130 period = 4 |
|
131 Preferences.setUI("PerformVersionCheck", period) |
|
132 |
|
133 Preferences.setUser( |
|
134 "UseSystemEmailClient", |
|
135 self.systemEmailClientCheckBox.isChecked()) |
|
136 |
|
137 Preferences.setUI( |
|
138 "CheckErrorLog", |
|
139 self.errorlogCheckBox.isChecked()) |
|
140 |
|
141 Preferences.setUI( |
|
142 "KeyboardInputInterval", |
|
143 self.intervalSpinBox.value()) |
|
144 |
|
145 Preferences.setUI( |
|
146 "BackgroundServiceProcesses", |
|
147 self.backgroundServicesSpinBox.value()) |
|
148 |
|
149 |
|
150 def create(dlg): |
|
151 """ |
|
152 Module function to create the configuration page. |
|
153 |
|
154 @param dlg reference to the configuration dialog |
|
155 @return reference to the instantiated page (ConfigurationPageBase) |
|
156 """ |
|
157 page = ApplicationPage() |
|
158 return page |