Skip to content

Commit 5aa66b3

Browse files
authored
Merge pull request #346 from ales-erjavec/optional-symbolic-icons
[ENH] Make symbolic icons optional
2 parents 0498177 + a061d09 commit 5aa66b3

3 files changed

Lines changed: 38 additions & 11 deletions

File tree

i18n/si/msgs.jaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ resources.py:
223223
icons/default-widget.svg: false
224224
def `icon_glob`:
225225
_*: false
226-
def `is_icon_glob`:
227-
_*: false
226+
-symbolic: false
228227
def `get`:
229228
.svg: false
230229
current-color-scheme: false
230+
.*-symbolic\.\w+$: false
231231
def `load_styled_svg_icon`:
232232
icons/{name}: false
233233
application/aboutdialog.py:
@@ -2034,7 +2034,7 @@ document/schemeedit.py:
20342034
def `__toggleNewTextAnnotation`:
20352035
Canceled new text annotation: false
20362036
def `__triggerNewTextAnnotation`:
2037-
text/markdown: false
2037+
text/markdown: false
20382038
def `__onHelpAction`:
20392039
help://search?: false
20402040
id: false
@@ -2268,10 +2268,13 @@ gui/svgiconengine.py:
22682268
.ColorScheme-Background {{
22692269
color: {background};
22702270
}}
2271+
.ColorScheme-ViewBackground {{
2272+
color: {base};
2273+
}}
22712274
.ColorScheme-Highlight {{
22722275
color: {highlight};
22732276
}}
2274-
.ColorScheme-Disabled-Text {{
2277+
.ColorScheme-DisabledText {{
22752278
color: {disabled_text};
22762279
}}
22772280
.ColorScheme-Contrast {{
@@ -2280,6 +2283,15 @@ gui/svgiconengine.py:
22802283
.ColorScheme-Complement {{
22812284
color: {complement};
22822285
}}
2286+
.ColorScheme-PositiveText {{
2287+
color:#27ae60;
2288+
}}
2289+
.ColorScheme-NeutralText {{
2290+
color:#f67400;
2291+
}}
2292+
.ColorScheme-NegativeText {{
2293+
color:#da4453;
2294+
}}
22832295
': false
22842296
def `replace_css_style`:
22852297
current-color-scheme: false

orangecanvas/gui/svgiconengine.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,13 @@ def clone(self) -> 'QIconEngine':
217217
.ColorScheme-Background {{
218218
color: {background};
219219
}}
220+
.ColorScheme-ViewBackground {{
221+
color: {base};
222+
}}
220223
.ColorScheme-Highlight {{
221224
color: {highlight};
222225
}}
223-
.ColorScheme-Disabled-Text {{
226+
.ColorScheme-DisabledText {{
224227
color: {disabled_text};
225228
}}
226229
.ColorScheme-Contrast {{
@@ -229,6 +232,15 @@ def clone(self) -> 'QIconEngine':
229232
.ColorScheme-Complement {{
230233
color: {complement};
231234
}}
235+
.ColorScheme-PositiveText {{
236+
color:#27ae60;
237+
}}
238+
.ColorScheme-NeutralText {{
239+
color:#f67400;
240+
}}
241+
.ColorScheme-NegativeText {{
242+
color:#da4453;
243+
}}
232244
"""
233245

234246

@@ -252,13 +264,15 @@ def render_svg_color_scheme_css(palette: QPalette, state: QIcon.State) -> str:
252264
selected = state == QIcon.Selected
253265
text = QPalette.HighlightedText if selected else QPalette.WindowText
254266
background = QPalette.Highlight if selected else QPalette.Window
267+
base = QPalette.Base
255268
hligh = QPalette.HighlightedText if selected else QPalette.Highlight
256269
lum = luminance(palette.color(background))
257270
complement = QColor(Qt.white) if lum > 0.5 else QColor(Qt.black)
258271
contrast = QColor(Qt.black) if lum > 0.5 else QColor(Qt.white)
259272
return TEMPLATE.format(
260273
text=_hexrgb_solid(palette.color(text), palette.color(background)),
261274
background=_hexrgb_solid(palette.color(background)),
275+
base=_hexrgb_solid(palette.color(base)),
262276
highlight=_hexrgb_solid(palette.color(hligh)),
263277
disabled_text=_hexrgb_solid(palette.color(QPalette.Disabled, text),
264278
palette.color(QPalette.Disabled, background)),

orangecanvas/resources.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import glob
77
import pkgutil
8+
import re
89
from typing import Tuple, Dict, Optional, List, IO
910

1011
from AnyQt.QtCore import QObject
@@ -172,14 +173,13 @@ def match(self, path):
172173
def icon_glob(self, path):
173174
# type: (str) -> List[str]
174175
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)
177179

178180
def is_icon_glob(self, path):
179181
# 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))
183183

184184
def get(self, name, default=None):
185185
# type: (str, Optional[str]) -> QIcon
@@ -218,7 +218,8 @@ def get(self, name, default=None):
218218
if cache_key not in self._icon_cache:
219219
for path in icons:
220220
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))
222223
self._icon_cache[cache_key] = icon
223224
else:
224225
icon = self._icon_cache[cache_key]

0 commit comments

Comments
 (0)