|
5 | 5 | import os |
6 | 6 | import glob |
7 | 7 | import pkgutil |
| 8 | +import re |
8 | 9 | from typing import Tuple, Dict, Optional, List, IO |
9 | 10 |
|
10 | 11 | from AnyQt.QtCore import QObject |
@@ -172,14 +173,13 @@ def match(self, path): |
172 | 173 | def icon_glob(self, path): |
173 | 174 | # type: (str) -> List[str] |
174 | 175 | name, ext = os.path.splitext(path) |
175 | | - pattern = name + "_*" + ext |
176 | | - return glob.glob(pattern) |
| 176 | + pattern1 = name + "_*" + ext |
| 177 | + pattern2 = name + "-symbolic" + ext |
| 178 | + return glob.glob(pattern1) + glob.glob(pattern2) |
177 | 179 |
|
178 | 180 | def is_icon_glob(self, path): |
179 | 181 | # type: (str) -> bool |
180 | | - name, ext = os.path.splitext(path) |
181 | | - pattern = name + "_*" + ext |
182 | | - return bool(glob.glob(pattern)) |
| 182 | + return bool(self.icon_glob(path)) |
183 | 183 |
|
184 | 184 | def get(self, name, default=None): |
185 | 185 | # type: (str, Optional[str]) -> QIcon |
@@ -218,7 +218,8 @@ def get(self, name, default=None): |
218 | 218 | if cache_key not in self._icon_cache: |
219 | 219 | for path in icons: |
220 | 220 | icon.addFile(path) |
221 | | - icon = QIcon(SymbolIconEngine(icon)) |
| 221 | + if len(icons) == 1 and re.match(r".*-symbolic\.\w+$", icons[0]): |
| 222 | + icon = QIcon(SymbolIconEngine(icon)) |
222 | 223 | self._icon_cache[cache_key] = icon |
223 | 224 | else: |
224 | 225 | icon = self._icon_cache[cache_key] |
|
0 commit comments