src/eric7/Preferences/ConfigurationDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
14 import types 14 import types
15 15
16 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QMetaObject, QRect 16 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QMetaObject, QRect
17 from PyQt6.QtGui import QPixmap 17 from PyQt6.QtGui import QPixmap
18 from PyQt6.QtWidgets import ( 18 from PyQt6.QtWidgets import (
19 QSizePolicy, QSpacerItem, QWidget, QTreeWidget, QStackedWidget, QDialog, 19 QSizePolicy,
20 QSplitter, QScrollArea, QApplication, QDialogButtonBox, QFrame, 20 QSpacerItem,
21 QVBoxLayout, QTreeWidgetItem, QLabel, QAbstractScrollArea, QLineEdit 21 QWidget,
22 QTreeWidget,
23 QStackedWidget,
24 QDialog,
25 QSplitter,
26 QScrollArea,
27 QApplication,
28 QDialogButtonBox,
29 QFrame,
30 QVBoxLayout,
31 QTreeWidgetItem,
32 QLabel,
33 QAbstractScrollArea,
34 QLineEdit,
22 ) 35 )
23 36
24 from EricWidgets.EricApplication import ericApp 37 from EricWidgets.EricApplication import ericApp
25 from EricWidgets import EricMessageBox 38 from EricWidgets import EricMessageBox
26 from EricWidgets.EricMainWindow import EricMainWindow 39 from EricWidgets.EricMainWindow import EricMainWindow
36 49
37 class ConfigurationPageItem(QTreeWidgetItem): 50 class ConfigurationPageItem(QTreeWidgetItem):
38 """ 51 """
39 Class implementing a QTreeWidgetItem holding the configuration page data. 52 Class implementing a QTreeWidgetItem holding the configuration page data.
40 """ 53 """
54
41 def __init__(self, parent, text, pageName, iconFile): 55 def __init__(self, parent, text, pageName, iconFile):
42 """ 56 """
43 Constructor 57 Constructor
44 58
45 @param parent parent widget of the item (QTreeWidget or 59 @param parent parent widget of the item (QTreeWidget or
46 QTreeWidgetItem) 60 QTreeWidgetItem)
47 @param text text to be displayed (string) 61 @param text text to be displayed (string)
48 @param pageName name of the configuration page (string) 62 @param pageName name of the configuration page (string)
49 @param iconFile file name of the icon to be shown (string) 63 @param iconFile file name of the icon to be shown (string)
50 """ 64 """
51 super().__init__(parent, [text]) 65 super().__init__(parent, [text])
52 self.setIcon(0, UI.PixmapCache.getIcon(iconFile)) 66 self.setIcon(0, UI.PixmapCache.getIcon(iconFile))
53 67
54 self.__pageName = pageName 68 self.__pageName = pageName
55 69
56 def getPageName(self): 70 def getPageName(self):
57 """ 71 """
58 Public method to get the name of the associated configuration page. 72 Public method to get the name of the associated configuration page.
59 73
60 @return name of the configuration page (string) 74 @return name of the configuration page (string)
61 """ 75 """
62 return self.__pageName 76 return self.__pageName
63 77
64 78
65 class ConfigurationMode(enum.Enum): 79 class ConfigurationMode(enum.Enum):
66 """ 80 """
67 Class defining the various modes of the configuration widget. 81 Class defining the various modes of the configuration widget.
68 """ 82 """
83
69 DEFAULTMODE = 0 84 DEFAULTMODE = 0
70 TRAYSTARTERMODE = 1 85 TRAYSTARTERMODE = 1
71 HEXEDITORMODE = 2 86 HEXEDITORMODE = 2
72 WEBBROWSERMODE = 3 87 WEBBROWSERMODE = 3
73 EDITORMODE = 4 88 EDITORMODE = 4
74 89
75 90
76 class ConfigurationWidget(QWidget): 91 class ConfigurationWidget(QWidget):
77 """ 92 """
78 Class implementing a dialog for the configuration of eric. 93 Class implementing a dialog for the configuration of eric.
79 94
80 @signal preferencesChanged() emitted after settings have been changed 95 @signal preferencesChanged() emitted after settings have been changed
81 @signal masterPasswordChanged(str, str) emitted after the master 96 @signal masterPasswordChanged(str, str) emitted after the master
82 password has been changed with the old and the new password 97 password has been changed with the old and the new password
83 @signal accepted() emitted to indicate acceptance of the changes 98 @signal accepted() emitted to indicate acceptance of the changes
84 @signal rejected() emitted to indicate rejection of the changes 99 @signal rejected() emitted to indicate rejection of the changes
85 """ 100 """
101
86 preferencesChanged = pyqtSignal() 102 preferencesChanged = pyqtSignal()
87 masterPasswordChanged = pyqtSignal(str, str) 103 masterPasswordChanged = pyqtSignal(str, str)
88 accepted = pyqtSignal() 104 accepted = pyqtSignal()
89 rejected = pyqtSignal() 105 rejected = pyqtSignal()
90 106
91 def __init__(self, parent=None, fromEric=True, 107 def __init__(
92 displayMode=ConfigurationMode.DEFAULTMODE, 108 self,
93 expandedEntries=None): 109 parent=None,
110 fromEric=True,
111 displayMode=ConfigurationMode.DEFAULTMODE,
112 expandedEntries=None,
113 ):
94 """ 114 """
95 Constructor 115 Constructor
96 116
97 @param parent reference to the parent widget 117 @param parent reference to the parent widget
98 @type QWidget 118 @type QWidget
99 @param fromEric flag indicating a dialog generation from within the 119 @param fromEric flag indicating a dialog generation from within the
100 eric IDE 120 eric IDE
101 @type bool 121 @type bool
103 @type ConfigurationMode 123 @type ConfigurationMode
104 @param expandedEntries list of entries to be shown expanded 124 @param expandedEntries list of entries to be shown expanded
105 @type list of str 125 @type list of str
106 """ 126 """
107 super().__init__(parent) 127 super().__init__(parent)
108 128
109 self.fromEric = fromEric 129 self.fromEric = fromEric
110 self.displayMode = displayMode 130 self.displayMode = displayMode
111 self.__webEngine = getWebBrowserSupport() == "QtWebEngine" 131 self.__webEngine = getWebBrowserSupport() == "QtWebEngine"
112 expandedEntries = [] if expandedEntries is None else expandedEntries[:] 132 expandedEntries = [] if expandedEntries is None else expandedEntries[:]
113 133
114 self.__setupUi() 134 self.__setupUi()
115 135
116 self.itmDict = {} 136 self.itmDict = {}
117 137
118 if not fromEric: 138 if not fromEric:
119 from PluginManager.PluginManager import PluginManager 139 from PluginManager.PluginManager import PluginManager
140
120 try: 141 try:
121 self.pluginManager = ericApp().getObject("PluginManager") 142 self.pluginManager = ericApp().getObject("PluginManager")
122 except KeyError: 143 except KeyError:
123 self.pluginManager = PluginManager(self) 144 self.pluginManager = PluginManager(self)
124 ericApp().registerObject("PluginManager", self.pluginManager) 145 ericApp().registerObject("PluginManager", self.pluginManager)
125 146
126 from VirtualEnv.VirtualenvManager import VirtualenvManager 147 from VirtualEnv.VirtualenvManager import VirtualenvManager
148
127 try: 149 try:
128 self.virtualenvManager = ericApp().getObject( 150 self.virtualenvManager = ericApp().getObject("VirtualEnvManager")
129 "VirtualEnvManager")
130 except KeyError: 151 except KeyError:
131 self.virtualenvManager = VirtualenvManager(self) 152 self.virtualenvManager = VirtualenvManager(self)
132 ericApp().registerObject("VirtualEnvManager", 153 ericApp().registerObject("VirtualEnvManager", self.virtualenvManager)
133 self.virtualenvManager) 154
134
135 if displayMode == ConfigurationMode.DEFAULTMODE: 155 if displayMode == ConfigurationMode.DEFAULTMODE:
136 self.configItems = { 156 self.configItems = {
137 # key : [display string, pixmap name, dialog module name or 157 # key : [display string, pixmap name, dialog module name or
138 # page creation function, parent key, 158 # page creation function, parent key,
139 # reference to configuration page (must always be last)] 159 # reference to configuration page (must always be last)]
140 # The dialog module must have the module function 'create' to 160 # The dialog module must have the module function 'create' to
141 # create the configuration page. This must have the method 161 # create the configuration page. This must have the method
142 # 'save' to save the settings. 162 # 'save' to save the settings.
143 "applicationPage": 163 "applicationPage": [
144 [self.tr("Application"), "preferences-application", 164 self.tr("Application"),
145 "ApplicationPage", None, None], 165 "preferences-application",
146 "condaPage": 166 "ApplicationPage",
147 [self.tr("Conda"), "miniconda", 167 None,
148 "CondaPage", None, None], 168 None,
149 "cooperationPage": 169 ],
150 [self.tr("Cooperation"), "preferences-cooperation", 170 "condaPage": [self.tr("Conda"), "miniconda", "CondaPage", None, None],
151 "CooperationPage", None, None], 171 "cooperationPage": [
152 "corbaPage": 172 self.tr("Cooperation"),
153 [self.tr("CORBA"), "preferences-orbit", 173 "preferences-cooperation",
154 "CorbaPage", None, None], 174 "CooperationPage",
155 "diffPage": 175 None,
156 [self.tr("Diff"), "diffFiles", 176 None,
157 "DiffColoursPage", None, None], 177 ],
158 "emailPage": 178 "corbaPage": [
159 [self.tr("Email"), "preferences-mail_generic", 179 self.tr("CORBA"),
160 "EmailPage", None, None], 180 "preferences-orbit",
161 "graphicsPage": 181 "CorbaPage",
162 [self.tr("Graphics"), "preferences-graphics", 182 None,
163 "GraphicsPage", None, None], 183 None,
164 "hexEditorPage": 184 ],
165 [self.tr("Hex Editor"), "hexEditor", 185 "diffPage": [
166 "HexEditorPage", None, None], 186 self.tr("Diff"),
167 "iconsPage": 187 "diffFiles",
168 [self.tr("Icons"), "preferences-icons", 188 "DiffColoursPage",
169 "IconsPage", None, None], 189 None,
170 "ircPage": 190 None,
171 [self.tr("IRC"), "irc", 191 ],
172 "IrcPage", None, None], 192 "emailPage": [
173 "logViewerPage": 193 self.tr("Email"),
174 [self.tr("Log-Viewer"), "preferences-logviewer", 194 "preferences-mail_generic",
175 "LogViewerPage", None, None], 195 "EmailPage",
176 "microPythonPage": 196 None,
177 [self.tr("MicroPython"), "micropython", 197 None,
178 "MicroPythonPage", None, None], 198 ],
179 "mimeTypesPage": 199 "graphicsPage": [
180 [self.tr("Mimetypes"), "preferences-mimetypes", 200 self.tr("Graphics"),
181 "MimeTypesPage", None, None], 201 "preferences-graphics",
182 "networkPage": 202 "GraphicsPage",
183 [self.tr("Network"), "preferences-network", 203 None,
184 "NetworkPage", None, None], 204 None,
185 "notificationsPage": 205 ],
186 [self.tr("Notifications"), 206 "hexEditorPage": [
187 "preferences-notifications", 207 self.tr("Hex Editor"),
188 "NotificationsPage", None, None], 208 "hexEditor",
189 "pipPage": 209 "HexEditorPage",
190 [self.tr("Python Package Management"), "pypi", 210 None,
191 "PipPage", None, None], 211 None,
192 "pluginManagerPage": 212 ],
193 [self.tr("Plugin Manager"), 213 "iconsPage": [
194 "preferences-pluginmanager", 214 self.tr("Icons"),
195 "PluginManagerPage", None, None], 215 "preferences-icons",
196 "printerPage": 216 "IconsPage",
197 [self.tr("Printer"), "preferences-printer", 217 None,
198 "PrinterPage", None, None], 218 None,
199 "protobufPage": 219 ],
200 [self.tr("Protobuf"), "protobuf", 220 "ircPage": [self.tr("IRC"), "irc", "IrcPage", None, None],
201 "ProtobufPage", None, None], 221 "logViewerPage": [
202 "pythonPage": 222 self.tr("Log-Viewer"),
203 [self.tr("Python"), "preferences-python", 223 "preferences-logviewer",
204 "PythonPage", None, None], 224 "LogViewerPage",
205 "qtPage": 225 None,
206 [self.tr("Qt"), "preferences-qtlogo", 226 None,
207 "QtPage", None, None], 227 ],
208 "securityPage": 228 "microPythonPage": [
209 [self.tr("Security"), "preferences-security", 229 self.tr("MicroPython"),
210 "SecurityPage", None, None], 230 "micropython",
211 "shellPage": 231 "MicroPythonPage",
212 [self.tr("Shell"), "preferences-shell", 232 None,
213 "ShellPage", None, None], 233 None,
214 "tasksPage": 234 ],
215 [self.tr("Tasks"), "task", 235 "mimeTypesPage": [
216 "TasksPage", None, None], 236 self.tr("Mimetypes"),
217 "templatesPage": 237 "preferences-mimetypes",
218 [self.tr("Templates"), "preferences-template", 238 "MimeTypesPage",
219 "TemplatesPage", None, None], 239 None,
220 "trayStarterPage": 240 None,
221 [self.tr("Tray Starter"), "erict", 241 ],
222 "TrayStarterPage", None, None], 242 "networkPage": [
223 "vcsPage": 243 self.tr("Network"),
224 [self.tr("Version Control Systems"), 244 "preferences-network",
225 "preferences-vcs", 245 "NetworkPage",
226 "VcsPage", None, None], 246 None,
227 247 None,
228 "0debuggerPage": 248 ],
229 [self.tr("Debugger"), "preferences-debugger", 249 "notificationsPage": [
230 None, None, None], 250 self.tr("Notifications"),
231 "debuggerGeneralPage": 251 "preferences-notifications",
232 [self.tr("General"), "preferences-debugger", 252 "NotificationsPage",
233 "DebuggerGeneralPage", "0debuggerPage", None], 253 None,
234 "debuggerPython3Page": 254 None,
235 [self.tr("Python3"), "preferences-pyDebugger", 255 ],
236 "DebuggerPython3Page", "0debuggerPage", None], 256 "pipPage": [
237 257 self.tr("Python Package Management"),
238 "0editorPage": 258 "pypi",
239 [self.tr("Editor"), "preferences-editor", 259 "PipPage",
240 None, None, None], 260 None,
241 "editorAPIsPage": 261 None,
242 [self.tr("APIs"), "preferences-api", 262 ],
243 "EditorAPIsPage", "0editorPage", None], 263 "pluginManagerPage": [
244 "editorDocViewerPage": 264 self.tr("Plugin Manager"),
245 [self.tr("Documentation Viewer"), "codeDocuViewer", 265 "preferences-pluginmanager",
246 "EditorDocViewerPage", "0editorPage", None], 266 "PluginManagerPage",
247 "editorGeneralPage": 267 None,
248 [self.tr("General"), "preferences-general", 268 None,
249 "EditorGeneralPage", "0editorPage", None], 269 ],
250 "editorFilePage": 270 "printerPage": [
251 [self.tr("Filehandling"), 271 self.tr("Printer"),
252 "preferences-filehandling", 272 "preferences-printer",
253 "EditorFilePage", "0editorPage", None], 273 "PrinterPage",
254 "editorSearchPage": 274 None,
255 [self.tr("Searching"), "preferences-search", 275 None,
256 "EditorSearchPage", "0editorPage", None], 276 ],
257 "editorSpellCheckingPage": 277 "protobufPage": [
258 [self.tr("Spell checking"), 278 self.tr("Protobuf"),
259 "preferences-spellchecking", 279 "protobuf",
260 "EditorSpellCheckingPage", "0editorPage", None], 280 "ProtobufPage",
261 "editorStylesPage": 281 None,
262 [self.tr("Style"), "preferences-styles", 282 None,
263 "EditorStylesPage", "0editorPage", None], 283 ],
264 "editorSyntaxPage": 284 "pythonPage": [
265 [self.tr("Code Checkers"), "preferences-debugger", 285 self.tr("Python"),
266 "EditorSyntaxPage", "0editorPage", None], 286 "preferences-python",
267 "editorTypingPage": 287 "PythonPage",
268 [self.tr("Typing"), "preferences-typing", 288 None,
269 "EditorTypingPage", "0editorPage", None], 289 None,
270 "editorExportersPage": 290 ],
271 [self.tr("Exporters"), "preferences-exporters", 291 "qtPage": [self.tr("Qt"), "preferences-qtlogo", "QtPage", None, None],
272 "EditorExportersPage", "0editorPage", None], 292 "securityPage": [
273 293 self.tr("Security"),
274 "1editorAutocompletionPage": 294 "preferences-security",
275 [self.tr("Autocompletion"), 295 "SecurityPage",
276 "preferences-autocompletion", 296 None,
277 "EditorAutocompletionPage", "0editorPage", None], 297 None,
278 "editorAutocompletionQScintillaPage": 298 ],
279 [self.tr("QScintilla"), "qscintilla", 299 "shellPage": [
280 "EditorAutocompletionQScintillaPage", 300 self.tr("Shell"),
281 "1editorAutocompletionPage", None], 301 "preferences-shell",
282 "editorAutocompletionJediPage": 302 "ShellPage",
283 [self.tr("Jedi"), "jedi", 303 None,
284 "EditorAutoCompletionJediPage", 304 None,
285 "1editorAutocompletionPage", None], 305 ],
286 306 "tasksPage": [self.tr("Tasks"), "task", "TasksPage", None, None],
287 "1editorCalltipsPage": 307 "templatesPage": [
288 [self.tr("Calltips"), "preferences-calltips", 308 self.tr("Templates"),
289 "EditorCalltipsPage", "0editorPage", None], 309 "preferences-template",
290 "editorCalltipsQScintillaPage": 310 "TemplatesPage",
291 [self.tr("QScintilla"), "qscintilla", 311 None,
292 "EditorCalltipsQScintillaPage", "1editorCalltipsPage", None], 312 None,
293 "editorCalltipsJediPage": 313 ],
294 [self.tr("Jedi"), "jedi", 314 "trayStarterPage": [
295 "EditorCallTipsJediPage", "1editorCalltipsPage", None], 315 self.tr("Tray Starter"),
296 316 "erict",
297 "1editorLexerPage": 317 "TrayStarterPage",
298 [self.tr("Highlighters"), 318 None,
299 "preferences-highlighting-styles", 319 None,
300 None, "0editorPage", None], 320 ],
301 "editorHighlightersPage": 321 "vcsPage": [
302 [self.tr("Filetype Associations"), 322 self.tr("Version Control Systems"),
303 "preferences-highlighter-association", 323 "preferences-vcs",
304 "EditorHighlightersPage", "1editorLexerPage", None], 324 "VcsPage",
305 "editorHighlightingStylesPage": 325 None,
306 [self.tr("Styles"), 326 None,
307 "preferences-highlighting-styles", 327 ],
308 "EditorHighlightingStylesPage", "1editorLexerPage", None], 328 "0debuggerPage": [
309 "editorKeywordsPage": 329 self.tr("Debugger"),
310 [self.tr("Keywords"), "preferences-keywords", 330 "preferences-debugger",
311 "EditorKeywordsPage", "1editorLexerPage", None], 331 None,
312 "editorPropertiesPage": 332 None,
313 [self.tr("Properties"), "preferences-properties", 333 None,
314 "EditorPropertiesPage", "1editorLexerPage", None], 334 ],
315 335 "debuggerGeneralPage": [
316 "1editorMouseClickHandlers": 336 self.tr("General"),
317 [self.tr("Mouse Click Handlers"), 337 "preferences-debugger",
318 "preferences-mouse-click-handler", 338 "DebuggerGeneralPage",
319 "EditorMouseClickHandlerPage", "0editorPage", None], 339 "0debuggerPage",
320 "editorMouseClickHandlerJediPage": 340 None,
321 [self.tr("Jedi"), "jedi", 341 ],
322 "EditorMouseClickHandlerJediPage", 342 "debuggerPython3Page": [
323 "1editorMouseClickHandlers", None], 343 self.tr("Python3"),
324 344 "preferences-pyDebugger",
325 "0helpPage": 345 "DebuggerPython3Page",
326 [self.tr("Help"), "preferences-help", 346 "0debuggerPage",
327 None, None, None], 347 None,
328 "helpDocumentationPage": 348 ],
329 [self.tr("Help Documentation"), 349 "0editorPage": [
330 "preferences-helpdocumentation", 350 self.tr("Editor"),
331 "HelpDocumentationPage", "0helpPage", None], 351 "preferences-editor",
332 "helpViewersPage": 352 None,
333 [self.tr("Help Viewers"), 353 None,
334 "preferences-helpviewers", 354 None,
335 "HelpViewersPage", "0helpPage", None], 355 ],
336 356 "editorAPIsPage": [
337 "0projectPage": 357 self.tr("APIs"),
338 [self.tr("Project"), "preferences-project", 358 "preferences-api",
339 None, None, None], 359 "EditorAPIsPage",
340 "projectBrowserPage": 360 "0editorPage",
341 [self.tr("Project Viewer"), "preferences-project", 361 None,
342 "ProjectBrowserPage", "0projectPage", None], 362 ],
343 "projectPage": 363 "editorDocViewerPage": [
344 [self.tr("Project"), "preferences-project", 364 self.tr("Documentation Viewer"),
345 "ProjectPage", "0projectPage", None], 365 "codeDocuViewer",
346 "multiProjectPage": 366 "EditorDocViewerPage",
347 [self.tr("Multiproject"), 367 "0editorPage",
348 "preferences-multiproject", 368 None,
349 "MultiProjectPage", "0projectPage", None], 369 ],
350 370 "editorGeneralPage": [
351 "0interfacePage": 371 self.tr("General"),
352 [self.tr("Interface"), "preferences-interface", 372 "preferences-general",
353 None, None, None], 373 "EditorGeneralPage",
354 "interfacePage": 374 "0editorPage",
355 [self.tr("Interface"), "preferences-interface", 375 None,
356 "InterfacePage", "0interfacePage", None], 376 ],
357 "viewmanagerPage": 377 "editorFilePage": [
358 [self.tr("Viewmanager"), "preferences-viewmanager", 378 self.tr("Filehandling"),
359 "ViewmanagerPage", "0interfacePage", None], 379 "preferences-filehandling",
380 "EditorFilePage",
381 "0editorPage",
382 None,
383 ],
384 "editorSearchPage": [
385 self.tr("Searching"),
386 "preferences-search",
387 "EditorSearchPage",
388 "0editorPage",
389 None,
390 ],
391 "editorSpellCheckingPage": [
392 self.tr("Spell checking"),
393 "preferences-spellchecking",
394 "EditorSpellCheckingPage",
395 "0editorPage",
396 None,
397 ],
398 "editorStylesPage": [
399 self.tr("Style"),
400 "preferences-styles",
401 "EditorStylesPage",
402 "0editorPage",
403 None,
404 ],
405 "editorSyntaxPage": [
406 self.tr("Code Checkers"),
407 "preferences-debugger",
408 "EditorSyntaxPage",
409 "0editorPage",
410 None,
411 ],
412 "editorTypingPage": [
413 self.tr("Typing"),
414 "preferences-typing",
415 "EditorTypingPage",
416 "0editorPage",
417 None,
418 ],
419 "editorExportersPage": [
420 self.tr("Exporters"),
421 "preferences-exporters",
422 "EditorExportersPage",
423 "0editorPage",
424 None,
425 ],
426 "1editorAutocompletionPage": [
427 self.tr("Autocompletion"),
428 "preferences-autocompletion",
429 "EditorAutocompletionPage",
430 "0editorPage",
431 None,
432 ],
433 "editorAutocompletionQScintillaPage": [
434 self.tr("QScintilla"),
435 "qscintilla",
436 "EditorAutocompletionQScintillaPage",
437 "1editorAutocompletionPage",
438 None,
439 ],
440 "editorAutocompletionJediPage": [
441 self.tr("Jedi"),
442 "jedi",
443 "EditorAutoCompletionJediPage",
444 "1editorAutocompletionPage",
445 None,
446 ],
447 "1editorCalltipsPage": [
448 self.tr("Calltips"),
449 "preferences-calltips",
450 "EditorCalltipsPage",
451 "0editorPage",
452 None,
453 ],
454 "editorCalltipsQScintillaPage": [
455 self.tr("QScintilla"),
456 "qscintilla",
457 "EditorCalltipsQScintillaPage",
458 "1editorCalltipsPage",
459 None,
460 ],
461 "editorCalltipsJediPage": [
462 self.tr("Jedi"),
463 "jedi",
464 "EditorCallTipsJediPage",
465 "1editorCalltipsPage",
466 None,
467 ],
468 "1editorLexerPage": [
469 self.tr("Highlighters"),
470 "preferences-highlighting-styles",
471 None,
472 "0editorPage",
473 None,
474 ],
475 "editorHighlightersPage": [
476 self.tr("Filetype Associations"),
477 "preferences-highlighter-association",
478 "EditorHighlightersPage",
479 "1editorLexerPage",
480 None,
481 ],
482 "editorHighlightingStylesPage": [
483 self.tr("Styles"),
484 "preferences-highlighting-styles",
485 "EditorHighlightingStylesPage",
486 "1editorLexerPage",
487 None,
488 ],
489 "editorKeywordsPage": [
490 self.tr("Keywords"),
491 "preferences-keywords",
492 "EditorKeywordsPage",
493 "1editorLexerPage",
494 None,
495 ],
496 "editorPropertiesPage": [
497 self.tr("Properties"),
498 "preferences-properties",
499 "EditorPropertiesPage",
500 "1editorLexerPage",
501 None,
502 ],
503 "1editorMouseClickHandlers": [
504 self.tr("Mouse Click Handlers"),
505 "preferences-mouse-click-handler",
506 "EditorMouseClickHandlerPage",
507 "0editorPage",
508 None,
509 ],
510 "editorMouseClickHandlerJediPage": [
511 self.tr("Jedi"),
512 "jedi",
513 "EditorMouseClickHandlerJediPage",
514 "1editorMouseClickHandlers",
515 None,
516 ],
517 "0helpPage": [self.tr("Help"), "preferences-help", None, None, None],
518 "helpDocumentationPage": [
519 self.tr("Help Documentation"),
520 "preferences-helpdocumentation",
521 "HelpDocumentationPage",
522 "0helpPage",
523 None,
524 ],
525 "helpViewersPage": [
526 self.tr("Help Viewers"),
527 "preferences-helpviewers",
528 "HelpViewersPage",
529 "0helpPage",
530 None,
531 ],
532 "0projectPage": [
533 self.tr("Project"),
534 "preferences-project",
535 None,
536 None,
537 None,
538 ],
539 "projectBrowserPage": [
540 self.tr("Project Viewer"),
541 "preferences-project",
542 "ProjectBrowserPage",
543 "0projectPage",
544 None,
545 ],
546 "projectPage": [
547 self.tr("Project"),
548 "preferences-project",
549 "ProjectPage",
550 "0projectPage",
551 None,
552 ],
553 "multiProjectPage": [
554 self.tr("Multiproject"),
555 "preferences-multiproject",
556 "MultiProjectPage",
557 "0projectPage",
558 None,
559 ],
560 "0interfacePage": [
561 self.tr("Interface"),
562 "preferences-interface",
563 None,
564 None,
565 None,
566 ],
567 "interfacePage": [
568 self.tr("Interface"),
569 "preferences-interface",
570 "InterfacePage",
571 "0interfacePage",
572 None,
573 ],
574 "viewmanagerPage": [
575 self.tr("Viewmanager"),
576 "preferences-viewmanager",
577 "ViewmanagerPage",
578 "0interfacePage",
579 None,
580 ],
360 } 581 }
361 if self.__webEngine: 582 if self.__webEngine:
362 self.configItems.update({ 583 self.configItems.update(
363 "0webBrowserPage": 584 {
364 [self.tr("Web Browser"), "ericWeb", 585 "0webBrowserPage": [
365 None, None, None], 586 self.tr("Web Browser"),
366 "webBrowserAppearancePage": 587 "ericWeb",
367 [self.tr("Appearance"), "preferences-styles", 588 None,
368 "WebBrowserAppearancePage", "0webBrowserPage", None], 589 None,
369 "webBrowserPage": 590 None,
370 [self.tr("eric Web Browser"), "ericWeb", 591 ],
371 "WebBrowserPage", "0webBrowserPage", None], 592 "webBrowserAppearancePage": [
372 "webBrowserVirusTotalPage": 593 self.tr("Appearance"),
373 [self.tr("VirusTotal Interface"), "virustotal", 594 "preferences-styles",
374 "WebBrowserVirusTotalPage", "0webBrowserPage", None], 595 "WebBrowserAppearancePage",
375 "webBrowserSpellCheckingPage": 596 "0webBrowserPage",
376 [self.tr("Spell checking"), 597 None,
377 "preferences-spellchecking", 598 ],
378 "WebBrowserSpellCheckingPage", "0webBrowserPage", 599 "webBrowserPage": [
379 None], 600 self.tr("eric Web Browser"),
380 }) 601 "ericWeb",
381 602 "WebBrowserPage",
603 "0webBrowserPage",
604 None,
605 ],
606 "webBrowserVirusTotalPage": [
607 self.tr("VirusTotal Interface"),
608 "virustotal",
609 "WebBrowserVirusTotalPage",
610 "0webBrowserPage",
611 None,
612 ],
613 "webBrowserSpellCheckingPage": [
614 self.tr("Spell checking"),
615 "preferences-spellchecking",
616 "WebBrowserSpellCheckingPage",
617 "0webBrowserPage",
618 None,
619 ],
620 }
621 )
622
382 self.configItems.update( 623 self.configItems.update(
383 ericApp().getObject("PluginManager").getPluginConfigData()) 624 ericApp().getObject("PluginManager").getPluginConfigData()
384 625 )
626
385 elif displayMode == ConfigurationMode.EDITORMODE: 627 elif displayMode == ConfigurationMode.EDITORMODE:
386 self.configItems = { 628 self.configItems = {
387 # key : [display string, pixmap name, dialog module name or 629 # key : [display string, pixmap name, dialog module name or
388 # page creation function, parent key, 630 # page creation function, parent key,
389 # reference to configuration page (must always be last)] 631 # reference to configuration page (must always be last)]
390 # The dialog module must have the module function 'create' to 632 # The dialog module must have the module function 'create' to
391 # create the configuration page. This must have the method 633 # create the configuration page. This must have the method
392 # 'save' to save the settings. 634 # 'save' to save the settings.
393 "iconsPage": 635 "iconsPage": [
394 [self.tr("Icons"), "preferences-icons", 636 self.tr("Icons"),
395 "IconsPage", None, None], 637 "preferences-icons",
396 "interfacePage": 638 "IconsPage",
397 [self.tr("Interface"), "preferences-interface", 639 None,
398 "InterfaceLightPage", None, None], 640 None,
399 "printerPage": 641 ],
400 [self.tr("Printer"), "preferences-printer", 642 "interfacePage": [
401 "PrinterPage", None, None], 643 self.tr("Interface"),
402 644 "preferences-interface",
403 "0editorPage": 645 "InterfaceLightPage",
404 [self.tr("Editor"), "preferences-editor", 646 None,
405 None, None, None], 647 None,
406 "editorGeneralPage": 648 ],
407 [self.tr("General"), "preferences-general", 649 "printerPage": [
408 "EditorGeneralPage", "0editorPage", None], 650 self.tr("Printer"),
409 "editorFilePage": 651 "preferences-printer",
410 [self.tr("Filehandling"), 652 "PrinterPage",
411 "preferences-filehandling", 653 None,
412 "EditorFilePage", "0editorPage", None], 654 None,
413 "editorSearchPage": 655 ],
414 [self.tr("Searching"), "preferences-search", 656 "0editorPage": [
415 "EditorSearchPage", "0editorPage", None], 657 self.tr("Editor"),
416 "editorSpellCheckingPage": 658 "preferences-editor",
417 [self.tr("Spell checking"), 659 None,
418 "preferences-spellchecking", 660 None,
419 "EditorSpellCheckingPage", "0editorPage", None], 661 None,
420 "editorStylesPage": 662 ],
421 [self.tr("Style"), "preferences-styles", 663 "editorGeneralPage": [
422 "EditorStylesPage", "0editorPage", None], 664 self.tr("General"),
423 "editorTypingPage": 665 "preferences-general",
424 [self.tr("Typing"), "preferences-typing", 666 "EditorGeneralPage",
425 "EditorTypingPage", "0editorPage", None], 667 "0editorPage",
426 668 None,
427 "1editorLexerPage": 669 ],
428 [self.tr("Highlighters"), 670 "editorFilePage": [
429 "preferences-highlighting-styles", 671 self.tr("Filehandling"),
430 None, "0editorPage", None], 672 "preferences-filehandling",
431 "editorHighlightersPage": 673 "EditorFilePage",
432 [self.tr("Filetype Associations"), 674 "0editorPage",
433 "preferences-highlighter-association", 675 None,
434 "EditorHighlightersPage", "1editorLexerPage", None], 676 ],
435 "editorHighlightingStylesPage": 677 "editorSearchPage": [
436 [self.tr("Styles"), 678 self.tr("Searching"),
437 "preferences-highlighting-styles", 679 "preferences-search",
438 "EditorHighlightingStylesPage", "1editorLexerPage", None], 680 "EditorSearchPage",
439 "editorKeywordsPage": 681 "0editorPage",
440 [self.tr("Keywords"), "preferences-keywords", 682 None,
441 "EditorKeywordsPage", "1editorLexerPage", None], 683 ],
442 "editorPropertiesPage": 684 "editorSpellCheckingPage": [
443 [self.tr("Properties"), "preferences-properties", 685 self.tr("Spell checking"),
444 "EditorPropertiesPage", "1editorLexerPage", None], 686 "preferences-spellchecking",
687 "EditorSpellCheckingPage",
688 "0editorPage",
689 None,
690 ],
691 "editorStylesPage": [
692 self.tr("Style"),
693 "preferences-styles",
694 "EditorStylesPage",
695 "0editorPage",
696 None,
697 ],
698 "editorTypingPage": [
699 self.tr("Typing"),
700 "preferences-typing",
701 "EditorTypingPage",
702 "0editorPage",
703 None,
704 ],
705 "1editorLexerPage": [
706 self.tr("Highlighters"),
707 "preferences-highlighting-styles",
708 None,
709 "0editorPage",
710 None,
711 ],
712 "editorHighlightersPage": [
713 self.tr("Filetype Associations"),
714 "preferences-highlighter-association",
715 "EditorHighlightersPage",
716 "1editorLexerPage",
717 None,
718 ],
719 "editorHighlightingStylesPage": [
720 self.tr("Styles"),
721 "preferences-highlighting-styles",
722 "EditorHighlightingStylesPage",
723 "1editorLexerPage",
724 None,
725 ],
726 "editorKeywordsPage": [
727 self.tr("Keywords"),
728 "preferences-keywords",
729 "EditorKeywordsPage",
730 "1editorLexerPage",
731 None,
732 ],
733 "editorPropertiesPage": [
734 self.tr("Properties"),
735 "preferences-properties",
736 "EditorPropertiesPage",
737 "1editorLexerPage",
738 None,
739 ],
445 } 740 }
446 741
447 elif displayMode == ConfigurationMode.WEBBROWSERMODE: 742 elif displayMode == ConfigurationMode.WEBBROWSERMODE:
448 self.configItems = { 743 self.configItems = {
449 # key : [display string, pixmap name, dialog module name or 744 # key : [display string, pixmap name, dialog module name or
450 # page creation function, parent key, 745 # page creation function, parent key,
451 # reference to configuration page (must always be last)] 746 # reference to configuration page (must always be last)]
452 # The dialog module must have the module function 'create' to 747 # The dialog module must have the module function 'create' to
453 # create the configuration page. This must have the method 748 # create the configuration page. This must have the method
454 # 'save' to save the settings. 749 # 'save' to save the settings.
455 "iconsPage": 750 "iconsPage": [
456 [self.tr("Icons"), "preferences-icons", 751 self.tr("Icons"),
457 "IconsPage", None, None], 752 "preferences-icons",
458 "interfacePage": 753 "IconsPage",
459 [self.tr("Interface"), "preferences-interface", 754 None,
460 "InterfaceLightPage", None, None], 755 None,
461 "networkPage": 756 ],
462 [self.tr("Network"), "preferences-network", 757 "interfacePage": [
463 "NetworkPage", None, None], 758 self.tr("Interface"),
464 "printerPage": 759 "preferences-interface",
465 [self.tr("Printer"), "preferences-printer", 760 "InterfaceLightPage",
466 "PrinterPage", None, None], 761 None,
467 "securityPage": 762 None,
468 [self.tr("Security"), "preferences-security", 763 ],
469 "SecurityPage", None, None], 764 "networkPage": [
470 765 self.tr("Network"),
471 "helpDocumentationPage": 766 "preferences-network",
472 [self.tr("Help Documentation"), 767 "NetworkPage",
473 "preferences-helpdocumentation", 768 None,
474 "HelpDocumentationPage", None, None], 769 None,
475 770 ],
476 "webBrowserAppearancePage": 771 "printerPage": [
477 [self.tr("Appearance"), "preferences-styles", 772 self.tr("Printer"),
478 "WebBrowserAppearancePage", None, None], 773 "preferences-printer",
479 "webBrowserPage": 774 "PrinterPage",
480 [self.tr("eric Web Browser"), "ericWeb", 775 None,
481 "WebBrowserPage", None, None], 776 None,
482 777 ],
483 "webBrowserVirusTotalPage": 778 "securityPage": [
484 [self.tr("VirusTotal Interface"), "virustotal", 779 self.tr("Security"),
485 "WebBrowserVirusTotalPage", None, None], 780 "preferences-security",
486 781 "SecurityPage",
487 "webBrowserSpellCheckingPage": 782 None,
488 [self.tr("Spell checking"), 783 None,
489 "preferences-spellchecking", 784 ],
490 "WebBrowserSpellCheckingPage", None, None], 785 "helpDocumentationPage": [
786 self.tr("Help Documentation"),
787 "preferences-helpdocumentation",
788 "HelpDocumentationPage",
789 None,
790 None,
791 ],
792 "webBrowserAppearancePage": [
793 self.tr("Appearance"),
794 "preferences-styles",
795 "WebBrowserAppearancePage",
796 None,
797 None,
798 ],
799 "webBrowserPage": [
800 self.tr("eric Web Browser"),
801 "ericWeb",
802 "WebBrowserPage",
803 None,
804 None,
805 ],
806 "webBrowserVirusTotalPage": [
807 self.tr("VirusTotal Interface"),
808 "virustotal",
809 "WebBrowserVirusTotalPage",
810 None,
811 None,
812 ],
813 "webBrowserSpellCheckingPage": [
814 self.tr("Spell checking"),
815 "preferences-spellchecking",
816 "WebBrowserSpellCheckingPage",
817 None,
818 None,
819 ],
491 } 820 }
492 821
493 elif displayMode == ConfigurationMode.TRAYSTARTERMODE: 822 elif displayMode == ConfigurationMode.TRAYSTARTERMODE:
494 self.configItems = { 823 self.configItems = {
495 # key : [display string, pixmap name, dialog module name or 824 # key : [display string, pixmap name, dialog module name or
496 # page creation function, parent key, 825 # page creation function, parent key,
497 # reference to configuration page (must always be last)] 826 # reference to configuration page (must always be last)]
498 # The dialog module must have the module function 'create' to 827 # The dialog module must have the module function 'create' to
499 # create the configuration page. This must have the method 828 # create the configuration page. This must have the method
500 # 'save' to save the settings. 829 # 'save' to save the settings.
501 "trayStarterPage": 830 "trayStarterPage": [
502 [self.tr("Tray Starter"), "erict", 831 self.tr("Tray Starter"),
503 "TrayStarterPage", None, None], 832 "erict",
833 "TrayStarterPage",
834 None,
835 None,
836 ],
504 } 837 }
505 838
506 elif displayMode == ConfigurationMode.HEXEDITORMODE: 839 elif displayMode == ConfigurationMode.HEXEDITORMODE:
507 self.configItems = { 840 self.configItems = {
508 # key : [display string, pixmap name, dialog module name or 841 # key : [display string, pixmap name, dialog module name or
509 # page creation function, parent key, 842 # page creation function, parent key,
510 # reference to configuration page (must always be last)] 843 # reference to configuration page (must always be last)]
511 # The dialog module must have the module function 'create' to 844 # The dialog module must have the module function 'create' to
512 # create the configuration page. This must have the method 845 # create the configuration page. This must have the method
513 # 'save' to save the settings. 846 # 'save' to save the settings.
514 "iconsPage": 847 "iconsPage": [
515 [self.tr("Icons"), "preferences-icons", 848 self.tr("Icons"),
516 "IconsPage", None, None], 849 "preferences-icons",
517 "interfacePage": 850 "IconsPage",
518 [self.tr("Interface"), "preferences-interface", 851 None,
519 "InterfaceLightPage", None, None], 852 None,
520 "hexEditorPage": 853 ],
521 [self.tr("Hex Editor"), "hexEditor", 854 "interfacePage": [
522 "HexEditorPage", None, None], 855 self.tr("Interface"),
856 "preferences-interface",
857 "InterfaceLightPage",
858 None,
859 None,
860 ],
861 "hexEditorPage": [
862 self.tr("Hex Editor"),
863 "hexEditor",
864 "HexEditorPage",
865 None,
866 None,
867 ],
523 } 868 }
524 869
525 else: 870 else:
526 # display mode for generic use 871 # display mode for generic use
527 self.configItems = { 872 self.configItems = {
528 # key : [display string, pixmap name, dialog module name or 873 # key : [display string, pixmap name, dialog module name or
529 # page creation function, parent key, 874 # page creation function, parent key,
530 # reference to configuration page (must always be last)] 875 # reference to configuration page (must always be last)]
531 # The dialog module must have the module function 'create' to 876 # The dialog module must have the module function 'create' to
532 # create the configuration page. This must have the method 877 # create the configuration page. This must have the method
533 # 'save' to save the settings. 878 # 'save' to save the settings.
534 "iconsPage": 879 "iconsPage": [
535 [self.tr("Icons"), "preferences-icons", 880 self.tr("Icons"),
536 "IconsPage", None, None], 881 "preferences-icons",
537 "interfacePage": 882 "IconsPage",
538 [self.tr("Interface"), "preferences-interface", 883 None,
539 "InterfaceLightPage", None, None], 884 None,
885 ],
886 "interfacePage": [
887 self.tr("Interface"),
888 "preferences-interface",
889 "InterfaceLightPage",
890 None,
891 None,
892 ],
540 } 893 }
541 894
542 # generate the list entries 895 # generate the list entries
543 self.__expandedEntries = [] 896 self.__expandedEntries = []
544 for key in sorted(self.configItems.keys()): 897 for key in sorted(self.configItems.keys()):
545 pageData = self.configItems[key] 898 pageData = self.configItems[key]
546 if pageData[3]: 899 if pageData[3]:
548 pitm = self.itmDict[pageData[3]] # get the parent item 901 pitm = self.itmDict[pageData[3]] # get the parent item
549 else: 902 else:
550 continue 903 continue
551 else: 904 else:
552 pitm = self.configList 905 pitm = self.configList
553 self.itmDict[key] = ConfigurationPageItem(pitm, pageData[0], key, 906 self.itmDict[key] = ConfigurationPageItem(
554 pageData[1]) 907 pitm, pageData[0], key, pageData[1]
908 )
555 self.itmDict[key].setData(0, Qt.ItemDataRole.UserRole, key) 909 self.itmDict[key].setData(0, Qt.ItemDataRole.UserRole, key)
556 if ( 910 if (
557 not self.fromEric or 911 not self.fromEric
558 displayMode != ConfigurationMode.DEFAULTMODE or 912 or displayMode != ConfigurationMode.DEFAULTMODE
559 key in expandedEntries 913 or key in expandedEntries
560 ): 914 ):
561 self.itmDict[key].setExpanded(True) 915 self.itmDict[key].setExpanded(True)
562 self.configList.sortByColumn(0, Qt.SortOrder.AscendingOrder) 916 self.configList.sortByColumn(0, Qt.SortOrder.AscendingOrder)
563 917
564 # set the initial size of the splitter 918 # set the initial size of the splitter
565 self.configSplitter.setSizes([200, 600]) 919 self.configSplitter.setSizes([200, 600])
566 self.configSplitter.splitterMoved.connect(self.__resizeConfigStack) 920 self.configSplitter.splitterMoved.connect(self.__resizeConfigStack)
567 921
568 self.configList.itemActivated.connect(self.__showConfigurationPage) 922 self.configList.itemActivated.connect(self.__showConfigurationPage)
569 self.configList.itemClicked.connect(self.__showConfigurationPage) 923 self.configList.itemClicked.connect(self.__showConfigurationPage)
570 self.buttonBox.accepted.connect(self.accept) 924 self.buttonBox.accepted.connect(self.accept)
571 self.buttonBox.rejected.connect(self.rejected) 925 self.buttonBox.rejected.connect(self.rejected)
572 926
573 if displayMode in [ConfigurationMode.TRAYSTARTERMODE, 927 if displayMode in [
574 ConfigurationMode.HEXEDITORMODE, 928 ConfigurationMode.TRAYSTARTERMODE,
575 ConfigurationMode.WEBBROWSERMODE]: 929 ConfigurationMode.HEXEDITORMODE,
930 ConfigurationMode.WEBBROWSERMODE,
931 ]:
576 self.configListSearch.hide() 932 self.configListSearch.hide()
577 933
578 if displayMode not in [ConfigurationMode.TRAYSTARTERMODE, 934 if displayMode not in [
579 ConfigurationMode.HEXEDITORMODE]: 935 ConfigurationMode.TRAYSTARTERMODE,
936 ConfigurationMode.HEXEDITORMODE,
937 ]:
580 self.__initLexers() 938 self.__initLexers()
581 939
582 def accept(self): 940 def accept(self):
583 """ 941 """
584 Public slot to accept the buttonBox accept signal. 942 Public slot to accept the buttonBox accept signal.
585 """ 943 """
586 if not isMacPlatform(): 944 if not isMacPlatform():
587 wdg = self.focusWidget() 945 wdg = self.focusWidget()
588 if wdg == self.configList: 946 if wdg == self.configList:
589 return 947 return
590 948
591 self.accepted.emit() 949 self.accepted.emit()
592 950
593 def __setupUi(self): 951 def __setupUi(self):
594 """ 952 """
595 Private method to perform the general setup of the configuration 953 Private method to perform the general setup of the configuration
596 widget. 954 widget.
597 """ 955 """
599 self.resize(900, 750) 957 self.resize(900, 750)
600 self.verticalLayout_2 = QVBoxLayout(self) 958 self.verticalLayout_2 = QVBoxLayout(self)
601 self.verticalLayout_2.setSpacing(6) 959 self.verticalLayout_2.setSpacing(6)
602 self.verticalLayout_2.setContentsMargins(6, 6, 6, 6) 960 self.verticalLayout_2.setContentsMargins(6, 6, 6, 6)
603 self.verticalLayout_2.setObjectName("verticalLayout_2") 961 self.verticalLayout_2.setObjectName("verticalLayout_2")
604 962
605 self.configSplitter = QSplitter(self) 963 self.configSplitter = QSplitter(self)
606 self.configSplitter.setOrientation(Qt.Orientation.Horizontal) 964 self.configSplitter.setOrientation(Qt.Orientation.Horizontal)
607 self.configSplitter.setObjectName("configSplitter") 965 self.configSplitter.setObjectName("configSplitter")
608 966
609 self.configListWidget = QWidget(self.configSplitter) 967 self.configListWidget = QWidget(self.configSplitter)
610 self.leftVBoxLayout = QVBoxLayout(self.configListWidget) 968 self.leftVBoxLayout = QVBoxLayout(self.configListWidget)
611 self.leftVBoxLayout.setContentsMargins(0, 0, 0, 0) 969 self.leftVBoxLayout.setContentsMargins(0, 0, 0, 0)
612 self.leftVBoxLayout.setSpacing(0) 970 self.leftVBoxLayout.setSpacing(0)
613 self.leftVBoxLayout.setObjectName("leftVBoxLayout") 971 self.leftVBoxLayout.setObjectName("leftVBoxLayout")
614 self.configListSearch = QLineEdit(self) 972 self.configListSearch = QLineEdit(self)
615 self.configListSearch.setPlaceholderText( 973 self.configListSearch.setPlaceholderText(self.tr("Enter search text..."))
616 self.tr("Enter search text..."))
617 self.configListSearch.setClearButtonEnabled(True) 974 self.configListSearch.setClearButtonEnabled(True)
618 self.configListSearch.setObjectName("configListSearch") 975 self.configListSearch.setObjectName("configListSearch")
619 self.configListSearch.setClearButtonEnabled(True) 976 self.configListSearch.setClearButtonEnabled(True)
620 self.leftVBoxLayout.addWidget(self.configListSearch) 977 self.leftVBoxLayout.addWidget(self.configListSearch)
621 self.configList = QTreeWidget() 978 self.configList = QTreeWidget()
622 self.configList.setObjectName("configList") 979 self.configList.setObjectName("configList")
623 self.leftVBoxLayout.addWidget(self.configList) 980 self.leftVBoxLayout.addWidget(self.configList)
624 self.configListSearch.textChanged.connect(self.__searchTextChanged) 981 self.configListSearch.textChanged.connect(self.__searchTextChanged)
625 982
626 self.scrollArea = QScrollArea(self.configSplitter) 983 self.scrollArea = QScrollArea(self.configSplitter)
627 self.scrollArea.setFrameShape(QFrame.Shape.NoFrame) 984 self.scrollArea.setFrameShape(QFrame.Shape.NoFrame)
628 self.scrollArea.setVerticalScrollBarPolicy( 985 self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
629 Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
630 self.scrollArea.setHorizontalScrollBarPolicy( 986 self.scrollArea.setHorizontalScrollBarPolicy(
631 Qt.ScrollBarPolicy.ScrollBarAlwaysOn) 987 Qt.ScrollBarPolicy.ScrollBarAlwaysOn
988 )
632 self.scrollArea.setWidgetResizable(False) 989 self.scrollArea.setWidgetResizable(False)
633 self.scrollArea.setSizeAdjustPolicy( 990 self.scrollArea.setSizeAdjustPolicy(
634 QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents) 991 QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents
992 )
635 self.scrollArea.setObjectName("scrollArea") 993 self.scrollArea.setObjectName("scrollArea")
636 994
637 self.configStack = QStackedWidget() 995 self.configStack = QStackedWidget()
638 self.configStack.setFrameShape(QFrame.Shape.Box) 996 self.configStack.setFrameShape(QFrame.Shape.Box)
639 self.configStack.setFrameShadow(QFrame.Shadow.Sunken) 997 self.configStack.setFrameShadow(QFrame.Shadow.Sunken)
640 self.configStack.setObjectName("configStack") 998 self.configStack.setObjectName("configStack")
641 self.scrollArea.setWidget(self.configStack) 999 self.scrollArea.setWidget(self.configStack)
642 1000
643 self.emptyPage = QWidget() 1001 self.emptyPage = QWidget()
644 self.emptyPage.setGeometry(QRect(0, 0, 372, 591)) 1002 self.emptyPage.setGeometry(QRect(0, 0, 372, 591))
645 self.emptyPage.setObjectName("emptyPage") 1003 self.emptyPage.setObjectName("emptyPage")
646 self.vboxlayout = QVBoxLayout(self.emptyPage) 1004 self.vboxlayout = QVBoxLayout(self.emptyPage)
647 self.vboxlayout.setSpacing(6) 1005 self.vboxlayout.setSpacing(6)
648 self.vboxlayout.setContentsMargins(6, 6, 6, 6) 1006 self.vboxlayout.setContentsMargins(6, 6, 6, 6)
649 self.vboxlayout.setObjectName("vboxlayout") 1007 self.vboxlayout.setObjectName("vboxlayout")
650 spacerItem = QSpacerItem( 1008 spacerItem = QSpacerItem(
651 20, 20, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding) 1009 20, 20, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding
1010 )
652 self.vboxlayout.addItem(spacerItem) 1011 self.vboxlayout.addItem(spacerItem)
653 self.emptyPagePixmap = QLabel(self.emptyPage) 1012 self.emptyPagePixmap = QLabel(self.emptyPage)
654 self.emptyPagePixmap.setAlignment(Qt.AlignmentFlag.AlignCenter) 1013 self.emptyPagePixmap.setAlignment(Qt.AlignmentFlag.AlignCenter)
655 self.emptyPagePixmap.setObjectName("emptyPagePixmap") 1014 self.emptyPagePixmap.setObjectName("emptyPagePixmap")
656 self.emptyPagePixmap.setPixmap( 1015 self.emptyPagePixmap.setPixmap(
657 QPixmap(os.path.join(getConfig('ericPixDir'), 'eric.png'))) 1016 QPixmap(os.path.join(getConfig("ericPixDir"), "eric.png"))
1017 )
658 self.vboxlayout.addWidget(self.emptyPagePixmap) 1018 self.vboxlayout.addWidget(self.emptyPagePixmap)
659 self.textLabel1 = QLabel(self.emptyPage) 1019 self.textLabel1 = QLabel(self.emptyPage)
660 self.textLabel1.setAlignment(Qt.AlignmentFlag.AlignCenter) 1020 self.textLabel1.setAlignment(Qt.AlignmentFlag.AlignCenter)
661 self.textLabel1.setObjectName("textLabel1") 1021 self.textLabel1.setObjectName("textLabel1")
662 self.vboxlayout.addWidget(self.textLabel1) 1022 self.vboxlayout.addWidget(self.textLabel1)
663 spacerItem1 = QSpacerItem( 1023 spacerItem1 = QSpacerItem(
664 20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding) 1024 20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding
1025 )
665 self.vboxlayout.addItem(spacerItem1) 1026 self.vboxlayout.addItem(spacerItem1)
666 self.configStack.addWidget(self.emptyPage) 1027 self.configStack.addWidget(self.emptyPage)
667 1028
668 self.verticalLayout_2.addWidget(self.configSplitter) 1029 self.verticalLayout_2.addWidget(self.configSplitter)
669 1030
670 self.buttonBox = QDialogButtonBox(self) 1031 self.buttonBox = QDialogButtonBox(self)
671 self.buttonBox.setOrientation(Qt.Orientation.Horizontal) 1032 self.buttonBox.setOrientation(Qt.Orientation.Horizontal)
672 self.buttonBox.setStandardButtons( 1033 self.buttonBox.setStandardButtons(
673 QDialogButtonBox.StandardButton.Apply | 1034 QDialogButtonBox.StandardButton.Apply
674 QDialogButtonBox.StandardButton.Cancel | 1035 | QDialogButtonBox.StandardButton.Cancel
675 QDialogButtonBox.StandardButton.Ok | 1036 | QDialogButtonBox.StandardButton.Ok
676 QDialogButtonBox.StandardButton.Reset 1037 | QDialogButtonBox.StandardButton.Reset
677 ) 1038 )
678 self.buttonBox.setObjectName("buttonBox") 1039 self.buttonBox.setObjectName("buttonBox")
679 if ( 1040 if not self.fromEric and self.displayMode == ConfigurationMode.DEFAULTMODE:
680 not self.fromEric and
681 self.displayMode == ConfigurationMode.DEFAULTMODE
682 ):
683 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).hide() 1041 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).hide()
684 self.buttonBox.button( 1042 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).setEnabled(False)
685 QDialogButtonBox.StandardButton.Apply).setEnabled(False) 1043 self.buttonBox.button(QDialogButtonBox.StandardButton.Reset).setEnabled(False)
686 self.buttonBox.button(
687 QDialogButtonBox.StandardButton.Reset).setEnabled(False)
688 self.verticalLayout_2.addWidget(self.buttonBox) 1044 self.verticalLayout_2.addWidget(self.buttonBox)
689 1045
690 self.setWindowTitle(self.tr("Preferences")) 1046 self.setWindowTitle(self.tr("Preferences"))
691 1047
692 self.configList.header().hide() 1048 self.configList.header().hide()
693 self.configList.header().setSortIndicator( 1049 self.configList.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder)
694 0, Qt.SortOrder.AscendingOrder)
695 self.configList.setSortingEnabled(True) 1050 self.configList.setSortingEnabled(True)
696 self.textLabel1.setText( 1051 self.textLabel1.setText(
697 self.tr("Please select an entry of the list \n" 1052 self.tr(
698 "to display the configuration page.")) 1053 "Please select an entry of the list \n"
699 1054 "to display the configuration page."
1055 )
1056 )
1057
700 QMetaObject.connectSlotsByName(self) 1058 QMetaObject.connectSlotsByName(self)
701 self.setTabOrder(self.configList, self.configStack) 1059 self.setTabOrder(self.configList, self.configStack)
702 1060
703 self.configStack.setCurrentWidget(self.emptyPage) 1061 self.configStack.setCurrentWidget(self.emptyPage)
704 1062
705 self.configList.setFocus() 1063 self.configList.setFocus()
706 1064
707 def __searchTextChanged(self, text): 1065 def __searchTextChanged(self, text):
708 """ 1066 """
709 Private slot to handle a change of the search text. 1067 Private slot to handle a change of the search text.
710 1068
711 @param text text to search for (string) 1069 @param text text to search for (string)
712 """ 1070 """
713 self.__searchChildItems(self.configList.invisibleRootItem(), text) 1071 self.__searchChildItems(self.configList.invisibleRootItem(), text)
714 1072
715 def __searchChildItems(self, parent, text): 1073 def __searchChildItems(self, parent, text):
716 """ 1074 """
717 Private method to enable child items based on a search string. 1075 Private method to enable child items based on a search string.
718 1076
719 @param parent reference to the parent item (QTreeWidgetItem) 1077 @param parent reference to the parent item (QTreeWidgetItem)
720 @param text text to search for (string) 1078 @param text text to search for (string)
721 @return flag indicating an enabled child item (boolean) 1079 @return flag indicating an enabled child item (boolean)
722 """ 1080 """
723 childEnabled = False 1081 childEnabled = False
724 text = text.lower() 1082 text = text.lower()
725 for index in range(parent.childCount()): 1083 for index in range(parent.childCount()):
726 itm = parent.child(index) 1084 itm = parent.child(index)
727 enable = ( 1085 enable = (
728 (self.__searchChildItems(itm, text) or 1086 (
729 text == "" or 1087 self.__searchChildItems(itm, text)
730 text in itm.text(0).lower()) 1088 or text == ""
731 if itm.childCount() > 0 else 1089 or text in itm.text(0).lower()
732 (text == "" or text in itm.text(0).lower()) 1090 )
1091 if itm.childCount() > 0
1092 else (text == "" or text in itm.text(0).lower())
733 ) 1093 )
734 if enable: 1094 if enable:
735 childEnabled = True 1095 childEnabled = True
736 itm.setDisabled(not enable) 1096 itm.setDisabled(not enable)
737 1097
738 return childEnabled 1098 return childEnabled
739 1099
740 def __initLexers(self): 1100 def __initLexers(self):
741 """ 1101 """
742 Private method to initialize the dictionary of preferences lexers. 1102 Private method to initialize the dictionary of preferences lexers.
743 """ 1103 """
744 import QScintilla.Lexers 1104 import QScintilla.Lexers
745 from .PreferencesLexer import ( 1105 from .PreferencesLexer import PreferencesLexer, PreferencesLexerLanguageError
746 PreferencesLexer, PreferencesLexerLanguageError 1106
747 )
748
749 self.lexers = {} 1107 self.lexers = {}
750 for language in QScintilla.Lexers.getSupportedLanguages(): 1108 for language in QScintilla.Lexers.getSupportedLanguages():
751 if language not in self.lexers: 1109 if language not in self.lexers:
752 with contextlib.suppress(PreferencesLexerLanguageError): 1110 with contextlib.suppress(PreferencesLexerLanguageError):
753 self.lexers[language] = PreferencesLexer(language, self) 1111 self.lexers[language] = PreferencesLexer(language, self)
754 1112
755 def __importConfigurationPage(self, name): 1113 def __importConfigurationPage(self, name):
756 """ 1114 """
757 Private method to import a configuration page module. 1115 Private method to import a configuration page module.
758 1116
759 @param name name of the configuration page module (string) 1117 @param name name of the configuration page module (string)
760 @return reference to the configuration page module 1118 @return reference to the configuration page module
761 """ 1119 """
762 modName = "Preferences.ConfigurationPages.{0}".format(name) 1120 modName = "Preferences.ConfigurationPages.{0}".format(name)
763 try: 1121 try:
764 mod = __import__(modName) 1122 mod = __import__(modName)
765 components = modName.split('.') 1123 components = modName.split(".")
766 for comp in components[1:]: 1124 for comp in components[1:]:
767 mod = getattr(mod, comp) 1125 mod = getattr(mod, comp)
768 return mod 1126 return mod
769 except ImportError: 1127 except ImportError:
770 EricMessageBox.critical( 1128 EricMessageBox.critical(
771 self, 1129 self,
772 self.tr("Configuration Page Error"), 1130 self.tr("Configuration Page Error"),
773 self.tr("""<p>The configuration page <b>{0}</b>""" 1131 self.tr(
774 """ could not be loaded.</p>""").format(name)) 1132 """<p>The configuration page <b>{0}</b>"""
1133 """ could not be loaded.</p>"""
1134 ).format(name),
1135 )
775 return None 1136 return None
776 1137
777 def __showConfigurationPage(self, itm, column): 1138 def __showConfigurationPage(self, itm, column):
778 """ 1139 """
779 Private slot to show a selected configuration page. 1140 Private slot to show a selected configuration page.
780 1141
781 @param itm reference to the selected item (QTreeWidgetItem) 1142 @param itm reference to the selected item (QTreeWidgetItem)
782 @param column column that was selected (integer) (ignored) 1143 @param column column that was selected (integer) (ignored)
783 """ 1144 """
784 pageName = itm.getPageName() 1145 pageName = itm.getPageName()
785 self.showConfigurationPageByName(pageName, setCurrent=False) 1146 self.showConfigurationPageByName(pageName, setCurrent=False)
786 1147
787 def __initPage(self, pageData): 1148 def __initPage(self, pageData):
788 """ 1149 """
789 Private method to initialize a configuration page. 1150 Private method to initialize a configuration page.
790 1151
791 @param pageData data structure for the page to initialize 1152 @param pageData data structure for the page to initialize
792 @return reference to the initialized page 1153 @return reference to the initialized page
793 """ 1154 """
794 page = None 1155 page = None
795 if isinstance(pageData[2], types.FunctionType): 1156 if isinstance(pageData[2], types.FunctionType):
802 self.configStack.addWidget(page) 1163 self.configStack.addWidget(page)
803 pageData[-1] = page 1164 pageData[-1] = page
804 with contextlib.suppress(AttributeError): 1165 with contextlib.suppress(AttributeError):
805 page.setMode(self.displayMode) 1166 page.setMode(self.displayMode)
806 return page 1167 return page
807 1168
808 def showConfigurationPageByName(self, pageName, setCurrent=True): 1169 def showConfigurationPageByName(self, pageName, setCurrent=True):
809 """ 1170 """
810 Public slot to show a named configuration page. 1171 Public slot to show a named configuration page.
811 1172
812 @param pageName name of the configuration page to show (string) 1173 @param pageName name of the configuration page to show (string)
813 @param setCurrent flag indicating to set the current item (boolean) 1174 @param setCurrent flag indicating to set the current item (boolean)
814 """ 1175 """
815 if pageName == "empty" or pageName not in self.configItems: 1176 if pageName == "empty" or pageName not in self.configItems:
816 page = self.emptyPage 1177 page = self.emptyPage
824 if page is None: 1185 if page is None:
825 page = self.emptyPage 1186 page = self.emptyPage
826 elif setCurrent: 1187 elif setCurrent:
827 items = self.configList.findItems( 1188 items = self.configList.findItems(
828 pageData[0], 1189 pageData[0],
829 Qt.MatchFlag.MatchFixedString | 1190 Qt.MatchFlag.MatchFixedString | Qt.MatchFlag.MatchRecursive,
830 Qt.MatchFlag.MatchRecursive) 1191 )
831 for item in items: 1192 for item in items:
832 if item.data(0, Qt.ItemDataRole.UserRole) == pageName: 1193 if item.data(0, Qt.ItemDataRole.UserRole) == pageName:
833 self.configList.setCurrentItem(item) 1194 self.configList.setCurrentItem(item)
834 self.configStack.setCurrentWidget(page) 1195 self.configStack.setCurrentWidget(page)
835 self.__resizeConfigStack() 1196 self.__resizeConfigStack()
836 1197
837 if page != self.emptyPage: 1198 if page != self.emptyPage:
838 page.polishPage() 1199 page.polishPage()
839 self.buttonBox.button( 1200 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).setEnabled(
840 QDialogButtonBox.StandardButton.Apply).setEnabled(True) 1201 True
841 self.buttonBox.button( 1202 )
842 QDialogButtonBox.StandardButton.Reset).setEnabled(True) 1203 self.buttonBox.button(QDialogButtonBox.StandardButton.Reset).setEnabled(
1204 True
1205 )
843 else: 1206 else:
844 self.buttonBox.button( 1207 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).setEnabled(
845 QDialogButtonBox.StandardButton.Apply).setEnabled(False) 1208 False
846 self.buttonBox.button( 1209 )
847 QDialogButtonBox.StandardButton.Reset).setEnabled(False) 1210 self.buttonBox.button(QDialogButtonBox.StandardButton.Reset).setEnabled(
848 1211 False
1212 )
1213
849 # reset scrollbars 1214 # reset scrollbars
850 for sb in [self.scrollArea.horizontalScrollBar(), 1215 for sb in [
851 self.scrollArea.verticalScrollBar()]: 1216 self.scrollArea.horizontalScrollBar(),
1217 self.scrollArea.verticalScrollBar(),
1218 ]:
852 if sb: 1219 if sb:
853 sb.setValue(0) 1220 sb.setValue(0)
854 1221
855 self.__currentConfigurationPageName = pageName 1222 self.__currentConfigurationPageName = pageName
856 1223
857 def resizeEvent(self, evt): 1224 def resizeEvent(self, evt):
858 """ 1225 """
859 Protected method to handle the resizing of the widget. 1226 Protected method to handle the resizing of the widget.
860 1227
861 @param evt reference to the event object 1228 @param evt reference to the event object
862 @type QResizeEvent 1229 @type QResizeEvent
863 """ 1230 """
864 self.__resizeConfigStack() 1231 self.__resizeConfigStack()
865 1232
866 def __resizeConfigStack(self): 1233 def __resizeConfigStack(self):
867 """ 1234 """
868 Private method to resize the stack of configuration pages. 1235 Private method to resize the stack of configuration pages.
869 """ 1236 """
870 ssize = self.scrollArea.size() 1237 ssize = self.scrollArea.size()
871 if self.scrollArea.horizontalScrollBar(): 1238 if self.scrollArea.horizontalScrollBar():
872 ssize.setHeight( 1239 ssize.setHeight(
873 ssize.height() - 1240 ssize.height() - self.scrollArea.horizontalScrollBar().height() - 2
874 self.scrollArea.horizontalScrollBar().height() - 2) 1241 )
875 if self.scrollArea.verticalScrollBar(): 1242 if self.scrollArea.verticalScrollBar():
876 ssize.setWidth( 1243 ssize.setWidth(
877 ssize.width() - 1244 ssize.width() - self.scrollArea.verticalScrollBar().width() - 2
878 self.scrollArea.verticalScrollBar().width() - 2) 1245 )
879 psize = self.configStack.currentWidget().minimumSizeHint() 1246 psize = self.configStack.currentWidget().minimumSizeHint()
880 self.configStack.resize(max(ssize.width(), psize.width()), 1247 self.configStack.resize(
881 max(ssize.height(), psize.height())) 1248 max(ssize.width(), psize.width()), max(ssize.height(), psize.height())
882 1249 )
1250
883 def getConfigurationPageName(self): 1251 def getConfigurationPageName(self):
884 """ 1252 """
885 Public method to get the page name of the current page. 1253 Public method to get the page name of the current page.
886 1254
887 @return page name of the current page (string) 1255 @return page name of the current page (string)
888 """ 1256 """
889 return self.__currentConfigurationPageName 1257 return self.__currentConfigurationPageName
890 1258
891 def calledFromEric(self): 1259 def calledFromEric(self):
892 """ 1260 """
893 Public method to check, if invoked from within eric. 1261 Public method to check, if invoked from within eric.
894 1262
895 @return flag indicating invocation from within eric (boolean) 1263 @return flag indicating invocation from within eric (boolean)
896 """ 1264 """
897 return self.fromEric 1265 return self.fromEric
898 1266
899 def getPage(self, pageName): 1267 def getPage(self, pageName):
900 """ 1268 """
901 Public method to get a reference to the named page. 1269 Public method to get a reference to the named page.
902 1270
903 @param pageName name of the configuration page (string) 1271 @param pageName name of the configuration page (string)
904 @return reference to the page or None, indicating page was 1272 @return reference to the page or None, indicating page was
905 not loaded yet 1273 not loaded yet
906 """ 1274 """
907 return self.configItems[pageName][-1] 1275 return self.configItems[pageName][-1]
908 1276
909 def getLexers(self): 1277 def getLexers(self):
910 """ 1278 """
911 Public method to get a reference to the lexers dictionary. 1279 Public method to get a reference to the lexers dictionary.
912 1280
913 @return reference to the lexers dictionary 1281 @return reference to the lexers dictionary
914 """ 1282 """
915 return self.lexers 1283 return self.lexers
916 1284
917 def setPreferences(self): 1285 def setPreferences(self):
918 """ 1286 """
919 Public method called to store the selected values into the preferences 1287 Public method called to store the selected values into the preferences
920 storage. 1288 storage.
921 """ 1289 """
923 for pageData in self.configItems.values(): 1291 for pageData in self.configItems.values():
924 if pageData[-1]: 1292 if pageData[-1]:
925 pageData[-1].save() 1293 pageData[-1].save()
926 # page was loaded (and possibly modified) 1294 # page was loaded (and possibly modified)
927 if time.monotonic() - now > 0.01: 1295 if time.monotonic() - now > 0.01:
928 QApplication.processEvents() # ensure HMI is responsive 1296 QApplication.processEvents() # ensure HMI is responsive
929 now = time.monotonic() 1297 now = time.monotonic()
930 1298
931 def on_buttonBox_clicked(self, button): 1299 def on_buttonBox_clicked(self, button):
932 """ 1300 """
933 Private slot called by a button of the button box clicked. 1301 Private slot called by a button of the button box clicked.
934 1302
935 @param button button that was clicked (QAbstractButton) 1303 @param button button that was clicked (QAbstractButton)
936 """ 1304 """
937 if button == self.buttonBox.button( 1305 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Apply):
938 QDialogButtonBox.StandardButton.Apply
939 ):
940 self.on_applyButton_clicked() 1306 self.on_applyButton_clicked()
941 elif button == self.buttonBox.button( 1307 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Reset):
942 QDialogButtonBox.StandardButton.Reset
943 ):
944 self.on_resetButton_clicked() 1308 self.on_resetButton_clicked()
945 1309
946 @pyqtSlot() 1310 @pyqtSlot()
947 def on_applyButton_clicked(self): 1311 def on_applyButton_clicked(self):
948 """ 1312 """
949 Private slot called to apply the settings of the current page. 1313 Private slot called to apply the settings of the current page.
950 """ 1314 """
954 page.save() 1318 page.save()
955 self.preferencesChanged.emit() 1319 self.preferencesChanged.emit()
956 if savedState is not None: 1320 if savedState is not None:
957 page.setState(savedState) 1321 page.setState(savedState)
958 page.polishPage() 1322 page.polishPage()
959 1323
960 @pyqtSlot() 1324 @pyqtSlot()
961 def on_resetButton_clicked(self): 1325 def on_resetButton_clicked(self):
962 """ 1326 """
963 Private slot called to reset the settings of the current page. 1327 Private slot called to reset the settings of the current page.
964 """ 1328 """
968 pageName = self.configList.currentItem().getPageName() 1332 pageName = self.configList.currentItem().getPageName()
969 self.configStack.removeWidget(currentPage) 1333 self.configStack.removeWidget(currentPage)
970 if pageName == "editorHighlightingStylesPage": 1334 if pageName == "editorHighlightingStylesPage":
971 self.__initLexers() 1335 self.__initLexers()
972 self.configItems[pageName][-1] = None 1336 self.configItems[pageName][-1] = None
973 1337
974 self.showConfigurationPageByName(pageName) 1338 self.showConfigurationPageByName(pageName)
975 if savedState is not None: 1339 if savedState is not None:
976 self.configStack.currentWidget().setState(savedState) 1340 self.configStack.currentWidget().setState(savedState)
977 1341
978 def getExpandedEntries(self): 1342 def getExpandedEntries(self):
979 """ 1343 """
980 Public method to get a list of expanded entries. 1344 Public method to get a list of expanded entries.
981 1345
982 @return list of expanded entries (list of string) 1346 @return list of expanded entries (list of string)
983 """ 1347 """
984 return self.__expandedEntries 1348 return self.__expandedEntries
985 1349
986 @pyqtSlot(QTreeWidgetItem) 1350 @pyqtSlot(QTreeWidgetItem)
987 def on_configList_itemCollapsed(self, item): 1351 def on_configList_itemCollapsed(self, item):
988 """ 1352 """
989 Private slot handling a list entry being collapsed. 1353 Private slot handling a list entry being collapsed.
990 1354
991 @param item reference to the collapsed item (QTreeWidgetItem) 1355 @param item reference to the collapsed item (QTreeWidgetItem)
992 """ 1356 """
993 pageName = item.data(0, Qt.ItemDataRole.UserRole) 1357 pageName = item.data(0, Qt.ItemDataRole.UserRole)
994 if pageName in self.__expandedEntries: 1358 if pageName in self.__expandedEntries:
995 self.__expandedEntries.remove(pageName) 1359 self.__expandedEntries.remove(pageName)
996 1360
997 @pyqtSlot(QTreeWidgetItem) 1361 @pyqtSlot(QTreeWidgetItem)
998 def on_configList_itemExpanded(self, item): 1362 def on_configList_itemExpanded(self, item):
999 """ 1363 """
1000 Private slot handling a list entry being expanded. 1364 Private slot handling a list entry being expanded.
1001 1365
1002 @param item reference to the expanded item (QTreeWidgetItem) 1366 @param item reference to the expanded item (QTreeWidgetItem)
1003 """ 1367 """
1004 pageName = item.data(0, Qt.ItemDataRole.UserRole) 1368 pageName = item.data(0, Qt.ItemDataRole.UserRole)
1005 if pageName not in self.__expandedEntries: 1369 if pageName not in self.__expandedEntries:
1006 self.__expandedEntries.append(pageName) 1370 self.__expandedEntries.append(pageName)
1007 1371
1008 def isUsingWebEngine(self): 1372 def isUsingWebEngine(self):
1009 """ 1373 """
1010 Public method to get an indication, if QtWebEngine is being used. 1374 Public method to get an indication, if QtWebEngine is being used.
1011 1375
1012 @return flag indicating the use of QtWebEngine 1376 @return flag indicating the use of QtWebEngine
1013 @rtype bool 1377 @rtype bool
1014 """ 1378 """
1015 return ( 1379 return self.__webEngine or self.displayMode == ConfigurationMode.WEBBROWSERMODE
1016 self.__webEngine or
1017 self.displayMode == ConfigurationMode.WEBBROWSERMODE
1018 )
1019 1380
1020 1381
1021 class ConfigurationDialog(QDialog): 1382 class ConfigurationDialog(QDialog):
1022 """ 1383 """
1023 Class for the dialog variant. 1384 Class for the dialog variant.
1024 1385
1025 @signal preferencesChanged() emitted after settings have been changed 1386 @signal preferencesChanged() emitted after settings have been changed
1026 @signal masterPasswordChanged(str, str) emitted after the master 1387 @signal masterPasswordChanged(str, str) emitted after the master
1027 password has been changed with the old and the new password 1388 password has been changed with the old and the new password
1028 """ 1389 """
1390
1029 preferencesChanged = pyqtSignal() 1391 preferencesChanged = pyqtSignal()
1030 masterPasswordChanged = pyqtSignal(str, str) 1392 masterPasswordChanged = pyqtSignal(str, str)
1031 1393
1032 def __init__(self, parent=None, name=None, modal=False, 1394 def __init__(
1033 fromEric=True, 1395 self,
1034 displayMode=ConfigurationMode.DEFAULTMODE, 1396 parent=None,
1035 expandedEntries=None): 1397 name=None,
1398 modal=False,
1399 fromEric=True,
1400 displayMode=ConfigurationMode.DEFAULTMODE,
1401 expandedEntries=None,
1402 ):
1036 """ 1403 """
1037 Constructor 1404 Constructor
1038 1405
1039 @param parent reference to the parent widget 1406 @param parent reference to the parent widget
1040 @type QWidget 1407 @type QWidget
1041 @param name name of the dialog 1408 @param name name of the dialog
1042 @type str 1409 @type str
1043 @param modal flag indicating a modal dialog 1410 @param modal flag indicating a modal dialog
1053 super().__init__(parent) 1420 super().__init__(parent)
1054 if name: 1421 if name:
1055 self.setObjectName(name) 1422 self.setObjectName(name)
1056 self.setModal(modal) 1423 self.setModal(modal)
1057 self.setWindowFlags(Qt.WindowType.Window) 1424 self.setWindowFlags(Qt.WindowType.Window)
1058 1425
1059 self.layout = QVBoxLayout(self) 1426 self.layout = QVBoxLayout(self)
1060 self.layout.setContentsMargins(0, 0, 0, 0) 1427 self.layout.setContentsMargins(0, 0, 0, 0)
1061 self.layout.setSpacing(0) 1428 self.layout.setSpacing(0)
1062 1429
1063 self.cw = ConfigurationWidget(self, fromEric=fromEric, 1430 self.cw = ConfigurationWidget(
1064 displayMode=displayMode, 1431 self,
1065 expandedEntries=expandedEntries) 1432 fromEric=fromEric,
1433 displayMode=displayMode,
1434 expandedEntries=expandedEntries,
1435 )
1066 size = self.cw.size() 1436 size = self.cw.size()
1067 self.layout.addWidget(self.cw) 1437 self.layout.addWidget(self.cw)
1068 self.resize(size) 1438 self.resize(size)
1069 self.setWindowTitle(self.cw.windowTitle()) 1439 self.setWindowTitle(self.cw.windowTitle())
1070 1440
1071 self.cw.accepted.connect(self.accept) 1441 self.cw.accepted.connect(self.accept)
1072 self.cw.rejected.connect(self.reject) 1442 self.cw.rejected.connect(self.reject)
1073 self.cw.preferencesChanged.connect(self.__preferencesChanged) 1443 self.cw.preferencesChanged.connect(self.__preferencesChanged)
1074 self.cw.masterPasswordChanged.connect(self.__masterPasswordChanged) 1444 self.cw.masterPasswordChanged.connect(self.__masterPasswordChanged)
1075 1445
1076 def __preferencesChanged(self): 1446 def __preferencesChanged(self):
1077 """ 1447 """
1078 Private slot to handle a change of the preferences. 1448 Private slot to handle a change of the preferences.
1079 """ 1449 """
1080 self.preferencesChanged.emit() 1450 self.preferencesChanged.emit()
1081 1451
1082 def __masterPasswordChanged(self, oldPassword, newPassword): 1452 def __masterPasswordChanged(self, oldPassword, newPassword):
1083 """ 1453 """
1084 Private slot to handle the change of the master password. 1454 Private slot to handle the change of the master password.
1085 1455
1086 @param oldPassword current master password (string) 1456 @param oldPassword current master password (string)
1087 @param newPassword new master password (string) 1457 @param newPassword new master password (string)
1088 """ 1458 """
1089 self.masterPasswordChanged.emit(oldPassword, newPassword) 1459 self.masterPasswordChanged.emit(oldPassword, newPassword)
1090 1460
1091 def showConfigurationPageByName(self, pageName): 1461 def showConfigurationPageByName(self, pageName):
1092 """ 1462 """
1093 Public slot to show a named configuration page. 1463 Public slot to show a named configuration page.
1094 1464
1095 @param pageName name of the configuration page to show (string) 1465 @param pageName name of the configuration page to show (string)
1096 """ 1466 """
1097 self.cw.showConfigurationPageByName(pageName) 1467 self.cw.showConfigurationPageByName(pageName)
1098 1468
1099 def getConfigurationPageName(self): 1469 def getConfigurationPageName(self):
1100 """ 1470 """
1101 Public method to get the page name of the current page. 1471 Public method to get the page name of the current page.
1102 1472
1103 @return page name of the current page (string) 1473 @return page name of the current page (string)
1104 """ 1474 """
1105 return self.cw.getConfigurationPageName() 1475 return self.cw.getConfigurationPageName()
1106 1476
1107 def getExpandedEntries(self): 1477 def getExpandedEntries(self):
1108 """ 1478 """
1109 Public method to get a list of expanded entries. 1479 Public method to get a list of expanded entries.
1110 1480
1111 @return list of expanded entries (list of string) 1481 @return list of expanded entries (list of string)
1112 """ 1482 """
1113 return self.cw.getExpandedEntries() 1483 return self.cw.getExpandedEntries()
1114 1484
1115 def setPreferences(self): 1485 def setPreferences(self):
1116 """ 1486 """
1117 Public method called to store the selected values into the preferences 1487 Public method called to store the selected values into the preferences
1118 storage. 1488 storage.
1119 """ 1489 """
1120 self.cw.setPreferences() 1490 self.cw.setPreferences()
1121 1491
1122 def accept(self): 1492 def accept(self):
1123 """ 1493 """
1124 Public method to accept the dialog. 1494 Public method to accept the dialog.
1125 """ 1495 """
1126 super().accept() 1496 super().accept()
1128 1498
1129 class ConfigurationWindow(EricMainWindow): 1499 class ConfigurationWindow(EricMainWindow):
1130 """ 1500 """
1131 Main window class for the standalone dialog. 1501 Main window class for the standalone dialog.
1132 """ 1502 """
1503
1133 def __init__(self, parent=None): 1504 def __init__(self, parent=None):
1134 """ 1505 """
1135 Constructor 1506 Constructor
1136 1507
1137 @param parent reference to the parent widget (QWidget) 1508 @param parent reference to the parent widget (QWidget)
1138 """ 1509 """
1139 super().__init__(parent) 1510 super().__init__(parent)
1140 1511
1141 self.cw = ConfigurationWidget(self, fromEric=False) 1512 self.cw = ConfigurationWidget(self, fromEric=False)
1142 size = self.cw.size() 1513 size = self.cw.size()
1143 self.setCentralWidget(self.cw) 1514 self.setCentralWidget(self.cw)
1144 self.resize(size) 1515 self.resize(size)
1145 self.setWindowTitle(self.cw.windowTitle()) 1516 self.setWindowTitle(self.cw.windowTitle())
1146 1517
1147 self.setStyle(Preferences.getUI("Style"), 1518 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
1148 Preferences.getUI("StyleSheet")) 1519
1149
1150 self.cw.accepted.connect(self.accept) 1520 self.cw.accepted.connect(self.accept)
1151 self.cw.rejected.connect(self.close) 1521 self.cw.rejected.connect(self.close)
1152 1522
1153 def showConfigurationPageByName(self, pageName): 1523 def showConfigurationPageByName(self, pageName):
1154 """ 1524 """
1155 Public slot to show a named configuration page. 1525 Public slot to show a named configuration page.
1156 1526
1157 @param pageName name of the configuration page to show (string) 1527 @param pageName name of the configuration page to show (string)
1158 """ 1528 """
1159 self.cw.showConfigurationPageByName(pageName) 1529 self.cw.showConfigurationPageByName(pageName)
1160 1530
1161 def accept(self): 1531 def accept(self):
1162 """ 1532 """
1163 Public slot called by the Ok button. 1533 Public slot called by the Ok button.
1164 """ 1534 """
1165 self.cw.setPreferences() 1535 self.cw.setPreferences()

eric ide

mercurial