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