src/eric7/Preferences/ConfigurationDialog.py

branch
eric7
changeset 10132
66c11ab8fefd
parent 10084
125166c6b66c
child 10135
36839e2c6945
equal deleted inserted replaced
10131:4488684d1b7d 10132:66c11ab8fefd
83 HEXEDITORMODE = 2 83 HEXEDITORMODE = 2
84 WEBBROWSERMODE = 3 84 WEBBROWSERMODE = 3
85 EDITORMODE = 4 85 EDITORMODE = 4
86 PDFVIEWERMODE = 5 86 PDFVIEWERMODE = 5
87 PIPMANAGERMODE = 6 87 PIPMANAGERMODE = 6
88 SHELLMODE = 7
88 89
89 90
90 class ConfigurationWidget(QWidget): 91 class ConfigurationWidget(QWidget):
91 """ 92 """
92 Class implementing a dialog for the configuration of eric. 93 Class implementing a dialog for the configuration of eric.
107 self, 108 self,
108 parent=None, 109 parent=None,
109 fromEric=True, 110 fromEric=True,
110 displayMode=ConfigurationMode.DEFAULTMODE, 111 displayMode=ConfigurationMode.DEFAULTMODE,
111 expandedEntries=None, 112 expandedEntries=None,
113 withApply=True,
112 ): 114 ):
113 """ 115 """
114 Constructor 116 Constructor
115 117
116 @param parent reference to the parent widget 118 @param parent reference to the parent widget (defaults to None)
117 @type QWidget 119 @type QWidget (optional)
118 @param fromEric flag indicating a dialog generation from within the 120 @param fromEric flag indicating a dialog generation from within the
119 eric IDE 121 eric IDE (defaults to True)
120 @type bool 122 @type bool (optional)
121 @param displayMode mode of the configuration dialog 123 @param displayMode mode of the configuration dialog (defaults to
122 @type ConfigurationMode 124 ConfigurationMode.DEFAULTMODE)
123 @param expandedEntries list of entries to be shown expanded 125 @type ConfigurationMode (optional)
124 @type list of str 126 @param expandedEntries list of entries to be shown expanded (defaults to None)
127 @type list of str (optional)
128 @param withApply flag indicating to show the 'Apply' button (defaults to True)
129 @type bool (optional)
125 """ 130 """
126 super().__init__(parent) 131 super().__init__(parent)
127 132
128 self.fromEric = fromEric 133 self.fromEric = fromEric
129 self.displayMode = displayMode 134 self.displayMode = displayMode
130 self.__webEngine = getWebBrowserSupport() == "QtWebEngine" 135 self.__webEngine = getWebBrowserSupport() == "QtWebEngine"
131 expandedEntries = [] if expandedEntries is None else expandedEntries[:] 136 expandedEntries = [] if expandedEntries is None else expandedEntries[:]
132 137
133 self.__setupUi() 138 self.__setupUi(withApply=withApply)
134 139
135 self.itmDict = {} 140 self.itmDict = {}
136 141
137 if not fromEric: 142 if not fromEric:
138 from eric7.PluginManager.PluginManager import ( # __IGNORE_WARNING_I101__ 143 from eric7.PluginManager.PluginManager import ( # __IGNORE_WARNING_I101__
931 None, 936 None,
932 None, 937 None,
933 ], 938 ],
934 } 939 }
935 940
941 elif displayMode == ConfigurationMode.SHELLMODE:
942 self.configItems = {
943 # key : [display string, pixmap name, dialog module name or
944 # page creation function, parent key,
945 # reference to configuration page (must always be last)]
946 # The dialog module must have the module function 'create' to
947 # create the configuration page. This must have the method
948 # 'save' to save the settings.
949 "iconsPage": [
950 self.tr("Icons"),
951 "preferences-icons",
952 "IconsPage",
953 None,
954 None,
955 ],
956 "interfacePage": [
957 self.tr("Interface"),
958 "preferences-interface",
959 "InterfaceLightPage",
960 None,
961 None,
962 ],
963 "shellPage": [
964 self.tr("Shell"),
965 "preferences-shell",
966 "ShellPage",
967 None,
968 None,
969 ],
970 }
971
936 else: 972 else:
937 # display mode for generic use 973 # display mode for generic use
938 self.configItems = { 974 self.configItems = {
939 # key : [display string, pixmap name, dialog module name or 975 # key : [display string, pixmap name, dialog module name or
940 # page creation function, parent key, 976 # page creation function, parent key,
992 1028
993 if displayMode in [ 1029 if displayMode in [
994 ConfigurationMode.TRAYSTARTERMODE, 1030 ConfigurationMode.TRAYSTARTERMODE,
995 ConfigurationMode.HEXEDITORMODE, 1031 ConfigurationMode.HEXEDITORMODE,
996 ConfigurationMode.WEBBROWSERMODE, 1032 ConfigurationMode.WEBBROWSERMODE,
1033 ConfigurationMode.PDFVIEWERMODE,
1034 ConfigurationMode.PIPMANAGERMODE,
1035 ConfigurationMode.SHELLMODE,
997 ]: 1036 ]:
998 self.configListSearch.hide() 1037 self.configListSearch.hide()
999 1038
1000 if displayMode not in [ 1039 if displayMode not in [
1001 ConfigurationMode.TRAYSTARTERMODE, 1040 ConfigurationMode.TRAYSTARTERMODE,
1012 if wdg == self.configList: 1051 if wdg == self.configList:
1013 return 1052 return
1014 1053
1015 self.accepted.emit() 1054 self.accepted.emit()
1016 1055
1017 def __setupUi(self): 1056 def __setupUi(self, withApply=True):
1018 """ 1057 """
1019 Private method to perform the general setup of the configuration 1058 Private method to perform the general setup of the configuration
1020 widget. 1059 widget.
1060
1061 @param withApply flag indicating to show the 'Apply' button (defaults to True)
1062 @type bool (optional)
1021 """ 1063 """
1022 self.setObjectName("ConfigurationDialog") 1064 self.setObjectName("ConfigurationDialog")
1023 self.resize(900, 750) 1065 self.resize(900, 750)
1024 self.verticalLayout_2 = QVBoxLayout(self) 1066 self.verticalLayout_2 = QVBoxLayout(self)
1025 self.verticalLayout_2.setSpacing(6) 1067 self.verticalLayout_2.setSpacing(6)
1101 | QDialogButtonBox.StandardButton.Cancel 1143 | QDialogButtonBox.StandardButton.Cancel
1102 | QDialogButtonBox.StandardButton.Ok 1144 | QDialogButtonBox.StandardButton.Ok
1103 | QDialogButtonBox.StandardButton.Reset 1145 | QDialogButtonBox.StandardButton.Reset
1104 ) 1146 )
1105 self.buttonBox.setObjectName("buttonBox") 1147 self.buttonBox.setObjectName("buttonBox")
1106 if not self.fromEric and self.displayMode == ConfigurationMode.DEFAULTMODE: 1148 if (
1149 not self.fromEric and self.displayMode == ConfigurationMode.DEFAULTMODE
1150 ) or not withApply:
1107 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).hide() 1151 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).hide()
1108 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).setEnabled(False) 1152 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).setEnabled(False)
1109 self.buttonBox.button(QDialogButtonBox.StandardButton.Reset).setEnabled(False) 1153 self.buttonBox.button(QDialogButtonBox.StandardButton.Reset).setEnabled(False)
1110 self.verticalLayout_2.addWidget(self.buttonBox) 1154 self.verticalLayout_2.addWidget(self.buttonBox)
1111 1155
1466 expandedEntries=None, 1510 expandedEntries=None,
1467 ): 1511 ):
1468 """ 1512 """
1469 Constructor 1513 Constructor
1470 1514
1471 @param parent reference to the parent widget 1515 @param parent reference to the parent widget (defaults to None)
1472 @type QWidget 1516 @type QWidget (optional)
1473 @param name name of the dialog 1517 @param name name of the dialog (defaults to None)
1474 @type str 1518 @type str (optional)
1475 @param modal flag indicating a modal dialog 1519 @param modal flag indicating a modal dialog (defaults to False)
1476 @type bool 1520 @type bool (optional)
1477 @param fromEric flag indicating a dialog generation from within the 1521 @param fromEric flag indicating a dialog generation from within the
1478 eric IDE 1522 eric IDE (defaults to True)
1479 @type bool 1523 @type bool (optional)
1480 @param displayMode mode of the configuration dialog 1524 @param displayMode mode of the configuration dialog (defaults to
1481 @type ConfigurationMode 1525 ConfigurationMode.DEFAULTMODE)
1482 @param expandedEntries list of entries to be shown expanded 1526 @type ConfigurationMode (optional)
1483 @type list of str 1527 @param expandedEntries list of entries to be shown expanded (defaults to None)
1528 @type list of str (optional)
1484 """ 1529 """
1485 super().__init__(parent) 1530 super().__init__(parent)
1486 if name: 1531 if name:
1487 self.setObjectName(name) 1532 self.setObjectName(name)
1488 self.setModal(modal) 1533 self.setModal(modal)
1495 self.cw = ConfigurationWidget( 1540 self.cw = ConfigurationWidget(
1496 self, 1541 self,
1497 fromEric=fromEric, 1542 fromEric=fromEric,
1498 displayMode=displayMode, 1543 displayMode=displayMode,
1499 expandedEntries=expandedEntries, 1544 expandedEntries=expandedEntries,
1545 withApply=not modal,
1500 ) 1546 )
1501 size = self.cw.size() 1547 size = self.cw.size()
1502 self.layout.addWidget(self.cw) 1548 self.layout.addWidget(self.cw)
1503 self.resize(size) 1549 self.resize(size)
1504 self.setWindowTitle(self.cw.windowTitle()) 1550 self.setWindowTitle(self.cw.windowTitle())
1574 1620
1575 @param parent reference to the parent widget (QWidget) 1621 @param parent reference to the parent widget (QWidget)
1576 """ 1622 """
1577 super().__init__(parent) 1623 super().__init__(parent)
1578 1624
1579 self.cw = ConfigurationWidget(self, fromEric=False) 1625 self.cw = ConfigurationWidget(self, fromEric=False, withApply=False)
1580 size = self.cw.size() 1626 size = self.cw.size()
1581 self.setCentralWidget(self.cw) 1627 self.setCentralWidget(self.cw)
1582 self.resize(size) 1628 self.resize(size)
1583 self.setWindowTitle(self.cw.windowTitle()) 1629 self.setWindowTitle(self.cw.windowTitle())
1584 1630
1585 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) 1631 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
1586 1632
1633 # Setting the style sheet above set the button state of the Apply button
1634 # to be visible. So we need to hide it again.
1635 self.cw.buttonBox.button(QDialogButtonBox.StandardButton.Apply).hide()
1587 self.cw.accepted.connect(self.accept) 1636 self.cw.accepted.connect(self.accept)
1588 self.cw.rejected.connect(self.close) 1637 self.cw.rejected.connect(self.close)
1589 1638
1590 def showConfigurationPageByName(self, pageName): 1639 def showConfigurationPageByName(self, pageName):
1591 """ 1640 """

eric ide

mercurial