src/eric7/Preferences/ConfigurationPages/ApplicationPage.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 9170
46523f488d07
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Application configuration page.
8 """
9
10 import multiprocessing
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().__init__()
28 self.setupUi(self)
29 self.setObjectName("ApplicationPage")
30
31 self.backgroundServicesLabel.setText(self.tr(
32 "<p>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.</p>"
37 "<p>Available CPUs: <b>{0}</b></p>"
38 ).format(multiprocessing.cpu_count()))
39
40 self.msgSeverityComboBox.addItem(self.tr("Debug"), 0)
41 self.msgSeverityComboBox.addItem(self.tr("Warning"), 1)
42 self.msgSeverityComboBox.addItem(self.tr("Critical"), 2)
43 self.msgSeverityComboBox.addItem(self.tr("Fatal Error"), 3)
44
45 # set initial values
46 self.singleApplicationCheckBox.setChecked(
47 Preferences.getUI("SingleApplicationMode"))
48 self.splashScreenCheckBox.setChecked(
49 Preferences.getUI("ShowSplash"))
50 self.crashSessionEnabledCheckBox.setChecked(
51 Preferences.getUI("CrashSessionEnabled"))
52 self.globalMenuCheckBox.setChecked(
53 Preferences.getUI("UseNativeMenuBar"))
54 if not Globals.isLinuxPlatform():
55 self.globalMenuCheckBox.hide()
56
57 openOnStartup = Preferences.getUI("OpenOnStartup")
58 if openOnStartup == 0:
59 self.noOpenRadioButton.setChecked(True)
60 elif openOnStartup == 1:
61 self.lastFileRadioButton.setChecked(True)
62 elif openOnStartup == 2:
63 self.lastProjectRadioButton.setChecked(True)
64 elif openOnStartup == 3:
65 self.lastMultiprojectRadioButton.setChecked(True)
66 elif openOnStartup == 4:
67 self.globalSessionRadioButton.setChecked(True)
68 self.openCrashSessionCheckBox.setChecked(
69 Preferences.getUI("OpenCrashSessionOnStartup"))
70
71 period = Preferences.getUI("PerformVersionCheck")
72 if period == 0:
73 self.noCheckRadioButton.setChecked(True)
74 elif period == 1:
75 self.alwaysCheckRadioButton.setChecked(True)
76 elif period == 2:
77 self.dailyCheckRadioButton.setChecked(True)
78 elif period == 3:
79 self.weeklyCheckRadioButton.setChecked(True)
80 elif period == 4:
81 self.monthlyCheckRadioButton.setChecked(True)
82
83 self.systemEmailClientCheckBox.setChecked(
84 Preferences.getUser("UseSystemEmailClient"))
85
86 self.errorlogCheckBox.setChecked(
87 Preferences.getUI("CheckErrorLog"))
88 severityIndex = self.msgSeverityComboBox.findData(
89 Preferences.getUI("MinimumMessageTypeSeverity"))
90 self.msgSeverityComboBox.setCurrentIndex(severityIndex)
91
92 self.intervalSpinBox.setValue(
93 Preferences.getUI("KeyboardInputInterval"))
94
95 self.backgroundServicesSpinBox.setValue(
96 Preferences.getUI("BackgroundServiceProcesses"))
97
98 self.upgraderDelaySpinBox.setValue(
99 Preferences.getUI("UpgraderDelay"))
100
101 def save(self):
102 """
103 Public slot to save the Application configuration.
104 """
105 Preferences.setUI(
106 "SingleApplicationMode",
107 self.singleApplicationCheckBox.isChecked())
108 Preferences.setUI(
109 "ShowSplash",
110 self.splashScreenCheckBox.isChecked())
111 Preferences.setUI(
112 "CrashSessionEnabled",
113 self.crashSessionEnabledCheckBox.isChecked())
114 if Globals.isLinuxPlatform():
115 Preferences.setUI(
116 "UseNativeMenuBar",
117 self.globalMenuCheckBox.isChecked())
118
119 if self.noOpenRadioButton.isChecked():
120 openOnStartup = 0
121 elif self.lastFileRadioButton.isChecked():
122 openOnStartup = 1
123 elif self.lastProjectRadioButton.isChecked():
124 openOnStartup = 2
125 elif self.lastMultiprojectRadioButton.isChecked():
126 openOnStartup = 3
127 elif self.globalSessionRadioButton.isChecked():
128 openOnStartup = 4
129 Preferences.setUI("OpenOnStartup", openOnStartup)
130 Preferences.setUI("OpenCrashSessionOnStartup",
131 self.openCrashSessionCheckBox.isChecked())
132
133 if self.noCheckRadioButton.isChecked():
134 period = 0
135 elif self.alwaysCheckRadioButton.isChecked():
136 period = 1
137 elif self.dailyCheckRadioButton.isChecked():
138 period = 2
139 elif self.weeklyCheckRadioButton.isChecked():
140 period = 3
141 elif self.monthlyCheckRadioButton.isChecked():
142 period = 4
143 Preferences.setUI("PerformVersionCheck", period)
144
145 Preferences.setUser(
146 "UseSystemEmailClient",
147 self.systemEmailClientCheckBox.isChecked())
148
149 Preferences.setUI(
150 "CheckErrorLog",
151 self.errorlogCheckBox.isChecked())
152 Preferences.setUI(
153 "MinimumMessageTypeSeverity",
154 self.msgSeverityComboBox.currentData())
155
156 Preferences.setUI(
157 "KeyboardInputInterval",
158 self.intervalSpinBox.value())
159
160 Preferences.setUI(
161 "BackgroundServiceProcesses",
162 self.backgroundServicesSpinBox.value())
163
164 Preferences.setUI(
165 "UpgraderDelay",
166 self.upgraderDelaySpinBox.value())
167
168
169 def create(dlg):
170 """
171 Module function to create the configuration page.
172
173 @param dlg reference to the configuration dialog
174 @return reference to the instantiated page (ConfigurationPageBase)
175 """
176 page = ApplicationPage()
177 return page

eric ide

mercurial