Skip to content

Change SVG icons color in the editor

Andrei Kortunov requested to merge akortunov/openmw:paint_svg into master

Implements feature #7953 (closed).

Use the same apporoach as in Qt-Advanced-Stylesheets project:

  1. 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).
  2. Use a static set of all instances of new icon engine (one per icon, and icon itself controls icon engine instance lifetime).
  3. 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:

  1. 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.
  2. I had to adjust a part of SVG icons to adapt them to new feature (mostly filling and lines color).
  3. On Windows runtime theme change is handled by QEvent::ThemeChange, on Linux - by QEvent::PaletteChange. Can not tell anything about MacOS X.
  4. 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

Merge request reports