src/eric7/Preferences/ConfigurationDialog.py

branch
eric7
changeset 10132
66c11ab8fefd
parent 10084
125166c6b66c
child 10135
36839e2c6945
--- a/src/eric7/Preferences/ConfigurationDialog.py	Mon Jul 24 11:56:29 2023 +0200
+++ b/src/eric7/Preferences/ConfigurationDialog.py	Mon Jul 24 14:36:06 2023 +0200
@@ -85,6 +85,7 @@
     EDITORMODE = 4
     PDFVIEWERMODE = 5
     PIPMANAGERMODE = 6
+    SHELLMODE = 7
 
 
 class ConfigurationWidget(QWidget):
@@ -109,19 +110,23 @@
         fromEric=True,
         displayMode=ConfigurationMode.DEFAULTMODE,
         expandedEntries=None,
+        withApply=True,
     ):
         """
         Constructor
 
-        @param parent reference to the parent widget
-        @type QWidget
+        @param parent reference to the parent widget (defaults to None)
+        @type QWidget (optional)
         @param fromEric flag indicating a dialog generation from within the
-            eric IDE
-        @type bool
-        @param displayMode mode of the configuration dialog
-        @type ConfigurationMode
-        @param expandedEntries list of entries to be shown expanded
-        @type list of str
+            eric IDE (defaults to True)
+        @type bool (optional)
+        @param displayMode mode of the configuration dialog (defaults to
+            ConfigurationMode.DEFAULTMODE)
+        @type ConfigurationMode (optional)
+        @param expandedEntries list of entries to be shown expanded (defaults to None)
+        @type list of str (optional)
+        @param withApply flag indicating to show the 'Apply' button (defaults to True)
+        @type bool (optional)
         """
         super().__init__(parent)
 
@@ -130,7 +135,7 @@
         self.__webEngine = getWebBrowserSupport() == "QtWebEngine"
         expandedEntries = [] if expandedEntries is None else expandedEntries[:]
 
-        self.__setupUi()
+        self.__setupUi(withApply=withApply)
 
         self.itmDict = {}
 
@@ -933,6 +938,37 @@
                 ],
             }
 
+        elif displayMode == ConfigurationMode.SHELLMODE:
+            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
+                # create the configuration page. This must have the method
+                # 'save' to save the settings.
+                "iconsPage": [
+                    self.tr("Icons"),
+                    "preferences-icons",
+                    "IconsPage",
+                    None,
+                    None,
+                ],
+                "interfacePage": [
+                    self.tr("Interface"),
+                    "preferences-interface",
+                    "InterfaceLightPage",
+                    None,
+                    None,
+                ],
+                "shellPage": [
+                    self.tr("Shell"),
+                    "preferences-shell",
+                    "ShellPage",
+                    None,
+                    None,
+                ],
+            }
+
         else:
             # display mode for generic use
             self.configItems = {
@@ -994,6 +1030,9 @@
             ConfigurationMode.TRAYSTARTERMODE,
             ConfigurationMode.HEXEDITORMODE,
             ConfigurationMode.WEBBROWSERMODE,
+            ConfigurationMode.PDFVIEWERMODE,
+            ConfigurationMode.PIPMANAGERMODE,
+            ConfigurationMode.SHELLMODE,
         ]:
             self.configListSearch.hide()
 
@@ -1014,10 +1053,13 @@
 
         self.accepted.emit()
 
-    def __setupUi(self):
+    def __setupUi(self, withApply=True):
         """
         Private method to perform the general setup of the configuration
         widget.
+
+        @param withApply flag indicating to show the 'Apply' button (defaults to True)
+        @type bool (optional)
         """
         self.setObjectName("ConfigurationDialog")
         self.resize(900, 750)
@@ -1103,7 +1145,9 @@
             | QDialogButtonBox.StandardButton.Reset
         )
         self.buttonBox.setObjectName("buttonBox")
-        if not self.fromEric and self.displayMode == ConfigurationMode.DEFAULTMODE:
+        if (
+            not self.fromEric and self.displayMode == ConfigurationMode.DEFAULTMODE
+        ) or not withApply:
             self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).hide()
         self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).setEnabled(False)
         self.buttonBox.button(QDialogButtonBox.StandardButton.Reset).setEnabled(False)
@@ -1468,19 +1512,20 @@
         """
         Constructor
 
-        @param parent reference to the parent widget
-        @type QWidget
-        @param name name of the dialog
-        @type str
-        @param modal flag indicating a modal dialog
-        @type bool
+        @param parent reference to the parent widget (defaults to None)
+        @type QWidget (optional)
+        @param name name of the dialog (defaults to None)
+        @type str (optional)
+        @param modal flag indicating a modal dialog (defaults to False)
+        @type bool (optional)
         @param fromEric flag indicating a dialog generation from within the
-            eric IDE
-        @type bool
-        @param displayMode mode of the configuration dialog
-        @type ConfigurationMode
-        @param expandedEntries list of entries to be shown expanded
-        @type list of str
+            eric IDE (defaults to True)
+        @type bool (optional)
+        @param displayMode mode of the configuration dialog (defaults to
+            ConfigurationMode.DEFAULTMODE)
+        @type ConfigurationMode (optional)
+        @param expandedEntries list of entries to be shown expanded (defaults to None)
+        @type list of str (optional)
         """
         super().__init__(parent)
         if name:
@@ -1497,6 +1542,7 @@
             fromEric=fromEric,
             displayMode=displayMode,
             expandedEntries=expandedEntries,
+            withApply=not modal,
         )
         size = self.cw.size()
         self.layout.addWidget(self.cw)
@@ -1576,7 +1622,7 @@
         """
         super().__init__(parent)
 
-        self.cw = ConfigurationWidget(self, fromEric=False)
+        self.cw = ConfigurationWidget(self, fromEric=False, withApply=False)
         size = self.cw.size()
         self.setCentralWidget(self.cw)
         self.resize(size)
@@ -1584,6 +1630,9 @@
 
         self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
 
+        # Setting the style sheet above set the button state of the Apply button
+        # to be visible. So we need to hide it again.
+        self.cw.buttonBox.button(QDialogButtonBox.StandardButton.Apply).hide()
         self.cw.accepted.connect(self.accept)
         self.cw.rejected.connect(self.close)
 

eric ide

mercurial