4 # |
4 # |
5 |
5 |
6 """ |
6 """ |
7 Class implementing a specialized application class. |
7 Class implementing a specialized application class. |
8 """ |
8 """ |
|
9 |
|
10 import os |
9 |
11 |
10 from PyQt6.QtCore import Qt, QCoreApplication |
12 from PyQt6.QtCore import Qt, QCoreApplication |
11 from PyQt6.QtGui import QColor, QPalette |
13 from PyQt6.QtGui import QColor, QPalette |
12 from PyQt6.QtWidgets import QApplication |
14 from PyQt6.QtWidgets import QApplication |
13 |
15 |
184 style sheet based on its contents. |
186 style sheet based on its contents. |
185 |
187 |
186 @param filename name of the QSS style sheet file |
188 @param filename name of the QSS style sheet file |
187 @type str |
189 @type str |
188 """ |
190 """ |
|
191 import Preferences |
|
192 from eric7config import getConfig |
|
193 |
189 if filename: |
194 if filename: |
190 try: |
195 try: |
191 with open(filename, "r", encoding="utf-8") as f: |
196 with open(filename, "r", encoding="utf-8") as f: |
192 styleSheet = f.read() |
197 styleSheet = f.read() |
193 except OSError as msg: |
198 except OSError as msg: |
202 .format(filename, str(msg))) |
207 .format(filename, str(msg))) |
203 return |
208 return |
204 else: |
209 else: |
205 styleSheet = "" |
210 styleSheet = "" |
206 |
211 |
|
212 if styleSheet: |
|
213 # preprocess the style sheet to replace the placeholder for the |
|
214 # path to the icons |
|
215 styleIconsPath = Preferences.getUI("StyleIconsPath") |
|
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) |
|
222 |
207 if "QPalette {" in styleSheet: |
223 if "QPalette {" in styleSheet: |
208 self.__setPaletteFromStyleSheet(styleSheet) |
224 self.__setPaletteFromStyleSheet(styleSheet) |
209 |
225 |
210 ericApp().setStyleSheet(styleSheet) |
226 ericApp().setStyleSheet(styleSheet) |
211 |
227 |