Preferences/ConfigurationDialog.py

changeset 4216
bca19a75be32
parent 4214
b8fd47f8b707
child 4278
ccd1e13cb9bd
diff -r b8fd47f8b707 -r bca19a75be32 Preferences/ConfigurationDialog.py
--- a/Preferences/ConfigurationDialog.py	Sun Apr 12 16:59:06 2015 +0200
+++ b/Preferences/ConfigurationDialog.py	Sun Apr 12 18:00:45 2015 +0200
@@ -79,7 +79,8 @@
     HelpBrowserMode = 1
     TrayStarterMode = 2
     
-    def __init__(self, parent=None, fromEric=True, displayMode=DefaultMode):
+    def __init__(self, parent=None, fromEric=True, displayMode=DefaultMode,
+                 expandedEntries=[]):
         """
         Constructor
         
@@ -89,6 +90,8 @@
         @keyparam displayMode mode of the configuration dialog
             (DefaultMode, HelpBrowserMode, TrayStarterMode)
         @exception RuntimeError raised to indicate an invalid dialog mode
+        @keyparam expandedEntries list of entries to be shown expanded
+            (list of strings)
         """
         assert displayMode in (
             ConfigurationWidget.DefaultMode,
@@ -117,9 +120,9 @@
                 # key : [display string, pixmap name, dialog module name or
                 #        page creation function, parent key,
                 #        reference to configuration page (must always be last)]
-                # The dialog module must have the module function create to
+                # The dialog module must have the module function 'create' to
                 # create the configuration page. This must have the method
-                # save to save the settings.
+                # 'save' to save the settings.
                 "applicationPage":
                 [self.tr("Application"), "preferences-application.png",
                  "ApplicationPage", None, None],
@@ -317,14 +320,15 @@
             
             self.configItems.update(
                 e5App().getObject("PluginManager").getPluginConfigData())
+        
         elif displayMode == ConfigurationWidget.HelpBrowserMode:
             self.configItems = {
                 # key : [display string, pixmap name, dialog module name or
                 #        page creation function, parent key,
                 #        reference to configuration page (must always be last)]
-                # The dialog module must have the module function create to
+                # The dialog module must have the module function 'create' to
                 # create the configuration page. This must have the method
-                # save to save the settings.
+                # 'save' to save the settings.
                 "interfacePage":
                 [self.tr("Interface"), "preferences-interface.png",
                  "HelpInterfacePage", None, None],
@@ -355,22 +359,25 @@
                 [self.tr("eric6 Web Browser"), "ericWeb.png",
                  "HelpWebBrowserPage", "0helpPage", None],
             }
+        
         elif displayMode == ConfigurationWidget.TrayStarterMode:
             self.configItems = {
                 # key : [display string, pixmap name, dialog module name or
                 #        page creation function, parent key,
                 #        reference to configuration page (must always be last)]
-                # The dialog module must have the module function create to
+                # The dialog module must have the module function 'create' to
                 # create the configuration page. This must have the method
-                # save to save the settings.
+                # 'save' to save the settings.
                 "trayStarterPage":
                 [self.tr("Tray Starter"), "erict.png",
                  "TrayStarterPage", None, None],
             }
+        
         else:
             raise RuntimeError("Illegal mode value: {0}".format(displayMode))
         
         # generate the list entries
+        self.__expandedEntries = []
         for key in sorted(self.configItems.keys()):
             pageData = self.configItems[key]
             if pageData[3]:
@@ -380,7 +387,10 @@
             self.itmDict[key] = ConfigurationPageItem(pitm, pageData[0], key,
                                                       pageData[1])
             self.itmDict[key].setData(0, Qt.UserRole, key)
-            self.itmDict[key].setExpanded(True)
+            if (not self.fromEric or
+                displayMode != ConfigurationWidget.DefaultMode or
+                    key in expandedEntries):
+                self.itmDict[key].setExpanded(True)
         self.configList.sortByColumn(0, Qt.AscendingOrder)
         
         # set the initial size of the splitter
@@ -747,6 +757,36 @@
             self.showConfigurationPageByName(pageName)
             if savedState is not None:
                 self.configStack.currentWidget().setState(savedState)
+        
+    def getExpandedEntries(self):
+        """
+        Public method to get a list of expanded entries.
+        
+        @return list of expanded entries (list of string)
+        """
+        return self.__expandedEntries
+    
+    @pyqtSlot(QTreeWidgetItem)
+    def on_configList_itemCollapsed(self, item):
+        """
+        Private slot handling a list entry being collapsed.
+        
+        @param item reference to the collapsed item (QTreeWidgetItem)
+        """
+        pageName = item.data(0, Qt.UserRole)
+        if pageName in self.__expandedEntries:
+            self.__expandedEntries.remove(pageName)
+    
+    @pyqtSlot(QTreeWidgetItem)
+    def on_configList_itemExpanded(self, item):
+        """
+        Private slot handling a list entry being expanded.
+        
+        @param item reference to the expanded item (QTreeWidgetItem)
+        """
+        pageName = item.data(0, Qt.UserRole)
+        if pageName not in self.__expandedEntries:
+            self.__expandedEntries.append(pageName)
 
 
 class ConfigurationDialog(QDialog):
@@ -765,7 +805,8 @@
     TrayStarterMode = ConfigurationWidget.TrayStarterMode
     
     def __init__(self, parent=None, name=None, modal=False,
-                 fromEric=True, displayMode=ConfigurationWidget.DefaultMode):
+                 fromEric=True, displayMode=ConfigurationWidget.DefaultMode,
+                 expandedEntries=[]):
         """
         Constructor
         
@@ -776,6 +817,8 @@
             eric6 ide (boolean)
         @keyparam displayMode mode of the configuration dialog
             (DefaultMode, HelpBrowserMode, TrayStarterMode)
+        @keyparam expandedEntries list of entries to be shown expanded
+            (list of strings)
         """
         super(ConfigurationDialog, self).__init__(parent)
         if name:
@@ -786,7 +829,8 @@
         self.layout.setSpacing(0)
         
         self.cw = ConfigurationWidget(self, fromEric=fromEric,
-                                      displayMode=displayMode)
+                                      displayMode=displayMode,
+                                      expandedEntries=expandedEntries)
         size = self.cw.size()
         self.layout.addWidget(self.cw)
         self.resize(size)
@@ -828,6 +872,14 @@
         """
         return self.cw.getConfigurationPageName()
         
+    def getExpandedEntries(self):
+        """
+        Public method to get a list of expanded entries.
+        
+        @return list of expanded entries (list of string)
+        """
+        return self.cw.getExpandedEntries()
+        
     def setPreferences(self):
         """
         Public method called to store the selected values into the preferences

eric ide

mercurial