Tue, 28 Dec 2021 15:04:17 +0100
Added configuration capability for the path containing the style icon sub-directories.
--- a/eric7/EricWidgets/EricApplication.py Tue Dec 28 15:02:01 2021 +0100 +++ b/eric7/EricWidgets/EricApplication.py Tue Dec 28 15:04:17 2021 +0100 @@ -180,6 +180,25 @@ return self.__pluginObjectRegistry[name][1] + def getStyleIconsPath(self): + """ + Public method to get the path for the style icons. + + @return directory path containing the style icons + @rtype str + """ + import Preferences + from eric7config import getConfig + + styleIconsPath = Preferences.getUI("StyleIconsPath") + if not styleIconsPath: + # default is the 'StyleIcons' sub-directory of the icons + # directory + styleIconsPath = os.path.join( + getConfig('ericIconDir'), "StyleIcons") + + return styleIconsPath + def setStyleSheetFile(self, filename): """ Public method to read a QSS style sheet file and set the application @@ -188,9 +207,6 @@ @param filename name of the QSS style sheet file @type str """ - import Preferences - from eric7config import getConfig - if filename: try: with open(filename, "r", encoding="utf-8") as f: @@ -212,12 +228,7 @@ if styleSheet: # preprocess the style sheet to replace the placeholder for the # path to the icons - styleIconsPath = Preferences.getUI("StyleIconsPath") - if not styleIconsPath: - # default ist the 'StyleIcons' subdirectory of the icons - # directory - styleIconsPath = os.path.join( - getConfig('ericIconDir'), "StyleIcons") + styleIconsPath = self.getStyleIconsPath() styleSheet = styleSheet.replace("${path}", styleIconsPath) if "QPalette {" in styleSheet:
--- a/eric7/Preferences/ConfigurationPages/InterfacePage.py Tue Dec 28 15:02:01 2021 +0100 +++ b/eric7/Preferences/ConfigurationPages/InterfacePage.py Tue Dec 28 15:04:17 2021 +0100 @@ -15,6 +15,7 @@ from EricWidgets.EricPathPicker import EricPathPickerModes from EricWidgets.EricIconBar import EricIconBar +from EricWidgets.EricApplication import ericApp from .ConfigurationPageBase import ConfigurationPageBase from .Ui_InterfacePage import Ui_InterfacePage @@ -44,6 +45,11 @@ "All files (*)")) self.styleSheetPicker.setDefaultDirectory(getConfig("ericStylesDir")) + styleIconsPath = ericApp().getStyleIconsPath() + self.styleIconsPathPicker.setMode( + EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE) + self.styleIconsPathPicker.setDefaultDirectory(styleIconsPath) + for iconBarSize in EricIconBar.BarSizes: self.iconSizeComboBox.addItem( EricIconBar.BarSizes[iconBarSize][2], iconBarSize) @@ -68,6 +74,7 @@ self.filenameLengthSpinBox.setValue( Preferences.getUI("CaptionFilenameLength")) self.styleSheetPicker.setText(Preferences.getUI("StyleSheet")) + self.styleIconsPathPicker.setText(Preferences.getUI("StyleIconsPath")) layoutType = Preferences.getUI("LayoutType") if layoutType == "Sidebars": @@ -152,6 +159,9 @@ Preferences.setUI( "StyleSheet", self.styleSheetPicker.text()) + Preferences.setUI( + "StyleIconsPath", + self.styleIconsPathPicker.text()) # save the language settings uiLanguageIndex = self.languageComboBox.currentIndex()
--- a/eric7/Preferences/ConfigurationPages/InterfacePage.ui Tue Dec 28 15:02:01 2021 +0100 +++ b/eric7/Preferences/ConfigurationPages/InterfacePage.ui Tue Dec 28 15:04:17 2021 +0100 @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>550</width> - <height>1048</height> + <height>1140</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -194,6 +194,29 @@ </property> </widget> </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Style Icons Path:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="EricPathPicker" name="styleIconsPathPicker" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>Qt::StrongFocus</enum> + </property> + <property name="toolTip"> + <string>Enter the path to the icons used within the style sheet (empty for default)</string> + </property> + </widget> + </item> </layout> </item> <item> @@ -614,6 +637,7 @@ <tabstop>filenameLengthSpinBox</tabstop> <tabstop>styleComboBox</tabstop> <tabstop>styleSheetPicker</tabstop> + <tabstop>styleIconsPathPicker</tabstop> <tabstop>iconBarButton</tabstop> <tabstop>iconSizeComboBox</tabstop> <tabstop>combinedLeftRightSidebarCheckBox</tabstop>
--- a/eric7/Preferences/__init__.py Tue Dec 28 15:02:01 2021 +0100 +++ b/eric7/Preferences/__init__.py Tue Dec 28 15:04:17 2021 +0100 @@ -114,7 +114,7 @@ "Language": "System", "Style": "System", "StyleSheet": "", - "StyleIconsPath": "", # TODO: add config entry + "StyleIconsPath": "", "ViewManager": "tabview", "LayoutType": "Sidebars", # "Toolboxes" or "Sidebars" "CombinedLeftRightSidebar": False, # place all tools into the
--- a/eric7/UI/Previewers/PreviewerQSS.py Tue Dec 28 15:02:01 2021 +0100 +++ b/eric7/UI/Previewers/PreviewerQSS.py Tue Dec 28 15:04:17 2021 +0100 @@ -15,6 +15,7 @@ ) from EricWidgets.EricPathPicker import EricPathPickerModes +from EricWidgets.EricApplication import ericApp from .Ui_PreviewerQSS import Ui_PreviewerQSS @@ -37,8 +38,10 @@ super().__init__(parent) self.setupUi(self) + styleIconsPath = ericApp().getStyleIconsPath() self.styleIconsPathPicker.setMode( EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE) + self.styleIconsPathPicker.setDefaultDirectory(styleIconsPath) self.__lastEditor = None