From 6c69eb40216c9f6ad27b3f03cbcbc2b0512d7dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 12 Jun 2023 13:26:21 +0200 Subject: [PATCH] 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 (cherry picked from commit 883c3dc8c8c014528e77ecbc4b4ed7d7504afa42) Reviewed-by: Qt Cherry-pick Bot --- src/gui/image/qiconloader.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 3aa5fa5057b..49e7b7731fe 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -119,19 +119,14 @@ QIconLoader *QIconLoader::instance() // icons if the theme has changed. void QIconLoader::updateSystemTheme() { - // Only change if this is not explicitly set by the user - if (m_userTheme.isEmpty()) { - QString theme = systemThemeName(); - if (theme.isEmpty()) - theme = fallbackThemeName(); - if (theme != m_systemTheme) { - m_systemTheme = theme; - qCDebug(lcIconLoader) << "Updated system theme to" << m_systemTheme; + const QString currentSystemTheme = m_systemTheme; + m_systemTheme = systemThemeName(); + if (m_systemTheme.isEmpty()) + m_systemTheme = fallbackThemeName(); + if (m_systemTheme != currentSystemTheme) { + qCDebug(lcIconLoader) << "Updated system theme to" << m_systemTheme; + if (!hasUserTheme()) invalidateKey(); - } - } else { - qCDebug(lcIconLoader) << "Ignoring system theme update because" - << "user theme" << m_userTheme << "has been set"; } }