Preferences/ConfigurationDialog.py

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

eric ide

mercurial