Browse Source

Merge pull request #12891 from jagannatharjun/cache-icons

Cache flag icons
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
6b6d2cab5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/gui/uithememanager.cpp
  2. 1
      src/gui/uithememanager.h

10
src/gui/uithememanager.cpp

@ -140,7 +140,15 @@ QIcon UIThemeManager::getIcon(const QString &iconId, const QString &fallback) co @@ -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

1
src/gui/uithememanager.h

@ -62,6 +62,7 @@ private: @@ -62,6 +62,7 @@ private:
static UIThemeManager *m_instance;
QHash<QString, QColor> m_colors;
mutable QHash<QString, QIcon> m_iconCache;
mutable QHash<QString, QIcon> m_flagCache;
const bool m_useCustomTheme;
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
const bool m_useSystemTheme;

Loading…
Cancel
Save