eric7/UI/Previewers/PreviewerQSS.py

branch
eric7
changeset 8843
586ee2c4553a
parent 8834
c7c3cedb5db3
child 8848
c3d1b62da058
equal deleted inserted replaced
8842:80ce644a6067 8843:586ee2c4553a
12 from PyQt6.QtCore import pyqtSlot, Qt 12 from PyQt6.QtCore import pyqtSlot, Qt
13 from PyQt6.QtWidgets import ( 13 from PyQt6.QtWidgets import (
14 QWidget, QMenu, QLabel, QHeaderView, QListWidgetItem 14 QWidget, QMenu, QLabel, QHeaderView, QListWidgetItem
15 ) 15 )
16 16
17 from EricWidgets.EricPathPicker import EricPathPickerModes
18
17 from .Ui_PreviewerQSS import Ui_PreviewerQSS 19 from .Ui_PreviewerQSS import Ui_PreviewerQSS
18 20
19 import Preferences 21 import Preferences
20 import UI.PixmapCache 22 import UI.PixmapCache
21 23
24 from eric7config import getConfig
22 25
23 class PreviewerQSS(QWidget, Ui_PreviewerQSS): 26 class PreviewerQSS(QWidget, Ui_PreviewerQSS):
24 """ 27 """
25 Class implementing a previewer widget for Qt style sheet files. 28 Class implementing a previewer widget for Qt style sheet files.
26 """ 29 """
30 33
31 @param parent reference to the parent widget (QWidget) 34 @param parent reference to the parent widget (QWidget)
32 """ 35 """
33 super().__init__(parent) 36 super().__init__(parent)
34 self.setupUi(self) 37 self.setupUi(self)
38
39 self.styleIconsPathPicker.setMode(
40 EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE)
41
42 self.__lastEditor = None
35 43
36 # menu for the tool button 44 # menu for the tool button
37 self.__toolButtonMenu = QMenu(self) 45 self.__toolButtonMenu = QMenu(self)
38 self.__toolButtonMenu.addAction(self.tr("Action 1")) 46 self.__toolButtonMenu.addAction(self.tr("Action 1"))
39 self.__toolButtonMenu.addSeparator() 47 self.__toolButtonMenu.addSeparator()
58 ("fileJavascript", self.tr("JavaScript")), 66 ("fileJavascript", self.tr("JavaScript")),
59 ): 67 ):
60 self.iconsListWidget.addItem(QListWidgetItem( 68 self.iconsListWidget.addItem(QListWidgetItem(
61 UI.PixmapCache.getIcon(iconName), labelText)) 69 UI.PixmapCache.getIcon(iconName), labelText))
62 70
71 @pyqtSlot(str)
72 def on_styleIconsPathPicker_textChanged(self, txt):
73 """
74 Private slot handling a change of the style icons path.
75
76 @param txt name of the style icons directory
77 @type str
78 """
79 self.processEditor(self.__lastEditor)
80
63 def processEditor(self, editor=None): 81 def processEditor(self, editor=None):
64 """ 82 """
65 Public slot to process an editor's text. 83 Public slot to process an editor's text.
66 84
67 @param editor editor to be processed (Editor) 85 @param editor editor to be processed (Editor)
68 """ 86 """
87 self.__lastEditor = editor
88
69 if editor is not None: 89 if editor is not None:
70 fn = editor.getFileName() 90 fn = editor.getFileName()
71 91
72 if fn: 92 if fn:
73 extension = os.path.normcase(os.path.splitext(fn)[1][1:]) 93 extension = os.path.normcase(os.path.splitext(fn)[1][1:])
77 extension in Preferences.getEditor( 97 extension in Preferences.getEditor(
78 "PreviewQssFileNameExtensions") 98 "PreviewQssFileNameExtensions")
79 ): 99 ):
80 styleSheet = editor.text() 100 styleSheet = editor.text()
81 if styleSheet: 101 if styleSheet:
102 styleIconsPath = self.styleIconsPathPicker.text()
103 if not styleIconsPath:
104 styleIconsPath = Preferences.getUI("StyleIconsPath")
105 if not styleIconsPath:
106 # default ist the 'StyleIcons' subdirectory of the
107 # icons directory
108 styleIconsPath = os.path.join(
109 getConfig('ericIconDir'), "StyleIcons")
110
111 styleSheet = styleSheet.replace("${path}", styleIconsPath)
82 self.scrollAreaWidgetContents.setStyleSheet(styleSheet) 112 self.scrollAreaWidgetContents.setStyleSheet(styleSheet)
83 else: 113 else:
84 self.scrollAreaWidgetContents.setStyleSheet("") 114 self.scrollAreaWidgetContents.setStyleSheet("")
85 self.toolButton.menu().setStyleSheet( 115 self.toolButton.menu().setStyleSheet(
86 self.scrollAreaWidgetContents.styleSheet()) 116 self.scrollAreaWidgetContents.styleSheet())

eric ide

mercurial