Preferences/ConfigurationDialog.py

changeset 3010
befeff46ec0f
parent 2964
84b65fb9e780
child 3020
542e97d4ecb3
child 3057
10516539f238
equal deleted inserted replaced
3009:bf5ae5d7477d 3010:befeff46ec0f
9 9
10 import os 10 import os
11 import types 11 import types
12 12
13 from PyQt4.QtCore import QMetaObject, pyqtSignal, Qt, QRect, pyqtSlot 13 from PyQt4.QtCore import QMetaObject, pyqtSignal, Qt, QRect, pyqtSlot
14 from PyQt4.QtGui import QSizePolicy, QSpacerItem, QWidget, QPixmap, QTreeWidget, \ 14 from PyQt4.QtGui import QSizePolicy, QSpacerItem, QWidget, QPixmap, \
15 QStackedWidget, QDialog, QSplitter, QScrollArea, QApplication, QDialogButtonBox, \ 15 QTreeWidget, QStackedWidget, QDialog, QSplitter, QScrollArea, \
16 QFrame, QVBoxLayout, QTreeWidgetItem, QLabel 16 QApplication, QDialogButtonBox, QFrame, QVBoxLayout, QTreeWidgetItem, \
17 QLabel
17 18
18 from E5Gui.E5Application import e5App 19 from E5Gui.E5Application import e5App
19 from E5Gui.E5LineEdit import E5ClearableLineEdit 20 from E5Gui.E5LineEdit import E5ClearableLineEdit
20 from E5Gui import E5MessageBox 21 from E5Gui import E5MessageBox
21 from E5Gui.E5MainWindow import E5MainWindow 22 from E5Gui.E5MainWindow import E5MainWindow
35 """ 36 """
36 def __init__(self, parent, text, pageName, iconFile): 37 def __init__(self, parent, text, pageName, iconFile):
37 """ 38 """
38 Constructor 39 Constructor
39 40
40 @param parent parent widget of the item (QTreeWidget or QTreeWidgetItem) 41 @param parent parent widget of the item (QTreeWidget or
42 QTreeWidgetItem)
41 @param text text to be displayed (string) 43 @param text text to be displayed (string)
42 @param pageName name of the configuration page (string) 44 @param pageName name of the configuration page (string)
43 @param iconFile file name of the icon to be shown (string) 45 @param iconFile file name of the icon to be shown (string)
44 """ 46 """
45 super().__init__(parent, [text]) 47 super().__init__(parent, [text])
111 if displayMode == ConfigurationWidget.DefaultMode: 113 if displayMode == ConfigurationWidget.DefaultMode:
112 self.configItems = { 114 self.configItems = {
113 # key : [display string, pixmap name, dialog module name or 115 # key : [display string, pixmap name, dialog module name or
114 # page creation function, parent key, 116 # page creation function, parent key,
115 # reference to configuration page (must always be last)] 117 # reference to configuration page (must always be last)]
116 # The dialog module must have the module function create to create 118 # The dialog module must have the module function create to
117 # the configuration page. This must have the method save to save 119 # create the configuration page. This must have the method
118 # the settings. 120 # save to save the settings.
119 "applicationPage": \ 121 "applicationPage": \
120 [self.trUtf8("Application"), "preferences-application.png", 122 [self.trUtf8("Application"), "preferences-application.png",
121 "ApplicationPage", None, None], 123 "ApplicationPage", None, None],
122 "cooperationPage": \ 124 "cooperationPage": \
123 [self.trUtf8("Cooperation"), "preferences-cooperation.png", 125 [self.trUtf8("Cooperation"), "preferences-cooperation.png",
124 "CooperationPage", None, None], 126 "CooperationPage", None, None],
125 "corbaPage": \ 127 "corbaPage": \
126 [self.trUtf8("CORBA"), "preferences-orbit.png", 128 [self.trUtf8("CORBA"), "preferences-orbit.png",
127 "CorbaPage", None, None], 129 "CorbaPage", None, None],
128 "emailPage": \ 130 "emailPage": \
129 [self.trUtf8("Email"), "preferences-mail_generic.png", 131 [self.trUtf8("Email"), "preferences-mail_generic.png",
130 "EmailPage", None, None], 132 "EmailPage", None, None],
131 "graphicsPage": \ 133 "graphicsPage": \
132 [self.trUtf8("Graphics"), "preferences-graphics.png", 134 [self.trUtf8("Graphics"), "preferences-graphics.png",
133 "GraphicsPage", None, None], 135 "GraphicsPage", None, None],
134 "iconsPage": \ 136 "iconsPage": \
135 [self.trUtf8("Icons"), "preferences-icons.png", 137 [self.trUtf8("Icons"), "preferences-icons.png",
136 "IconsPage", None, None], 138 "IconsPage", None, None],
137 "ircPage": \ 139 "ircPage": \
138 [self.trUtf8("IRC"), "irc.png", 140 [self.trUtf8("IRC"), "irc.png",
139 "IrcPage", None, None], 141 "IrcPage", None, None],
140 "networkPage": \ 142 "networkPage": \
141 [self.trUtf8("Network"), "preferences-network.png", 143 [self.trUtf8("Network"), "preferences-network.png",
142 "NetworkPage", None, None], 144 "NetworkPage", None, None],
143 "notificationsPage": \ 145 "notificationsPage": \
144 [self.trUtf8("Notifications"), "preferences-notifications.png", 146 [self.trUtf8("Notifications"),
145 "NotificationsPage", None, None], 147 "preferences-notifications.png",
148 "NotificationsPage", None, None],
146 "pluginManagerPage": \ 149 "pluginManagerPage": \
147 [self.trUtf8("Plugin Manager"), "preferences-pluginmanager.png", 150 [self.trUtf8("Plugin Manager"),
148 "PluginManagerPage", None, None], 151 "preferences-pluginmanager.png",
152 "PluginManagerPage", None, None],
149 "printerPage": \ 153 "printerPage": \
150 [self.trUtf8("Printer"), "preferences-printer.png", 154 [self.trUtf8("Printer"), "preferences-printer.png",
151 "PrinterPage", None, None], 155 "PrinterPage", None, None],
152 "pythonPage": \ 156 "pythonPage": \
153 [self.trUtf8("Python"), "preferences-python.png", 157 [self.trUtf8("Python"), "preferences-python.png",
154 "PythonPage", None, None], 158 "PythonPage", None, None],
155 "qtPage": \ 159 "qtPage": \
156 [self.trUtf8("Qt"), "preferences-qtlogo.png", 160 [self.trUtf8("Qt"), "preferences-qtlogo.png",
157 "QtPage", None, None], 161 "QtPage", None, None],
158 "securityPage": \ 162 "securityPage": \
159 [self.trUtf8("Security"), "preferences-security.png", 163 [self.trUtf8("Security"), "preferences-security.png",
160 "SecurityPage", None, None], 164 "SecurityPage", None, None],
161 "shellPage": \ 165 "shellPage": \
162 [self.trUtf8("Shell"), "preferences-shell.png", 166 [self.trUtf8("Shell"), "preferences-shell.png",
163 "ShellPage", None, None], 167 "ShellPage", None, None],
164 "tasksPage": \ 168 "tasksPage": \
165 [self.trUtf8("Tasks"), "task.png", 169 [self.trUtf8("Tasks"), "task.png",
166 "TasksPage", None, None], 170 "TasksPage", None, None],
167 "templatesPage": \ 171 "templatesPage": \
168 [self.trUtf8("Templates"), "preferences-template.png", 172 [self.trUtf8("Templates"), "preferences-template.png",
169 "TemplatesPage", None, None], 173 "TemplatesPage", None, None],
170 "trayStarterPage": \ 174 "trayStarterPage": \
171 [self.trUtf8("Tray Starter"), "erict.png", 175 [self.trUtf8("Tray Starter"), "erict.png",
172 "TrayStarterPage", None, None], 176 "TrayStarterPage", None, None],
173 "vcsPage": \ 177 "vcsPage": \
174 [self.trUtf8("Version Control Systems"), "preferences-vcs.png", 178 [self.trUtf8("Version Control Systems"),
175 "VcsPage", None, None], 179 "preferences-vcs.png",
180 "VcsPage", None, None],
176 181
177 "0debuggerPage": \ 182 "0debuggerPage": \
178 [self.trUtf8("Debugger"), "preferences-debugger.png", 183 [self.trUtf8("Debugger"), "preferences-debugger.png",
179 None, None, None], 184 None, None, None],
180 "debuggerGeneralPage": \ 185 "debuggerGeneralPage": \
181 [self.trUtf8("General"), "preferences-debugger.png", 186 [self.trUtf8("General"), "preferences-debugger.png",
182 "DebuggerGeneralPage", "0debuggerPage", None], 187 "DebuggerGeneralPage", "0debuggerPage", None],
183 "debuggerPythonPage": \ 188 "debuggerPythonPage": \
184 [self.trUtf8("Python"), "preferences-pyDebugger.png", 189 [self.trUtf8("Python"), "preferences-pyDebugger.png",
185 "DebuggerPythonPage", "0debuggerPage", None], 190 "DebuggerPythonPage", "0debuggerPage", None],
186 "debuggerPython3Page": \ 191 "debuggerPython3Page": \
187 [self.trUtf8("Python3"), "preferences-pyDebugger.png", 192 [self.trUtf8("Python3"), "preferences-pyDebugger.png",
188 "DebuggerPython3Page", "0debuggerPage", None], 193 "DebuggerPython3Page", "0debuggerPage", None],
189 "debuggerRubyPage": \ 194 "debuggerRubyPage": \
190 [self.trUtf8("Ruby"), "preferences-rbDebugger.png", 195 [self.trUtf8("Ruby"), "preferences-rbDebugger.png",
191 "DebuggerRubyPage", "0debuggerPage", None], 196 "DebuggerRubyPage", "0debuggerPage", None],
192 197
193 "0editorPage": \ 198 "0editorPage": \
194 [self.trUtf8("Editor"), "preferences-editor.png", 199 [self.trUtf8("Editor"), "preferences-editor.png",
195 None, None, None], 200 None, None, None],
196 "editorAPIsPage": \ 201 "editorAPIsPage": \
197 [self.trUtf8("APIs"), "preferences-api.png", 202 [self.trUtf8("APIs"), "preferences-api.png",
198 "EditorAPIsPage", "0editorPage", None], 203 "EditorAPIsPage", "0editorPage", None],
199 "editorAutocompletionPage": \ 204 "editorAutocompletionPage": \
200 [self.trUtf8("Autocompletion"), "preferences-autocompletion.png", 205 [self.trUtf8("Autocompletion"),
201 "EditorAutocompletionPage", "0editorPage", None], 206 "preferences-autocompletion.png",
207 "EditorAutocompletionPage", "0editorPage", None],
202 "editorAutocompletionQScintillaPage": \ 208 "editorAutocompletionQScintillaPage": \
203 [self.trUtf8("QScintilla"), "qscintilla.png", 209 [self.trUtf8("QScintilla"), "qscintilla.png",
204 "EditorAutocompletionQScintillaPage", 210 "EditorAutocompletionQScintillaPage",
205 "editorAutocompletionPage", None], 211 "editorAutocompletionPage", None],
206 "editorCalltipsPage": \ 212 "editorCalltipsPage": \
207 [self.trUtf8("Calltips"), "preferences-calltips.png", 213 [self.trUtf8("Calltips"), "preferences-calltips.png",
208 "EditorCalltipsPage", "0editorPage", None], 214 "EditorCalltipsPage", "0editorPage", None],
209 "editorCalltipsQScintillaPage": \ 215 "editorCalltipsQScintillaPage": \
210 [self.trUtf8("QScintilla"), "qscintilla.png", 216 [self.trUtf8("QScintilla"), "qscintilla.png",
211 "EditorCalltipsQScintillaPage", "editorCalltipsPage", None], 217 "EditorCalltipsQScintillaPage", "editorCalltipsPage",
218 None],
212 "editorGeneralPage": \ 219 "editorGeneralPage": \
213 [self.trUtf8("General"), "preferences-general.png", 220 [self.trUtf8("General"), "preferences-general.png",
214 "EditorGeneralPage", "0editorPage", None], 221 "EditorGeneralPage", "0editorPage", None],
215 "editorFilePage": \ 222 "editorFilePage": \
216 [self.trUtf8("Filehandling"), "preferences-filehandling.png", 223 [self.trUtf8("Filehandling"),
217 "EditorFilePage", "0editorPage", None], 224 "preferences-filehandling.png",
225 "EditorFilePage", "0editorPage", None],
218 "editorSearchPage": \ 226 "editorSearchPage": \
219 [self.trUtf8("Searching"), "preferences-search.png", 227 [self.trUtf8("Searching"), "preferences-search.png",
220 "EditorSearchPage", "0editorPage", None], 228 "EditorSearchPage", "0editorPage", None],
221 "editorSpellCheckingPage": \ 229 "editorSpellCheckingPage": \
222 [self.trUtf8("Spell checking"), "preferences-spellchecking.png", 230 [self.trUtf8("Spell checking"),
223 "EditorSpellCheckingPage", "0editorPage", None], 231 "preferences-spellchecking.png",
232 "EditorSpellCheckingPage", "0editorPage", None],
224 "editorStylesPage": \ 233 "editorStylesPage": \
225 [self.trUtf8("Style"), "preferences-styles.png", 234 [self.trUtf8("Style"), "preferences-styles.png",
226 "EditorStylesPage", "0editorPage", None], 235 "EditorStylesPage", "0editorPage", None],
227 "editorSyntaxPage": \ 236 "editorSyntaxPage": \
228 [self.trUtf8("Code Checkers"), "preferences-debugger.png", 237 [self.trUtf8("Code Checkers"), "preferences-debugger.png",
229 "EditorSyntaxPage", "0editorPage", None], 238 "EditorSyntaxPage", "0editorPage", None],
230 "editorTypingPage": \ 239 "editorTypingPage": \
231 [self.trUtf8("Typing"), "preferences-typing.png", 240 [self.trUtf8("Typing"), "preferences-typing.png",
232 "EditorTypingPage", "0editorPage", None], 241 "EditorTypingPage", "0editorPage", None],
233 "editorExportersPage": \ 242 "editorExportersPage": \
234 [self.trUtf8("Exporters"), "preferences-exporters.png", 243 [self.trUtf8("Exporters"), "preferences-exporters.png",
235 "EditorExportersPage", "0editorPage", None], 244 "EditorExportersPage", "0editorPage", None],
236 245
237 "1editorLexerPage": \ 246 "1editorLexerPage": \
238 [self.trUtf8("Highlighters"), "preferences-highlighting-styles.png", 247 [self.trUtf8("Highlighters"),
239 None, "0editorPage", None], 248 "preferences-highlighting-styles.png",
249 None, "0editorPage", None],
240 "editorHighlightersPage": \ 250 "editorHighlightersPage": \
241 [self.trUtf8("Filetype Associations"), 251 [self.trUtf8("Filetype Associations"),
242 "preferences-highlighter-association.png", 252 "preferences-highlighter-association.png",
243 "EditorHighlightersPage", "1editorLexerPage", None], 253 "EditorHighlightersPage", "1editorLexerPage", None],
244 "editorHighlightingStylesPage": \ 254 "editorHighlightingStylesPage": \
245 [self.trUtf8("Styles"), 255 [self.trUtf8("Styles"),
246 "preferences-highlighting-styles.png", 256 "preferences-highlighting-styles.png",
247 "EditorHighlightingStylesPage", "1editorLexerPage", None], 257 "EditorHighlightingStylesPage", "1editorLexerPage", None],
248 "editorKeywordsPage": \ 258 "editorKeywordsPage": \
249 [self.trUtf8("Keywords"), "preferences-keywords.png", 259 [self.trUtf8("Keywords"), "preferences-keywords.png",
250 "EditorKeywordsPage", "1editorLexerPage", None], 260 "EditorKeywordsPage", "1editorLexerPage", None],
251 "editorPropertiesPage": \ 261 "editorPropertiesPage": \
252 [self.trUtf8("Properties"), "preferences-properties.png", 262 [self.trUtf8("Properties"), "preferences-properties.png",
253 "EditorPropertiesPage", "1editorLexerPage", None], 263 "EditorPropertiesPage", "1editorLexerPage", None],
254 264
255 "0helpPage": \ 265 "0helpPage": \
256 [self.trUtf8("Help"), "preferences-help.png", 266 [self.trUtf8("Help"), "preferences-help.png",
257 None, None, None], 267 None, None, None],
258 "helpAppearancePage": \ 268 "helpAppearancePage": \
259 [self.trUtf8("Appearance"), "preferences-styles.png", 269 [self.trUtf8("Appearance"), "preferences-styles.png",
260 "HelpAppearancePage", "0helpPage", None], 270 "HelpAppearancePage", "0helpPage", None],
261 "helpDocumentationPage": \ 271 "helpDocumentationPage": \
262 [self.trUtf8("Help Documentation"), 272 [self.trUtf8("Help Documentation"),
263 "preferences-helpdocumentation.png", 273 "preferences-helpdocumentation.png",
264 "HelpDocumentationPage", "0helpPage", None], 274 "HelpDocumentationPage", "0helpPage", None],
265 "helpViewersPage": \ 275 "helpViewersPage": \
266 [self.trUtf8("Help Viewers"), "preferences-helpviewers.png", 276 [self.trUtf8("Help Viewers"),
267 "HelpViewersPage", "0helpPage", None], 277 "preferences-helpviewers.png",
278 "HelpViewersPage", "0helpPage", None],
268 "helpVirusTotalPage": \ 279 "helpVirusTotalPage": \
269 [self.trUtf8("VirusTotal Interface"), "virustotal.png", 280 [self.trUtf8("VirusTotal Interface"), "virustotal.png",
270 "HelpVirusTotalPage", "0helpPage", None], 281 "HelpVirusTotalPage", "0helpPage", None],
271 "helpWebBrowserPage": \ 282 "helpWebBrowserPage": \
272 [self.trUtf8("eric5 Web Browser"), "ericWeb.png", 283 [self.trUtf8("eric5 Web Browser"), "ericWeb.png",
273 "HelpWebBrowserPage", "0helpPage", None], 284 "HelpWebBrowserPage", "0helpPage", None],
274 285
275 "0projectPage": \ 286 "0projectPage": \
276 [self.trUtf8("Project"), "preferences-project.png", 287 [self.trUtf8("Project"), "preferences-project.png",
277 None, None, None], 288 None, None, None],
278 "projectBrowserPage": \ 289 "projectBrowserPage": \
279 [self.trUtf8("Project Viewer"), "preferences-project.png", 290 [self.trUtf8("Project Viewer"), "preferences-project.png",
280 "ProjectBrowserPage", "0projectPage", None], 291 "ProjectBrowserPage", "0projectPage", None],
281 "projectPage": \ 292 "projectPage": \
282 [self.trUtf8("Project"), "preferences-project.png", 293 [self.trUtf8("Project"), "preferences-project.png",
283 "ProjectPage", "0projectPage", None], 294 "ProjectPage", "0projectPage", None],
284 "multiProjectPage": \ 295 "multiProjectPage": \
285 [self.trUtf8("Multiproject"), "preferences-multiproject.png", 296 [self.trUtf8("Multiproject"),
286 "MultiProjectPage", "0projectPage", None], 297 "preferences-multiproject.png",
298 "MultiProjectPage", "0projectPage", None],
287 299
288 "0interfacePage": \ 300 "0interfacePage": \
289 [self.trUtf8("Interface"), "preferences-interface.png", 301 [self.trUtf8("Interface"), "preferences-interface.png",
290 None, None, None], 302 None, None, None],
291 "interfacePage": \ 303 "interfacePage": \
292 [self.trUtf8("Interface"), "preferences-interface.png", 304 [self.trUtf8("Interface"), "preferences-interface.png",
293 "InterfacePage", "0interfacePage", None], 305 "InterfacePage", "0interfacePage", None],
294 "viewmanagerPage": \ 306 "viewmanagerPage": \
295 [self.trUtf8("Viewmanager"), "preferences-viewmanager.png", 307 [self.trUtf8("Viewmanager"), "preferences-viewmanager.png",
296 "ViewmanagerPage", "0interfacePage", None], 308 "ViewmanagerPage", "0interfacePage", None],
297 } 309 }
298 310
299 self.configItems.update( 311 self.configItems.update(
300 e5App().getObject("PluginManager").getPluginConfigData()) 312 e5App().getObject("PluginManager").getPluginConfigData())
301 elif displayMode == ConfigurationWidget.HelpBrowserMode: 313 elif displayMode == ConfigurationWidget.HelpBrowserMode:
302 self.configItems = { 314 self.configItems = {
303 # key : [display string, pixmap name, dialog module name or 315 # key : [display string, pixmap name, dialog module name or
304 # page creation function, parent key, 316 # page creation function, parent key,
305 # reference to configuration page (must always be last)] 317 # reference to configuration page (must always be last)]
306 # The dialog module must have the module function create to create 318 # The dialog module must have the module function create to
307 # the configuration page. This must have the method save to save 319 # create the configuration page. This must have the method
308 # the settings. 320 # save to save the settings.
309 "interfacePage": \ 321 "interfacePage": \
310 [self.trUtf8("Interface"), "preferences-interface.png", 322 [self.trUtf8("Interface"), "preferences-interface.png",
311 "HelpInterfacePage", None, None], 323 "HelpInterfacePage", None, None],
312 "networkPage": \ 324 "networkPage": \
313 [self.trUtf8("Network"), "preferences-network.png", 325 [self.trUtf8("Network"), "preferences-network.png",
314 "NetworkPage", None, None], 326 "NetworkPage", None, None],
315 "printerPage": \ 327 "printerPage": \
316 [self.trUtf8("Printer"), "preferences-printer.png", 328 [self.trUtf8("Printer"), "preferences-printer.png",
317 "PrinterPage", None, None], 329 "PrinterPage", None, None],
318 "securityPage": \ 330 "securityPage": \
319 [self.trUtf8("Security"), "preferences-security.png", 331 [self.trUtf8("Security"), "preferences-security.png",
320 "SecurityPage", None, None], 332 "SecurityPage", None, None],
321 333
322 "0helpPage": \ 334 "0helpPage": \
323 [self.trUtf8("Help"), "preferences-help.png", 335 [self.trUtf8("Help"), "preferences-help.png",
324 None, None, None], 336 None, None, None],
325 "helpAppearancePage": \ 337 "helpAppearancePage": \
326 [self.trUtf8("Appearance"), "preferences-styles.png", 338 [self.trUtf8("Appearance"), "preferences-styles.png",
327 "HelpAppearancePage", "0helpPage", None], 339 "HelpAppearancePage", "0helpPage", None],
328 "helpDocumentationPage": \ 340 "helpDocumentationPage": \
329 [self.trUtf8("Help Documentation"), 341 [self.trUtf8("Help Documentation"),
330 "preferences-helpdocumentation.png", 342 "preferences-helpdocumentation.png",
331 "HelpDocumentationPage", "0helpPage", None], 343 "HelpDocumentationPage", "0helpPage", None],
332 "helpVirusTotalPage": \ 344 "helpVirusTotalPage": \
333 [self.trUtf8("VirusTotal Interface"), "virustotal.png", 345 [self.trUtf8("VirusTotal Interface"), "virustotal.png",
334 "HelpVirusTotalPage", "0helpPage", None], 346 "HelpVirusTotalPage", "0helpPage", None],
335 "helpWebBrowserPage": \ 347 "helpWebBrowserPage": \
336 [self.trUtf8("eric5 Web Browser"), "ericWeb.png", 348 [self.trUtf8("eric5 Web Browser"), "ericWeb.png",
337 "HelpWebBrowserPage", "0helpPage", None], 349 "HelpWebBrowserPage", "0helpPage", None],
338 } 350 }
339 elif displayMode == ConfigurationWidget.TrayStarterMode: 351 elif displayMode == ConfigurationWidget.TrayStarterMode:
340 self.configItems = { 352 self.configItems = {
341 # key : [display string, pixmap name, dialog module name or 353 # key : [display string, pixmap name, dialog module name or
342 # page creation function, parent key, 354 # page creation function, parent key,
343 # reference to configuration page (must always be last)] 355 # reference to configuration page (must always be last)]
344 # The dialog module must have the module function create to create 356 # The dialog module must have the module function create to
345 # the configuration page. This must have the method save to save 357 # create the configuration page. This must have the method
346 # the settings. 358 # save to save the settings.
347 "trayStarterPage": \ 359 "trayStarterPage": \
348 [self.trUtf8("Tray Starter"), "erict.png", 360 [self.trUtf8("Tray Starter"), "erict.png",
349 "TrayStarterPage", None, None], 361 "TrayStarterPage", None, None],
350 } 362 }
351 else: 363 else:
352 raise RuntimeError("Illegal mode value: {0}".format(displayMode)) 364 raise RuntimeError("Illegal mode value: {0}".format(displayMode))
353 365
354 # generate the list entries 366 # generate the list entries
356 pageData = self.configItems[key] 368 pageData = self.configItems[key]
357 if pageData[3]: 369 if pageData[3]:
358 pitm = self.itmDict[pageData[3]] # get the parent item 370 pitm = self.itmDict[pageData[3]] # get the parent item
359 else: 371 else:
360 pitm = self.configList 372 pitm = self.configList
361 self.itmDict[key] = ConfigurationPageItem(pitm, pageData[0], key, pageData[1]) 373 self.itmDict[key] = ConfigurationPageItem(pitm, pageData[0], key,
374 pageData[1])
362 self.itmDict[key].setExpanded(True) 375 self.itmDict[key].setExpanded(True)
363 self.configList.sortByColumn(0, Qt.AscendingOrder) 376 self.configList.sortByColumn(0, Qt.AscendingOrder)
364 377
365 # set the initial size of the splitter 378 # set the initial size of the splitter
366 self.configSplitter.setSizes([200, 600]) 379 self.configSplitter.setSizes([200, 600])
384 397
385 self.accepted.emit() 398 self.accepted.emit()
386 399
387 def __setupUi(self): 400 def __setupUi(self):
388 """ 401 """
389 Private method to perform the general setup of the configuration widget. 402 Private method to perform the general setup of the configuration
403 widget.
390 """ 404 """
391 self.setObjectName("ConfigurationDialog") 405 self.setObjectName("ConfigurationDialog")
392 self.resize(900, 650) 406 self.resize(900, 650)
393 self.verticalLayout_2 = QVBoxLayout(self) 407 self.verticalLayout_2 = QVBoxLayout(self)
394 self.verticalLayout_2.setSpacing(6) 408 self.verticalLayout_2.setSpacing(6)
431 self.emptyPage.setObjectName("emptyPage") 445 self.emptyPage.setObjectName("emptyPage")
432 self.vboxlayout = QVBoxLayout(self.emptyPage) 446 self.vboxlayout = QVBoxLayout(self.emptyPage)
433 self.vboxlayout.setSpacing(6) 447 self.vboxlayout.setSpacing(6)
434 self.vboxlayout.setContentsMargins(6, 6, 6, 6) 448 self.vboxlayout.setContentsMargins(6, 6, 6, 6)
435 self.vboxlayout.setObjectName("vboxlayout") 449 self.vboxlayout.setObjectName("vboxlayout")
436 spacerItem = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) 450 spacerItem = QSpacerItem(
451 20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)
437 self.vboxlayout.addItem(spacerItem) 452 self.vboxlayout.addItem(spacerItem)
438 self.emptyPagePixmap = QLabel(self.emptyPage) 453 self.emptyPagePixmap = QLabel(self.emptyPage)
439 self.emptyPagePixmap.setAlignment(Qt.AlignCenter) 454 self.emptyPagePixmap.setAlignment(Qt.AlignCenter)
440 self.emptyPagePixmap.setObjectName("emptyPagePixmap") 455 self.emptyPagePixmap.setObjectName("emptyPagePixmap")
441 self.emptyPagePixmap.setPixmap( 456 self.emptyPagePixmap.setPixmap(
443 self.vboxlayout.addWidget(self.emptyPagePixmap) 458 self.vboxlayout.addWidget(self.emptyPagePixmap)
444 self.textLabel1 = QLabel(self.emptyPage) 459 self.textLabel1 = QLabel(self.emptyPage)
445 self.textLabel1.setAlignment(Qt.AlignCenter) 460 self.textLabel1.setAlignment(Qt.AlignCenter)
446 self.textLabel1.setObjectName("textLabel1") 461 self.textLabel1.setObjectName("textLabel1")
447 self.vboxlayout.addWidget(self.textLabel1) 462 self.vboxlayout.addWidget(self.textLabel1)
448 spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 463 spacerItem1 = QSpacerItem(
464 20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
449 self.vboxlayout.addItem(spacerItem1) 465 self.vboxlayout.addItem(spacerItem1)
450 self.configStack.addWidget(self.emptyPage) 466 self.configStack.addWidget(self.emptyPage)
451 467
452 self.verticalLayout_2.addWidget(self.configSplitter) 468 self.verticalLayout_2.addWidget(self.configSplitter)
453 469
455 self.buttonBox.setOrientation(Qt.Horizontal) 471 self.buttonBox.setOrientation(Qt.Horizontal)
456 self.buttonBox.setStandardButtons( 472 self.buttonBox.setStandardButtons(
457 QDialogButtonBox.Apply | QDialogButtonBox.Cancel | \ 473 QDialogButtonBox.Apply | QDialogButtonBox.Cancel | \
458 QDialogButtonBox.Ok | QDialogButtonBox.Reset) 474 QDialogButtonBox.Ok | QDialogButtonBox.Reset)
459 self.buttonBox.setObjectName("buttonBox") 475 self.buttonBox.setObjectName("buttonBox")
460 if not self.fromEric and self.displayMode == ConfigurationWidget.DefaultMode: 476 if not self.fromEric and \
477 self.displayMode == ConfigurationWidget.DefaultMode:
461 self.buttonBox.button(QDialogButtonBox.Apply).hide() 478 self.buttonBox.button(QDialogButtonBox.Apply).hide()
462 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False) 479 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False)
463 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False) 480 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False)
464 self.verticalLayout_2.addWidget(self.buttonBox) 481 self.verticalLayout_2.addWidget(self.buttonBox)
465 482
466 self.setWindowTitle(self.trUtf8("Preferences")) 483 self.setWindowTitle(self.trUtf8("Preferences"))
467 484
468 self.configList.header().hide() 485 self.configList.header().hide()
469 self.configList.header().setSortIndicator(0, Qt.AscendingOrder) 486 self.configList.header().setSortIndicator(0, Qt.AscendingOrder)
470 self.configList.setSortingEnabled(True) 487 self.configList.setSortingEnabled(True)
471 self.textLabel1.setText(self.trUtf8("Please select an entry of the list \n" 488 self.textLabel1.setText(
472 "to display the configuration page.")) 489 self.trUtf8("Please select an entry of the list \n"
490 "to display the configuration page."))
473 491
474 QMetaObject.connectSlotsByName(self) 492 QMetaObject.connectSlotsByName(self)
475 self.setTabOrder(self.configList, self.configStack) 493 self.setTabOrder(self.configList, self.configStack)
476 494
477 self.configStack.setCurrentWidget(self.emptyPage) 495 self.configStack.setCurrentWidget(self.emptyPage)
511 def __initLexers(self): 529 def __initLexers(self):
512 """ 530 """
513 Private method to initialize the dictionary of preferences lexers. 531 Private method to initialize the dictionary of preferences lexers.
514 """ 532 """
515 import QScintilla.Lexers 533 import QScintilla.Lexers
516 from .PreferencesLexer import PreferencesLexer, PreferencesLexerLanguageError 534 from .PreferencesLexer import PreferencesLexer, \
535 PreferencesLexerLanguageError
517 536
518 self.lexers = {} 537 self.lexers = {}
519 for language in QScintilla.Lexers.getSupportedLanguages(): 538 for language in QScintilla.Lexers.getSupportedLanguages():
520 if language not in self.lexers: 539 if language not in self.lexers:
521 try: 540 try:
602 self.configList.setCurrentItem(items[0]) 621 self.configList.setCurrentItem(items[0])
603 self.configStack.setCurrentWidget(page) 622 self.configStack.setCurrentWidget(page)
604 ssize = self.scrollArea.size() 623 ssize = self.scrollArea.size()
605 if self.scrollArea.horizontalScrollBar(): 624 if self.scrollArea.horizontalScrollBar():
606 ssize.setHeight( 625 ssize.setHeight(
607 ssize.height() - self.scrollArea.horizontalScrollBar().height() - 2) 626 ssize.height() -
627 self.scrollArea.horizontalScrollBar().height() - 2)
608 if self.scrollArea.verticalScrollBar(): 628 if self.scrollArea.verticalScrollBar():
609 ssize.setWidth( 629 ssize.setWidth(
610 ssize.width() - self.scrollArea.verticalScrollBar().width() - 2) 630 ssize.width() -
631 self.scrollArea.verticalScrollBar().width() - 2)
611 psize = page.minimumSizeHint() 632 psize = page.minimumSizeHint()
612 self.configStack.resize(max(ssize.width(), psize.width()), 633 self.configStack.resize(max(ssize.width(), psize.width()),
613 max(ssize.height(), psize.height())) 634 max(ssize.height(), psize.height()))
614 635
615 if page != self.emptyPage: 636 if page != self.emptyPage:
662 """ 683 """
663 return self.lexers 684 return self.lexers
664 685
665 def setPreferences(self): 686 def setPreferences(self):
666 """ 687 """
667 Public method called to store the selected values into the preferences storage. 688 Public method called to store the selected values into the preferences
689 storage.
668 """ 690 """
669 for key, pageData in list(self.configItems.items()): 691 for key, pageData in list(self.configItems.items()):
670 if pageData[-1]: 692 if pageData[-1]:
671 pageData[-1].save() 693 pageData[-1].save()
672 # page was loaded (and possibly modified) 694 # page was loaded (and possibly modified)
793 """ 815 """
794 return self.cw.getConfigurationPageName() 816 return self.cw.getConfigurationPageName()
795 817
796 def setPreferences(self): 818 def setPreferences(self):
797 """ 819 """
798 Public method called to store the selected values into the preferences storage. 820 Public method called to store the selected values into the preferences
821 storage.
799 """ 822 """
800 self.cw.setPreferences() 823 self.cw.setPreferences()
801 824
802 def accept(self): 825 def accept(self):
803 """ 826 """
821 self.cw = ConfigurationWidget(self, fromEric=False) 844 self.cw = ConfigurationWidget(self, fromEric=False)
822 size = self.cw.size() 845 size = self.cw.size()
823 self.setCentralWidget(self.cw) 846 self.setCentralWidget(self.cw)
824 self.resize(size) 847 self.resize(size)
825 848
826 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) 849 self.setStyle(Preferences.getUI("Style"),
850 Preferences.getUI("StyleSheet"))
827 851
828 self.cw.accepted[()].connect(self.accept) 852 self.cw.accepted[()].connect(self.accept)
829 self.cw.rejected[()].connect(self.close) 853 self.cw.rejected[()].connect(self.close)
830 854
831 def showConfigurationPageByName(self, pageName): 855 def showConfigurationPageByName(self, pageName):

eric ide

mercurial