silx.gui.icons: Improved silx icons to support dark color theme#4593
Draft
t20100 wants to merge 1 commit into
Draft
silx.gui.icons: Improved silx icons to support dark color theme#4593t20100 wants to merge 1 commit into
t20100 wants to merge 1 commit into
Conversation
t20100
commented
May 6, 2026
Comment on lines
+421
to
+422
| qfile = getQFile(name) | ||
| icon = qt.QIcon(qfile.fileName()) |
Member
Author
There was a problem hiding this comment.
Kept previous implementation for other application using silx icon mechanism but in silx we can consider completely remove .png icons.
Comment on lines
+108
to
+110
| svgpath = re.sub( | ||
| b'fill="(#000000|#000)"', f'fill="{foreground}"'.encode(), svgpath | ||
| ) |
Member
Author
There was a problem hiding this comment.
svg default fill is black and this can be overridden in with fill declared in the <svg> tag.
To complete this PR, the idea is to patch existing icons to remove unnecessary fill="#000" so this substitution is not needed. This would allow to explicitly set a fill color to black even in dark mode.
Comment on lines
+111
to
+113
| svgpath = re.sub( | ||
| b'stroke="(#000000|#000)"', f'stroke="{foreground}"'.encode(), svgpath | ||
| ) |
Member
Author
There was a problem hiding this comment.
svg default stroke is "none" so overriding the default in <svg> does not work as for fill....
Comment on lines
+124
to
+127
| if isDark != self._isDarkColorScheme: | ||
| self._renderer.load(self._darkSvgPath if isDark else self._lightSvgPath) | ||
| self._isDarkColorScheme = isDark | ||
|
|
Member
Author
There was a problem hiding this comment.
Reload icon only when needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
<Module or Topic>: <Action> <Summary>(see contributing guidelines)PR summary
This PR adds a QIconEngine to hook into QIcon rendering and "patch" the svg when the application is in dark mode.
This adds a bit of complexity to the icon module but it is fully transparent from a user point of view: Icons automatically adapts to color scheme changes.
There is still some thing to be done:
related to #4486
AI Disclosure