Skip to content

Set fallback theme path when a custom icon theme is used

Joshua Goins requested to merge work/redstrate/custom-icons into master

When a custom icon theme is used, built-in Breeze icons are unavailable. This is due to some undocumented Qt behavior regarding loosely organized icon files, so when the theme name is explicitly set, make sure to add the icons directory to the fallback search paths so the icons still work.

Reasoning

Currently while we are awaiting some icons getting upstreamed into Breeze, Tokodon uses a custom icon theme. On desktop this works fine, but for some reason on Android icons don't load. To be more specific, it's either that the built-in Breeze icons load or ours does - for some reason you can't have both.

There is some what I assume is undocumented behavior regarding Qt icon themes. Built-in Breeze icons are loosely organized but Tokodon's is XDG-compliant. Tokodon will eventually set (it doesn't yet) the icon theme on Android explicitly to "tokodon" which then interferes with KirigamiPlugin::registerTypes(), so the built-in icons are never set in any search path. So now we set the fallback icon path so Breeze icons show up as the fallback. Note that I use the "icons" directory in the fallback (unlike "."), this is not a mistake and is required for Qt to properly load the loose icons. We cannot go the other way ("tokodon" being the fallback and "breeze-internal" being the main theme) because Qt refuses to load one of the icon themes, hence why I chose to set it via fallback. I made sure to append it to the existing fallback search paths just in case other Kirigami applications depend on this.

I tested this on Android and Linux and there doesn't seem to be any repercussions but more testing is appreciated. Should be backported to KF5.

Merge request reports