diff --git a/src/gui/uithememanager.cpp b/src/gui/uithememanager.cpp index 3343cfaa5..a48656744 100644 --- a/src/gui/uithememanager.cpp +++ b/src/gui/uithememanager.cpp @@ -140,7 +140,15 @@ QIcon UIThemeManager::getIcon(const QString &iconId, const QString &fallback) co QIcon UIThemeManager::getFlagIcon(const QString &countryIsoCode) const { if (countryIsoCode.isEmpty()) return {}; - return QIcon(":/icons/flags/" + countryIsoCode.toLower() + ".svg"); + + const QString key = countryIsoCode.toLower(); + const auto iter = m_flagCache.find(key); + if (iter != m_flagCache.end()) + return *iter; + + const QIcon icon {QLatin1String(":/icons/flags/") + key + QLatin1String(".svg")}; + m_flagCache[key] = icon; + return icon; } QColor UIThemeManager::getColor(const QString &id, const QColor &defaultColor) const diff --git a/src/gui/uithememanager.h b/src/gui/uithememanager.h index dca86193b..e2580b78b 100644 --- a/src/gui/uithememanager.h +++ b/src/gui/uithememanager.h @@ -62,6 +62,7 @@ private: static UIThemeManager *m_instance; QHash m_colors; mutable QHash m_iconCache; + mutable QHash m_flagCache; const bool m_useCustomTheme; #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) const bool m_useSystemTheme;