Change SVG icons color in the editor
Implements feature #7953 (closed).
Use the same apporoach as in Qt-Advanced-Stylesheets project:
- Implement a custom icon engine, which replaces some color tags in SVG icon data by another colors (in current implementation I use a text color from current style and use a
#4d4d4d
as a template color). - Use a static set of all instances of new icon engine (one per icon, and icon itself controls icon engine instance lifetime).
- If current color scheme changed, update icons for all objects from this set.
Dark mode: https://imgsli.com/MjU5NDQz
Light mode: https://imgsli.com/MjU5NDQy
Notes:
- A main drawback of this approach is that we use
QSvgRenderer
directly, but it does not support icon modes (selected, active, disabled). For now I use grayscale images with 50% transparency for disabled icons to emulate a disabled mode. - I had to adjust a part of SVG icons to adapt them to new feature (mostly filling and lines color).
- On Windows runtime theme change is handled by
QEvent::ThemeChange
, on Linux - byQEvent::PaletteChange
. Can not tell anything about MacOS X. - This feature can be reused for launcher, where we load 3d-party themes for about of 5 icons (needs a discussion).
Edited by Andrei Kortunov