Preferences/ConfigurationDialog.py

changeset 701
fc587a1c2f8b
parent 537
72b32daeb8d6
child 791
9ec2ac20e54e
equal deleted inserted replaced
699:c008503ee766 701:fc587a1c2f8b
57 57
58 @signal preferencesChanged() emitted after settings have been changed 58 @signal preferencesChanged() emitted after settings have been changed
59 """ 59 """
60 preferencesChanged = pyqtSignal() 60 preferencesChanged = pyqtSignal()
61 61
62 def __init__(self, parent = None, fromEric = True, helpBrowserMode = False): 62 DefaultMode = 0
63 HelpBrowserMode = 1
64 TrayStarterMode = 2
65
66 def __init__(self, parent = None, fromEric = True, displayMode = DefaultMode):
63 """ 67 """
64 Constructor 68 Constructor
65 69
66 @param parent The parent widget of this dialog. (QWidget) 70 @param parent The parent widget of this dialog. (QWidget)
67 @keyparam fromEric flag indicating a dialog generation from within the 71 @keyparam fromEric flag indicating a dialog generation from within the
68 eric5 ide (boolean) 72 eric5 ide (boolean)
69 @keyparam helpBrowserMode flag indicating to show only help pages 73 @keyparam displayMode mode of the configuration dialog
70 for entries related to the help browser (boolean) 74 (DefaultMode, HelpBrowserMode, TrayStarterMode)
71 """ 75 """
76 assert displayMode in (
77 ConfigurationWidget.DefaultMode,
78 ConfigurationWidget.HelpBrowserMode,
79 ConfigurationWidget.TrayStarterMode
80 )
81
72 QWidget.__init__(self, parent) 82 QWidget.__init__(self, parent)
73 self.fromEric = fromEric 83 self.fromEric = fromEric
74 self.helpBrowserMode = helpBrowserMode 84 self.displayMode = displayMode
75 85
76 self.__setupUi() 86 self.__setupUi()
77 87
78 self.itmDict = {} 88 self.itmDict = {}
79 89
83 self.pluginManager = e5App().getObject("PluginManager") 93 self.pluginManager = e5App().getObject("PluginManager")
84 except KeyError: 94 except KeyError:
85 self.pluginManager = PluginManager(self) 95 self.pluginManager = PluginManager(self)
86 e5App().registerObject("PluginManager", self.pluginManager) 96 e5App().registerObject("PluginManager", self.pluginManager)
87 97
88 if not helpBrowserMode: 98 if displayMode == ConfigurationWidget.DefaultMode:
89 self.configItems = { 99 self.configItems = {
90 # key : [display string, pixmap name, dialog module name or 100 # key : [display string, pixmap name, dialog module name or
91 # page creation function, parent key, 101 # page creation function, parent key,
92 # reference to configuration page (must always be last)] 102 # reference to configuration page (must always be last)]
93 # The dialog module must have the module function create to create 103 # The dialog module must have the module function create to create
139 [self.trUtf8("Templates"), "preferences-template.png", 149 [self.trUtf8("Templates"), "preferences-template.png",
140 "TemplatesPage", None, None], 150 "TemplatesPage", None, None],
141 "terminalPage" : \ 151 "terminalPage" : \
142 [self.trUtf8("Terminal"), "terminal.png", 152 [self.trUtf8("Terminal"), "terminal.png",
143 "TerminalPage", None, None], 153 "TerminalPage", None, None],
154 "trayStarterPage" : \
155 [self.trUtf8("Tray Starter"), "erict.png",
156 "TrayStarterPage", None, None],
144 "vcsPage" : \ 157 "vcsPage" : \
145 [self.trUtf8("Version Control Systems"), "preferences-vcs.png", 158 [self.trUtf8("Version Control Systems"), "preferences-vcs.png",
146 "VcsPage", None, None], 159 "VcsPage", None, None],
147 160
148 "0debuggerPage": \ 161 "0debuggerPage": \
261 "ViewmanagerPage", "0interfacePage", None], 274 "ViewmanagerPage", "0interfacePage", None],
262 } 275 }
263 276
264 self.configItems.update( 277 self.configItems.update(
265 e5App().getObject("PluginManager").getPluginConfigData()) 278 e5App().getObject("PluginManager").getPluginConfigData())
266 else: 279 elif displayMode == ConfigurationWidget.HelpBrowserMode:
267 self.configItems = { 280 self.configItems = {
268 # key : [display string, pixmap name, dialog module name or 281 # key : [display string, pixmap name, dialog module name or
269 # page creation function, parent key, 282 # page creation function, parent key,
270 # reference to configuration page (must always be last)] 283 # reference to configuration page (must always be last)]
271 # The dialog module must have the module function create to create 284 # The dialog module must have the module function create to create
293 "HelpViewersPage", "0helpPage", None], 306 "HelpViewersPage", "0helpPage", None],
294 "helpWebBrowserPage" : \ 307 "helpWebBrowserPage" : \
295 [self.trUtf8("Eric Web Browser"), "ericWeb.png", 308 [self.trUtf8("Eric Web Browser"), "ericWeb.png",
296 "HelpWebBrowserPage", "0helpPage", None], 309 "HelpWebBrowserPage", "0helpPage", None],
297 } 310 }
311 elif displayMode == ConfigurationWidget.TrayStarterMode:
312 self.configItems = {
313 # key : [display string, pixmap name, dialog module name or
314 # page creation function, parent key,
315 # reference to configuration page (must always be last)]
316 # The dialog module must have the module function create to create
317 # the configuration page. This must have the method save to save
318 # the settings.
319 "trayStarterPage" : \
320 [self.trUtf8("Tray Starter"), "erict.png",
321 "TrayStarterPage", None, None],
322 }
323 else:
324 raise RuntimeError("Illegal mode value: {0}".format(displayMode))
298 325
299 # generate the list entries 326 # generate the list entries
300 for key in sorted(self.configItems.keys()): 327 for key in sorted(self.configItems.keys()):
301 pageData = self.configItems[key] 328 pageData = self.configItems[key]
302 if pageData[3]: 329 if pageData[3]:
311 self.configSplitter.setSizes([200, 600]) 338 self.configSplitter.setSizes([200, 600])
312 339
313 self.configList.itemActivated.connect(self.__showConfigurationPage) 340 self.configList.itemActivated.connect(self.__showConfigurationPage)
314 self.configList.itemClicked.connect(self.__showConfigurationPage) 341 self.configList.itemClicked.connect(self.__showConfigurationPage)
315 342
316 self.__initLexers() 343 if displayMode != ConfigurationWidget.TrayStarterMode:
344 self.__initLexers()
317 345
318 def __setupUi(self): 346 def __setupUi(self):
319 """ 347 """
320 Private method to perform the general setup of the configuration widget. 348 Private method to perform the general setup of the configuration widget.
321 """ 349 """
375 self.buttonBox.setOrientation(Qt.Horizontal) 403 self.buttonBox.setOrientation(Qt.Horizontal)
376 self.buttonBox.setStandardButtons( 404 self.buttonBox.setStandardButtons(
377 QDialogButtonBox.Apply | QDialogButtonBox.Cancel | \ 405 QDialogButtonBox.Apply | QDialogButtonBox.Cancel | \
378 QDialogButtonBox.Ok | QDialogButtonBox.Reset) 406 QDialogButtonBox.Ok | QDialogButtonBox.Reset)
379 self.buttonBox.setObjectName("buttonBox") 407 self.buttonBox.setObjectName("buttonBox")
380 if not self.fromEric and not self.helpBrowserMode: 408 if not self.fromEric and self.displayMode == ConfigurationWidget.DefaultMode:
381 self.buttonBox.button(QDialogButtonBox.Apply).hide() 409 self.buttonBox.button(QDialogButtonBox.Apply).hide()
382 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False) 410 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False)
383 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False) 411 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False)
384 self.verticalLayout_2.addWidget(self.buttonBox) 412 self.verticalLayout_2.addWidget(self.buttonBox)
385 413
584 612
585 @signal preferencesChanged() emitted after settings have been changed 613 @signal preferencesChanged() emitted after settings have been changed
586 """ 614 """
587 preferencesChanged = pyqtSignal() 615 preferencesChanged = pyqtSignal()
588 616
617 DefaultMode = ConfigurationWidget.DefaultMode
618 HelpBrowserMode = ConfigurationWidget.HelpBrowserMode
619 TrayStarterMode = ConfigurationWidget.TrayStarterMode
620
589 def __init__(self, parent = None, name = None, modal = False, 621 def __init__(self, parent = None, name = None, modal = False,
590 fromEric = True, helpBrowserMode = False): 622 fromEric = True, displayMode = ConfigurationWidget.DefaultMode):
591 """ 623 """
592 Constructor 624 Constructor
593 625
594 @param parent The parent widget of this dialog. (QWidget) 626 @param parent The parent widget of this dialog. (QWidget)
595 @param name The name of this dialog. string 627 @param name The name of this dialog. string
596 @param modal Flag indicating a modal dialog. (boolean) 628 @param modal Flag indicating a modal dialog. (boolean)
597 @keyparam fromEric flag indicating a dialog generation from within the 629 @keyparam fromEric flag indicating a dialog generation from within the
598 eric5 ide (boolean) 630 eric5 ide (boolean)
599 @keyparam helpBrowserMode flag indicating to show only help pages 631 @keyparam displayMode mode of the configuration dialog
600 for entries related to the help browser (boolean) 632 (DefaultMode, HelpBrowserMode, TrayStarterMode)
601 """ 633 """
602 QDialog.__init__(self, parent) 634 QDialog.__init__(self, parent)
603 if name: 635 if name:
604 self.setObjectName(name) 636 self.setObjectName(name)
605 self.setModal(modal) 637 self.setModal(modal)
606 self.layout = QVBoxLayout(self) 638 self.layout = QVBoxLayout(self)
607 self.layout.setMargin(0) 639 self.layout.setMargin(0)
608 self.layout.setSpacing(0) 640 self.layout.setSpacing(0)
609 641
610 self.cw = ConfigurationWidget(self, fromEric = fromEric, 642 self.cw = ConfigurationWidget(self, fromEric = fromEric,
611 helpBrowserMode = helpBrowserMode) 643 displayMode = displayMode)
612 size = self.cw.size() 644 size = self.cw.size()
613 self.layout.addWidget(self.cw) 645 self.layout.addWidget(self.cw)
614 self.resize(size) 646 self.resize(size)
615 647
616 self.cw.buttonBox.accepted[()].connect(self.accept) 648 self.cw.buttonBox.accepted[()].connect(self.accept)

eric ide

mercurial