Preferences/ConfigurationDialog.py

changeset 945
8cd4d08fa9f6
parent 934
657269549914
child 978
11f8adbcac97
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
22 22
23 from .PreferencesLexer import PreferencesLexer, PreferencesLexerLanguageError 23 from .PreferencesLexer import PreferencesLexer, PreferencesLexerLanguageError
24 import UI.PixmapCache 24 import UI.PixmapCache
25 25
26 from eric5config import getConfig 26 from eric5config import getConfig
27
27 28
28 class ConfigurationPageItem(QTreeWidgetItem): 29 class ConfigurationPageItem(QTreeWidgetItem):
29 """ 30 """
30 Class implementing a QTreeWidgetItem holding the configuration page data. 31 Class implementing a QTreeWidgetItem holding the configuration page data.
31 """ 32 """
48 Public method to get the name of the associated configuration page. 49 Public method to get the name of the associated configuration page.
49 50
50 @return name of the configuration page (string) 51 @return name of the configuration page (string)
51 """ 52 """
52 return self.__pageName 53 return self.__pageName
54
53 55
54 class ConfigurationWidget(QWidget): 56 class ConfigurationWidget(QWidget):
55 """ 57 """
56 Class implementing a dialog for the configuration of eric5. 58 Class implementing a dialog for the configuration of eric5.
57 59
58 @signal preferencesChanged() emitted after settings have been changed 60 @signal preferencesChanged() emitted after settings have been changed
59 """ 61 """
60 preferencesChanged = pyqtSignal() 62 preferencesChanged = pyqtSignal()
61 63
62 DefaultMode = 0 64 DefaultMode = 0
63 HelpBrowserMode = 1 65 HelpBrowserMode = 1
64 TrayStarterMode = 2 66 TrayStarterMode = 2
65 67
66 def __init__(self, parent = None, fromEric = True, displayMode = DefaultMode): 68 def __init__(self, parent=None, fromEric=True, displayMode=DefaultMode):
67 """ 69 """
68 Constructor 70 Constructor
69 71
70 @param parent The parent widget of this dialog. (QWidget) 72 @param parent The parent widget of this dialog. (QWidget)
71 @keyparam fromEric flag indicating a dialog generation from within the 73 @keyparam fromEric flag indicating a dialog generation from within the
72 eric5 ide (boolean) 74 eric5 ide (boolean)
73 @keyparam displayMode mode of the configuration dialog 75 @keyparam displayMode mode of the configuration dialog
74 (DefaultMode, HelpBrowserMode, TrayStarterMode) 76 (DefaultMode, HelpBrowserMode, TrayStarterMode)
75 """ 77 """
76 assert displayMode in ( 78 assert displayMode in (
77 ConfigurationWidget.DefaultMode, 79 ConfigurationWidget.DefaultMode,
78 ConfigurationWidget.HelpBrowserMode, 80 ConfigurationWidget.HelpBrowserMode,
79 ConfigurationWidget.TrayStarterMode 81 ConfigurationWidget.TrayStarterMode
80 ) 82 )
81 83
82 QWidget.__init__(self, parent) 84 QWidget.__init__(self, parent)
83 self.fromEric = fromEric 85 self.fromEric = fromEric
95 self.pluginManager = PluginManager(self) 97 self.pluginManager = PluginManager(self)
96 e5App().registerObject("PluginManager", self.pluginManager) 98 e5App().registerObject("PluginManager", self.pluginManager)
97 99
98 if displayMode == ConfigurationWidget.DefaultMode: 100 if displayMode == ConfigurationWidget.DefaultMode:
99 self.configItems = { 101 self.configItems = {
100 # key : [display string, pixmap name, dialog module name or 102 # key : [display string, pixmap name, dialog module name or
101 # page creation function, parent key, 103 # page creation function, parent key,
102 # reference to configuration page (must always be last)] 104 # reference to configuration page (must always be last)]
103 # The dialog module must have the module function create to create 105 # The dialog module must have the module function create to create
104 # the configuration page. This must have the method save to save 106 # the configuration page. This must have the method save to save
105 # the settings. 107 # the settings.
106 "applicationPage" : \ 108 "applicationPage": \
107 [self.trUtf8("Application"), "preferences-application.png", 109 [self.trUtf8("Application"), "preferences-application.png",
108 "ApplicationPage", None, None], 110 "ApplicationPage", None, None],
109 "cooperationPage" : \ 111 "cooperationPage": \
110 [self.trUtf8("Cooperation"), "preferences-cooperation.png", 112 [self.trUtf8("Cooperation"), "preferences-cooperation.png",
111 "CooperationPage", None, None], 113 "CooperationPage", None, None],
112 "corbaPage" : \ 114 "corbaPage": \
113 [self.trUtf8("CORBA"), "preferences-orbit.png", 115 [self.trUtf8("CORBA"), "preferences-orbit.png",
114 "CorbaPage", None, None], 116 "CorbaPage", None, None],
115 "emailPage" : \ 117 "emailPage": \
116 [self.trUtf8("Email"), "preferences-mail_generic.png", 118 [self.trUtf8("Email"), "preferences-mail_generic.png",
117 "EmailPage", None, None], 119 "EmailPage", None, None],
118 "graphicsPage" : \ 120 "graphicsPage": \
119 [self.trUtf8("Graphics"), "preferences-graphics.png", 121 [self.trUtf8("Graphics"), "preferences-graphics.png",
120 "GraphicsPage", None, None], 122 "GraphicsPage", None, None],
121 "iconsPage" : \ 123 "iconsPage": \
122 [self.trUtf8("Icons"), "preferences-icons.png", 124 [self.trUtf8("Icons"), "preferences-icons.png",
123 "IconsPage", None, None], 125 "IconsPage", None, None],
124 "networkPage" : \ 126 "networkPage": \
125 [self.trUtf8("Network"), "preferences-network.png", 127 [self.trUtf8("Network"), "preferences-network.png",
126 "NetworkPage", None, None], 128 "NetworkPage", None, None],
127 "pluginManagerPage" : \ 129 "pluginManagerPage": \
128 [self.trUtf8("Plugin Manager"), "preferences-pluginmanager.png", 130 [self.trUtf8("Plugin Manager"), "preferences-pluginmanager.png",
129 "PluginManagerPage", None, None], 131 "PluginManagerPage", None, None],
130 "printerPage" : \ 132 "printerPage": \
131 [self.trUtf8("Printer"), "preferences-printer.png", 133 [self.trUtf8("Printer"), "preferences-printer.png",
132 "PrinterPage", None, None], 134 "PrinterPage", None, None],
133 "py3flakesPage" : \ 135 "py3flakesPage": \
134 [self.trUtf8("PyFlakes"), "warning.png", 136 [self.trUtf8("PyFlakes"), "warning.png",
135 "Py3FlakesPage", None, None], 137 "Py3FlakesPage", None, None],
136 "pythonPage" : \ 138 "pythonPage": \
137 [self.trUtf8("Python"), "preferences-python.png", 139 [self.trUtf8("Python"), "preferences-python.png",
138 "PythonPage", None, None], 140 "PythonPage", None, None],
139 "qtPage" : \ 141 "qtPage": \
140 [self.trUtf8("Qt"), "preferences-qtlogo.png", 142 [self.trUtf8("Qt"), "preferences-qtlogo.png",
141 "QtPage", None, None], 143 "QtPage", None, None],
142 "shellPage" : \ 144 "shellPage": \
143 [self.trUtf8("Shell"), "preferences-shell.png", 145 [self.trUtf8("Shell"), "preferences-shell.png",
144 "ShellPage", None, None], 146 "ShellPage", None, None],
145 "tasksPage" : \ 147 "tasksPage": \
146 [self.trUtf8("Tasks"), "task.png", 148 [self.trUtf8("Tasks"), "task.png",
147 "TasksPage", None, None], 149 "TasksPage", None, None],
148 "templatesPage" : \ 150 "templatesPage": \
149 [self.trUtf8("Templates"), "preferences-template.png", 151 [self.trUtf8("Templates"), "preferences-template.png",
150 "TemplatesPage", None, None], 152 "TemplatesPage", None, None],
151 "terminalPage" : \ 153 "terminalPage": \
152 [self.trUtf8("Terminal"), "terminal.png", 154 [self.trUtf8("Terminal"), "terminal.png",
153 "TerminalPage", None, None], 155 "TerminalPage", None, None],
154 "trayStarterPage" : \ 156 "trayStarterPage": \
155 [self.trUtf8("Tray Starter"), "erict.png", 157 [self.trUtf8("Tray Starter"), "erict.png",
156 "TrayStarterPage", None, None], 158 "TrayStarterPage", None, None],
157 "vcsPage" : \ 159 "vcsPage": \
158 [self.trUtf8("Version Control Systems"), "preferences-vcs.png", 160 [self.trUtf8("Version Control Systems"), "preferences-vcs.png",
159 "VcsPage", None, None], 161 "VcsPage", None, None],
160 162
161 "0debuggerPage": \ 163 "0debuggerPage": \
162 [self.trUtf8("Debugger"), "preferences-debugger.png", 164 [self.trUtf8("Debugger"), "preferences-debugger.png",
163 None, None, None], 165 None, None, None],
164 "debuggerGeneralPage" : \ 166 "debuggerGeneralPage": \
165 [self.trUtf8("General"), "preferences-debugger.png", 167 [self.trUtf8("General"), "preferences-debugger.png",
166 "DebuggerGeneralPage", "0debuggerPage", None], 168 "DebuggerGeneralPage", "0debuggerPage", None],
167 "debuggerPythonPage" : \ 169 "debuggerPythonPage": \
168 [self.trUtf8("Python"), "preferences-pyDebugger.png", 170 [self.trUtf8("Python"), "preferences-pyDebugger.png",
169 "DebuggerPythonPage", "0debuggerPage", None], 171 "DebuggerPythonPage", "0debuggerPage", None],
170 "debuggerPython3Page" : \ 172 "debuggerPython3Page": \
171 [self.trUtf8("Python3"), "preferences-pyDebugger.png", 173 [self.trUtf8("Python3"), "preferences-pyDebugger.png",
172 "DebuggerPython3Page", "0debuggerPage", None], 174 "DebuggerPython3Page", "0debuggerPage", None],
173 "debuggerRubyPage" : \ 175 "debuggerRubyPage": \
174 [self.trUtf8("Ruby"), "preferences-rbDebugger.png", 176 [self.trUtf8("Ruby"), "preferences-rbDebugger.png",
175 "DebuggerRubyPage", "0debuggerPage", None], 177 "DebuggerRubyPage", "0debuggerPage", None],
176 178
177 "0editorPage" : \ 179 "0editorPage": \
178 [self.trUtf8("Editor"), "preferences-editor.png", 180 [self.trUtf8("Editor"), "preferences-editor.png",
179 None, None, None], 181 None, None, None],
180 "editorAPIsPage" : \ 182 "editorAPIsPage": \
181 [self.trUtf8("APIs"), "preferences-api.png", 183 [self.trUtf8("APIs"), "preferences-api.png",
182 "EditorAPIsPage", "0editorPage", None], 184 "EditorAPIsPage", "0editorPage", None],
183 "editorAutocompletionPage" : \ 185 "editorAutocompletionPage": \
184 [self.trUtf8("Autocompletion"), "preferences-autocompletion.png", 186 [self.trUtf8("Autocompletion"), "preferences-autocompletion.png",
185 "EditorAutocompletionPage", "0editorPage", None], 187 "EditorAutocompletionPage", "0editorPage", None],
186 "editorAutocompletionQScintillaPage" : \ 188 "editorAutocompletionQScintillaPage": \
187 [self.trUtf8("QScintilla"), "qscintilla.png", 189 [self.trUtf8("QScintilla"), "qscintilla.png",
188 "EditorAutocompletionQScintillaPage", 190 "EditorAutocompletionQScintillaPage",
189 "editorAutocompletionPage", None], 191 "editorAutocompletionPage", None],
190 "editorCalltipsPage" : \ 192 "editorCalltipsPage": \
191 [self.trUtf8("Calltips"), "preferences-calltips.png", 193 [self.trUtf8("Calltips"), "preferences-calltips.png",
192 "EditorCalltipsPage", "0editorPage", None], 194 "EditorCalltipsPage", "0editorPage", None],
193 "editorCalltipsQScintillaPage" : \ 195 "editorCalltipsQScintillaPage": \
194 [self.trUtf8("QScintilla"), "qscintilla.png", 196 [self.trUtf8("QScintilla"), "qscintilla.png",
195 "EditorCalltipsQScintillaPage", "editorCalltipsPage", None], 197 "EditorCalltipsQScintillaPage", "editorCalltipsPage", None],
196 "editorGeneralPage" : \ 198 "editorGeneralPage": \
197 [self.trUtf8("General"), "preferences-general.png", 199 [self.trUtf8("General"), "preferences-general.png",
198 "EditorGeneralPage", "0editorPage", None], 200 "EditorGeneralPage", "0editorPage", None],
199 "editorFilePage" : \ 201 "editorFilePage": \
200 [self.trUtf8("Filehandling"), "preferences-filehandling.png", 202 [self.trUtf8("Filehandling"), "preferences-filehandling.png",
201 "EditorFilePage", "0editorPage", None], 203 "EditorFilePage", "0editorPage", None],
202 "editorSearchPage" : \ 204 "editorSearchPage": \
203 [self.trUtf8("Searching"), "preferences-search.png", 205 [self.trUtf8("Searching"), "preferences-search.png",
204 "EditorSearchPage", "0editorPage", None], 206 "EditorSearchPage", "0editorPage", None],
205 "editorSpellCheckingPage" : \ 207 "editorSpellCheckingPage": \
206 [self.trUtf8("Spell checking"), "preferences-spellchecking.png", 208 [self.trUtf8("Spell checking"), "preferences-spellchecking.png",
207 "EditorSpellCheckingPage", "0editorPage", None], 209 "EditorSpellCheckingPage", "0editorPage", None],
208 "editorStylesPage" : \ 210 "editorStylesPage": \
209 [self.trUtf8("Style"), "preferences-styles.png", 211 [self.trUtf8("Style"), "preferences-styles.png",
210 "EditorStylesPage", "0editorPage", None], 212 "EditorStylesPage", "0editorPage", None],
211 "editorTypingPage" : \ 213 "editorTypingPage": \
212 [self.trUtf8("Typing"), "preferences-typing.png", 214 [self.trUtf8("Typing"), "preferences-typing.png",
213 "EditorTypingPage", "0editorPage", None], 215 "EditorTypingPage", "0editorPage", None],
214 "editorExportersPage" : \ 216 "editorExportersPage": \
215 [self.trUtf8("Exporters"), "preferences-exporters.png", 217 [self.trUtf8("Exporters"), "preferences-exporters.png",
216 "EditorExportersPage", "0editorPage", None], 218 "EditorExportersPage", "0editorPage", None],
217 219
218 "1editorLexerPage" : \ 220 "1editorLexerPage": \
219 [self.trUtf8("Highlighters"), "preferences-highlighting-styles.png", 221 [self.trUtf8("Highlighters"), "preferences-highlighting-styles.png",
220 None, "0editorPage", None], 222 None, "0editorPage", None],
221 "editorHighlightersPage" : \ 223 "editorHighlightersPage": \
222 [self.trUtf8("Filetype Associations"), 224 [self.trUtf8("Filetype Associations"),
223 "preferences-highlighter-association.png", 225 "preferences-highlighter-association.png",
224 "EditorHighlightersPage", "1editorLexerPage", None], 226 "EditorHighlightersPage", "1editorLexerPage", None],
225 "editorHighlightingStylesPage" : \ 227 "editorHighlightingStylesPage": \
226 [self.trUtf8("Styles"), 228 [self.trUtf8("Styles"),
227 "preferences-highlighting-styles.png", 229 "preferences-highlighting-styles.png",
228 "EditorHighlightingStylesPage", "1editorLexerPage", None], 230 "EditorHighlightingStylesPage", "1editorLexerPage", None],
229 "editorKeywordsPage" : \ 231 "editorKeywordsPage": \
230 [self.trUtf8("Keywords"), "preferences-keywords.png", 232 [self.trUtf8("Keywords"), "preferences-keywords.png",
231 "EditorKeywordsPage", "1editorLexerPage", None], 233 "EditorKeywordsPage", "1editorLexerPage", None],
232 "editorPropertiesPage" : \ 234 "editorPropertiesPage": \
233 [self.trUtf8("Properties"), "preferences-properties.png", 235 [self.trUtf8("Properties"), "preferences-properties.png",
234 "EditorPropertiesPage", "1editorLexerPage", None], 236 "EditorPropertiesPage", "1editorLexerPage", None],
235 237
236 "0helpPage" : \ 238 "0helpPage": \
237 [self.trUtf8("Help"), "preferences-help.png", 239 [self.trUtf8("Help"), "preferences-help.png",
238 None, None, None], 240 None, None, None],
239 "helpAppearancePage" : \ 241 "helpAppearancePage": \
240 [self.trUtf8("Appearance"), "preferences-styles.png", 242 [self.trUtf8("Appearance"), "preferences-styles.png",
241 "HelpAppearancePage", "0helpPage", None], 243 "HelpAppearancePage", "0helpPage", None],
242 "helpDocumentationPage" : \ 244 "helpDocumentationPage": \
243 [self.trUtf8("Help Documentation"), 245 [self.trUtf8("Help Documentation"),
244 "preferences-helpdocumentation.png", 246 "preferences-helpdocumentation.png",
245 "HelpDocumentationPage", "0helpPage", None], 247 "HelpDocumentationPage", "0helpPage", None],
246 "helpViewersPage" : \ 248 "helpViewersPage": \
247 [self.trUtf8("Help Viewers"), "preferences-helpviewers.png", 249 [self.trUtf8("Help Viewers"), "preferences-helpviewers.png",
248 "HelpViewersPage", "0helpPage", None], 250 "HelpViewersPage", "0helpPage", None],
249 "helpWebBrowserPage" : \ 251 "helpWebBrowserPage": \
250 [self.trUtf8("Eric Web Browser"), "ericWeb.png", 252 [self.trUtf8("Eric Web Browser"), "ericWeb.png",
251 "HelpWebBrowserPage", "0helpPage", None], 253 "HelpWebBrowserPage", "0helpPage", None],
252 254
253 "0projectPage" : \ 255 "0projectPage": \
254 [self.trUtf8("Project"), "preferences-project.png", 256 [self.trUtf8("Project"), "preferences-project.png",
255 None, None, None], 257 None, None, None],
256 "projectBrowserPage" : \ 258 "projectBrowserPage": \
257 [self.trUtf8("Project Viewer"), "preferences-project.png", 259 [self.trUtf8("Project Viewer"), "preferences-project.png",
258 "ProjectBrowserPage", "0projectPage", None], 260 "ProjectBrowserPage", "0projectPage", None],
259 "projectPage" : \ 261 "projectPage": \
260 [self.trUtf8("Project"), "preferences-project.png", 262 [self.trUtf8("Project"), "preferences-project.png",
261 "ProjectPage", "0projectPage", None], 263 "ProjectPage", "0projectPage", None],
262 "multiProjectPage" : \ 264 "multiProjectPage": \
263 [self.trUtf8("Multiproject"), "preferences-multiproject.png", 265 [self.trUtf8("Multiproject"), "preferences-multiproject.png",
264 "MultiProjectPage", "0projectPage", None], 266 "MultiProjectPage", "0projectPage", None],
265 267
266 "0interfacePage" : \ 268 "0interfacePage": \
267 [self.trUtf8("Interface"), "preferences-interface.png", 269 [self.trUtf8("Interface"), "preferences-interface.png",
268 None, None, None], 270 None, None, None],
269 "interfacePage" : \ 271 "interfacePage": \
270 [self.trUtf8("Interface"), "preferences-interface.png", 272 [self.trUtf8("Interface"), "preferences-interface.png",
271 "InterfacePage", "0interfacePage", None], 273 "InterfacePage", "0interfacePage", None],
272 "viewmanagerPage" : \ 274 "viewmanagerPage": \
273 [self.trUtf8("Viewmanager"), "preferences-viewmanager.png", 275 [self.trUtf8("Viewmanager"), "preferences-viewmanager.png",
274 "ViewmanagerPage", "0interfacePage", None], 276 "ViewmanagerPage", "0interfacePage", None],
275 } 277 }
276 278
277 self.configItems.update( 279 self.configItems.update(
278 e5App().getObject("PluginManager").getPluginConfigData()) 280 e5App().getObject("PluginManager").getPluginConfigData())
279 elif displayMode == ConfigurationWidget.HelpBrowserMode: 281 elif displayMode == ConfigurationWidget.HelpBrowserMode:
280 self.configItems = { 282 self.configItems = {
281 # key : [display string, pixmap name, dialog module name or 283 # key : [display string, pixmap name, dialog module name or
282 # page creation function, parent key, 284 # page creation function, parent key,
283 # reference to configuration page (must always be last)] 285 # reference to configuration page (must always be last)]
284 # The dialog module must have the module function create to create 286 # The dialog module must have the module function create to create
285 # the configuration page. This must have the method save to save 287 # the configuration page. This must have the method save to save
286 # the settings. 288 # the settings.
287 "networkPage" : \ 289 "networkPage": \
288 [self.trUtf8("Network"), "preferences-network.png", 290 [self.trUtf8("Network"), "preferences-network.png",
289 "NetworkPage", None, None], 291 "NetworkPage", None, None],
290 "pythonPage" : \ 292 "pythonPage": \
291 [self.trUtf8("Python"), "preferences-python.png", 293 [self.trUtf8("Python"), "preferences-python.png",
292 "PythonPage", None, None], 294 "PythonPage", None, None],
293 295
294 "0helpPage" : \ 296 "0helpPage": \
295 [self.trUtf8("Help"), "preferences-help.png", 297 [self.trUtf8("Help"), "preferences-help.png",
296 None, None, None], 298 None, None, None],
297 "helpAppearancePage" : \ 299 "helpAppearancePage": \
298 [self.trUtf8("Appearance"), "preferences-styles.png", 300 [self.trUtf8("Appearance"), "preferences-styles.png",
299 "HelpAppearancePage", "0helpPage", None], 301 "HelpAppearancePage", "0helpPage", None],
300 "helpDocumentationPage" : \ 302 "helpDocumentationPage": \
301 [self.trUtf8("Help Documentation"), 303 [self.trUtf8("Help Documentation"),
302 "preferences-helpdocumentation.png", 304 "preferences-helpdocumentation.png",
303 "HelpDocumentationPage", "0helpPage", None], 305 "HelpDocumentationPage", "0helpPage", None],
304 "helpViewersPage" : \ 306 "helpViewersPage": \
305 [self.trUtf8("Help Viewers"), "preferences-helpviewers.png", 307 [self.trUtf8("Help Viewers"), "preferences-helpviewers.png",
306 "HelpViewersPage", "0helpPage", None], 308 "HelpViewersPage", "0helpPage", None],
307 "helpWebBrowserPage" : \ 309 "helpWebBrowserPage": \
308 [self.trUtf8("Eric Web Browser"), "ericWeb.png", 310 [self.trUtf8("Eric Web Browser"), "ericWeb.png",
309 "HelpWebBrowserPage", "0helpPage", None], 311 "HelpWebBrowserPage", "0helpPage", None],
310 } 312 }
311 elif displayMode == ConfigurationWidget.TrayStarterMode: 313 elif displayMode == ConfigurationWidget.TrayStarterMode:
312 self.configItems = { 314 self.configItems = {
313 # key : [display string, pixmap name, dialog module name or 315 # key : [display string, pixmap name, dialog module name or
314 # page creation function, parent key, 316 # page creation function, parent key,
315 # reference to configuration page (must always be last)] 317 # reference to configuration page (must always be last)]
316 # The dialog module must have the module function create to create 318 # The dialog module must have the module function create to create
317 # the configuration page. This must have the method save to save 319 # the configuration page. This must have the method save to save
318 # the settings. 320 # the settings.
319 "trayStarterPage" : \ 321 "trayStarterPage": \
320 [self.trUtf8("Tray Starter"), "erict.png", 322 [self.trUtf8("Tray Starter"), "erict.png",
321 "TrayStarterPage", None, None], 323 "TrayStarterPage", None, None],
322 } 324 }
323 else: 325 else:
324 raise RuntimeError("Illegal mode value: {0}".format(displayMode)) 326 raise RuntimeError("Illegal mode value: {0}".format(displayMode))
325 327
326 # generate the list entries 328 # generate the list entries
327 for key in sorted(self.configItems.keys()): 329 for key in sorted(self.configItems.keys()):
328 pageData = self.configItems[key] 330 pageData = self.configItems[key]
329 if pageData[3]: 331 if pageData[3]:
330 pitm = self.itmDict[pageData[3]] # get the parent item 332 pitm = self.itmDict[pageData[3]] # get the parent item
331 else: 333 else:
332 pitm = self.configList 334 pitm = self.configList
333 self.itmDict[key] = ConfigurationPageItem(pitm, pageData[0], key, pageData[1]) 335 self.itmDict[key] = ConfigurationPageItem(pitm, pageData[0], key, pageData[1])
334 self.itmDict[key].setExpanded(True) 336 self.itmDict[key].setExpanded(True)
335 self.configList.sortByColumn(0, Qt.AscendingOrder) 337 self.configList.sortByColumn(0, Qt.AscendingOrder)
502 else: 504 else:
503 page = pageData[-1] 505 page = pageData[-1]
504 if page is None: 506 if page is None:
505 page = self.emptyPage 507 page = self.emptyPage
506 else: 508 else:
507 items = self.configList.findItems(pageData[0], 509 items = self.configList.findItems(pageData[0],
508 Qt.MatchFixedString | Qt.MatchRecursive) 510 Qt.MatchFixedString | Qt.MatchRecursive)
509 if items: 511 if items:
510 self.configList.setCurrentItem(items[0]) 512 self.configList.setCurrentItem(items[0])
511 self.configStack.setCurrentWidget(page) 513 self.configStack.setCurrentWidget(page)
512 ssize = self.scrollArea.size() 514 ssize = self.scrollArea.size()
515 ssize.height() - self.scrollArea.horizontalScrollBar().height() - 2) 517 ssize.height() - self.scrollArea.horizontalScrollBar().height() - 2)
516 if self.scrollArea.verticalScrollBar(): 518 if self.scrollArea.verticalScrollBar():
517 ssize.setWidth( 519 ssize.setWidth(
518 ssize.width() - self.scrollArea.verticalScrollBar().width() - 2) 520 ssize.width() - self.scrollArea.verticalScrollBar().width() - 2)
519 psize = page.minimumSizeHint() 521 psize = page.minimumSizeHint()
520 self.configStack.resize(max(ssize.width(), psize.width()), 522 self.configStack.resize(max(ssize.width(), psize.width()),
521 max(ssize.height(), psize.height())) 523 max(ssize.height(), psize.height()))
522 524
523 if page != self.emptyPage: 525 if page != self.emptyPage:
524 page.polishPage() 526 page.polishPage()
525 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(True) 527 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(True)
527 else: 529 else:
528 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False) 530 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False)
529 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False) 531 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False)
530 532
531 # reset scrollbars 533 # reset scrollbars
532 for sb in [self.scrollArea.horizontalScrollBar(), 534 for sb in [self.scrollArea.horizontalScrollBar(),
533 self.scrollArea.verticalScrollBar()]: 535 self.scrollArea.verticalScrollBar()]:
534 if sb: 536 if sb:
535 sb.setValue(0) 537 sb.setValue(0)
536 538
537 self.__currentConfigurationPageName = pageName 539 self.__currentConfigurationPageName = pageName
620 622
621 self.showConfigurationPageByName(pageName) 623 self.showConfigurationPageByName(pageName)
622 if savedState is not None: 624 if savedState is not None:
623 self.configStack.currentWidget().setState(savedState) 625 self.configStack.currentWidget().setState(savedState)
624 626
627
625 class ConfigurationDialog(QDialog): 628 class ConfigurationDialog(QDialog):
626 """ 629 """
627 Class for the dialog variant. 630 Class for the dialog variant.
628 631
629 @signal preferencesChanged() emitted after settings have been changed 632 @signal preferencesChanged() emitted after settings have been changed
630 """ 633 """
631 preferencesChanged = pyqtSignal() 634 preferencesChanged = pyqtSignal()
632 635
633 DefaultMode = ConfigurationWidget.DefaultMode 636 DefaultMode = ConfigurationWidget.DefaultMode
634 HelpBrowserMode = ConfigurationWidget.HelpBrowserMode 637 HelpBrowserMode = ConfigurationWidget.HelpBrowserMode
635 TrayStarterMode = ConfigurationWidget.TrayStarterMode 638 TrayStarterMode = ConfigurationWidget.TrayStarterMode
636 639
637 def __init__(self, parent = None, name = None, modal = False, 640 def __init__(self, parent=None, name=None, modal=False,
638 fromEric = True, displayMode = ConfigurationWidget.DefaultMode): 641 fromEric=True, displayMode=ConfigurationWidget.DefaultMode):
639 """ 642 """
640 Constructor 643 Constructor
641 644
642 @param parent The parent widget of this dialog. (QWidget) 645 @param parent The parent widget of this dialog. (QWidget)
643 @param name The name of this dialog. string 646 @param name The name of this dialog. string
644 @param modal Flag indicating a modal dialog. (boolean) 647 @param modal Flag indicating a modal dialog. (boolean)
645 @keyparam fromEric flag indicating a dialog generation from within the 648 @keyparam fromEric flag indicating a dialog generation from within the
646 eric5 ide (boolean) 649 eric5 ide (boolean)
647 @keyparam displayMode mode of the configuration dialog 650 @keyparam displayMode mode of the configuration dialog
648 (DefaultMode, HelpBrowserMode, TrayStarterMode) 651 (DefaultMode, HelpBrowserMode, TrayStarterMode)
649 """ 652 """
650 QDialog.__init__(self, parent) 653 QDialog.__init__(self, parent)
651 if name: 654 if name:
652 self.setObjectName(name) 655 self.setObjectName(name)
653 self.setModal(modal) 656 self.setModal(modal)
654 self.layout = QVBoxLayout(self) 657 self.layout = QVBoxLayout(self)
655 self.layout.setMargin(0) 658 self.layout.setMargin(0)
656 self.layout.setSpacing(0) 659 self.layout.setSpacing(0)
657 660
658 self.cw = ConfigurationWidget(self, fromEric = fromEric, 661 self.cw = ConfigurationWidget(self, fromEric=fromEric,
659 displayMode = displayMode) 662 displayMode=displayMode)
660 size = self.cw.size() 663 size = self.cw.size()
661 self.layout.addWidget(self.cw) 664 self.layout.addWidget(self.cw)
662 self.resize(size) 665 self.resize(size)
663 666
664 self.cw.buttonBox.accepted[()].connect(self.accept) 667 self.cw.buttonBox.accepted[()].connect(self.accept)
690 def setPreferences(self): 693 def setPreferences(self):
691 """ 694 """
692 Public method called to store the selected values into the preferences storage. 695 Public method called to store the selected values into the preferences storage.
693 """ 696 """
694 self.cw.setPreferences() 697 self.cw.setPreferences()
698
695 699
696 class ConfigurationWindow(QMainWindow): 700 class ConfigurationWindow(QMainWindow):
697 """ 701 """
698 Main window class for the standalone dialog. 702 Main window class for the standalone dialog.
699 """ 703 """
700 def __init__(self, parent = None): 704 def __init__(self, parent=None):
701 """ 705 """
702 Constructor 706 Constructor
703 707
704 @param parent reference to the parent widget (QWidget) 708 @param parent reference to the parent widget (QWidget)
705 """ 709 """
706 QMainWindow.__init__(self, parent) 710 QMainWindow.__init__(self, parent)
707 711
708 self.cw = ConfigurationWidget(self, fromEric = False) 712 self.cw = ConfigurationWidget(self, fromEric=False)
709 size = self.cw.size() 713 size = self.cw.size()
710 self.setCentralWidget(self.cw) 714 self.setCentralWidget(self.cw)
711 self.resize(size) 715 self.resize(size)
712 716
713 self.cw.buttonBox.accepted[()].connect(self.accept) 717 self.cw.buttonBox.accepted[()].connect(self.accept)
721 """ 725 """
722 self.cw.showConfigurationPageByName(pageName) 726 self.cw.showConfigurationPageByName(pageName)
723 727
724 def accept(self): 728 def accept(self):
725 """ 729 """
726 Protected slot called by the Ok button. 730 Protected slot called by the Ok button.
727 """ 731 """
728 self.cw.setPreferences() 732 self.cw.setPreferences()
729 Preferences.saveResetLayout() 733 Preferences.saveResetLayout()
730 Preferences.syncPreferences() 734 Preferences.syncPreferences()
731 self.close() 735 self.close()

eric ide

mercurial