Update QIconLoader system theme unconditionally on ThemeChange

We cache the system theme name in QIconLoader, so when a theme change
comes in we need to update the system icon theme name regardless of
whether a user theme has been set.

The updated system theme name will not be reflected through the
QiconLoader::themeNamed() unless the user theme is cleared/unset.

Change-Id: Id949e55e2fa12e40818ba54cf2a10ce48fe10815
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 883c3dc8c8c014528e77ecbc4b4ed7d7504afa42)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2023-06-12 13:26:21 +02:00 committed by Qt Cherry-pick Bot
parent dc7a2d20f8
commit 6c69eb4021

View File

@ -119,19 +119,14 @@ QIconLoader *QIconLoader::instance()
// icons if the theme has changed. // icons if the theme has changed.
void QIconLoader::updateSystemTheme() void QIconLoader::updateSystemTheme()
{ {
// Only change if this is not explicitly set by the user const QString currentSystemTheme = m_systemTheme;
if (m_userTheme.isEmpty()) { m_systemTheme = systemThemeName();
QString theme = systemThemeName(); if (m_systemTheme.isEmpty())
if (theme.isEmpty()) m_systemTheme = fallbackThemeName();
theme = fallbackThemeName(); if (m_systemTheme != currentSystemTheme) {
if (theme != m_systemTheme) { qCDebug(lcIconLoader) << "Updated system theme to" << m_systemTheme;
m_systemTheme = theme; if (!hasUserTheme())
qCDebug(lcIconLoader) << "Updated system theme to" << m_systemTheme;
invalidateKey(); invalidateKey();
}
} else {
qCDebug(lcIconLoader) << "Ignoring system theme update because"
<< "user theme" << m_userTheme << "has been set";
} }
} }