178 raise KeyError( |
178 raise KeyError( |
179 'Pluginobject "{0}" is not registered.'.format(name)) |
179 'Pluginobject "{0}" is not registered.'.format(name)) |
180 |
180 |
181 return self.__pluginObjectRegistry[name][1] |
181 return self.__pluginObjectRegistry[name][1] |
182 |
182 |
|
183 def getStyleIconsPath(self): |
|
184 """ |
|
185 Public method to get the path for the style icons. |
|
186 |
|
187 @return directory path containing the style icons |
|
188 @rtype str |
|
189 """ |
|
190 import Preferences |
|
191 from eric7config import getConfig |
|
192 |
|
193 styleIconsPath = Preferences.getUI("StyleIconsPath") |
|
194 if not styleIconsPath: |
|
195 # default is the 'StyleIcons' sub-directory of the icons |
|
196 # directory |
|
197 styleIconsPath = os.path.join( |
|
198 getConfig('ericIconDir'), "StyleIcons") |
|
199 |
|
200 return styleIconsPath |
|
201 |
183 def setStyleSheetFile(self, filename): |
202 def setStyleSheetFile(self, filename): |
184 """ |
203 """ |
185 Public method to read a QSS style sheet file and set the application |
204 Public method to read a QSS style sheet file and set the application |
186 style sheet based on its contents. |
205 style sheet based on its contents. |
187 |
206 |
188 @param filename name of the QSS style sheet file |
207 @param filename name of the QSS style sheet file |
189 @type str |
208 @type str |
190 """ |
209 """ |
191 import Preferences |
|
192 from eric7config import getConfig |
|
193 |
|
194 if filename: |
210 if filename: |
195 try: |
211 try: |
196 with open(filename, "r", encoding="utf-8") as f: |
212 with open(filename, "r", encoding="utf-8") as f: |
197 styleSheet = f.read() |
213 styleSheet = f.read() |
198 except OSError as msg: |
214 except OSError as msg: |
210 styleSheet = "" |
226 styleSheet = "" |
211 |
227 |
212 if styleSheet: |
228 if styleSheet: |
213 # preprocess the style sheet to replace the placeholder for the |
229 # preprocess the style sheet to replace the placeholder for the |
214 # path to the icons |
230 # path to the icons |
215 styleIconsPath = Preferences.getUI("StyleIconsPath") |
231 styleIconsPath = self.getStyleIconsPath() |
216 if not styleIconsPath: |
|
217 # default ist the 'StyleIcons' subdirectory of the icons |
|
218 # directory |
|
219 styleIconsPath = os.path.join( |
|
220 getConfig('ericIconDir'), "StyleIcons") |
|
221 styleSheet = styleSheet.replace("${path}", styleIconsPath) |
232 styleSheet = styleSheet.replace("${path}", styleIconsPath) |
222 |
233 |
223 if "QPalette {" in styleSheet: |
234 if "QPalette {" in styleSheet: |
224 self.__setPaletteFromStyleSheet(styleSheet) |
235 self.__setPaletteFromStyleSheet(styleSheet) |
225 |
236 |