QIconLoader: use system fallback theme as the first fallback option

When searching for an icon, we either use the system theme or the theme
set as a fallback through QPlatformTheme, it's only one or the other.
It can easily happen that the fallback theme we pick as a parent theme
will not fit into the application style (color-wise). For example using
KDE apps on GNOME, where we use "Adwaita" icon theme, we would always
fallback to "Breeze", however, using dark theming, we want to fallback
to "Breeze-dark" and this can be easily set through QPlatformTheme
integration, but it's not going to be used when the system icon theme
is valid and in such case the fallback theme will be ignored.

This change makes the system fallback theme used as the default fallback
by putting it to the list of parent themes.

Pick-to: 6.5 6.2 5.15
Change-Id: I966cd8ddd0e5576e3593d349fe7ee7139136bfdf
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Jan Grulich 2023-05-08 16:47:00 +02:00
parent adbfdacacc
commit 4710fb3528

View File

@ -384,6 +384,10 @@ QIconTheme::QIconTheme(const QString &themeName)
m_parents.append(fallback);
}
// Use system fallback theme as the first fallback option
if (const QString &systemFallback = systemFallbackThemeName(); !systemFallback.isEmpty())
m_parents.prepend(systemFallback);
// Ensure that all themes fall back to hicolor
if (!m_parents.contains("hicolor"_L1))
m_parents.append("hicolor"_L1);