--- a/eric7/UI/Previewers/PreviewerQSS.py Sun Dec 19 19:38:18 2021 +0100 +++ b/eric7/UI/Previewers/PreviewerQSS.py Mon Dec 20 14:51:29 2021 +0100 @@ -14,11 +14,14 @@ QWidget, QMenu, QLabel, QHeaderView, QListWidgetItem ) +from EricWidgets.EricPathPicker import EricPathPickerModes + from .Ui_PreviewerQSS import Ui_PreviewerQSS import Preferences import UI.PixmapCache +from eric7config import getConfig class PreviewerQSS(QWidget, Ui_PreviewerQSS): """ @@ -33,6 +36,11 @@ super().__init__(parent) self.setupUi(self) + self.styleIconsPathPicker.setMode( + EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE) + + self.__lastEditor = None + # menu for the tool button self.__toolButtonMenu = QMenu(self) self.__toolButtonMenu.addAction(self.tr("Action 1")) @@ -60,12 +68,24 @@ self.iconsListWidget.addItem(QListWidgetItem( UI.PixmapCache.getIcon(iconName), labelText)) + @pyqtSlot(str) + def on_styleIconsPathPicker_textChanged(self, txt): + """ + Private slot handling a change of the style icons path. + + @param txt name of the style icons directory + @type str + """ + self.processEditor(self.__lastEditor) + def processEditor(self, editor=None): """ Public slot to process an editor's text. @param editor editor to be processed (Editor) """ + self.__lastEditor = editor + if editor is not None: fn = editor.getFileName() @@ -79,6 +99,16 @@ ): styleSheet = editor.text() if styleSheet: + styleIconsPath = self.styleIconsPathPicker.text() + if not styleIconsPath: + styleIconsPath = Preferences.getUI("StyleIconsPath") + if not styleIconsPath: + # default ist the 'StyleIcons' subdirectory of the + # icons directory + styleIconsPath = os.path.join( + getConfig('ericIconDir'), "StyleIcons") + + styleSheet = styleSheet.replace("${path}", styleIconsPath) self.scrollAreaWidgetContents.setStyleSheet(styleSheet) else: self.scrollAreaWidgetContents.setStyleSheet("")