mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Cache flag icons
This commit is contained in:
parent
68d4dc34db
commit
bcf11cf1e8
@ -140,7 +140,15 @@ QIcon UIThemeManager::getIcon(const QString &iconId, const QString &fallback) co
|
|||||||
QIcon UIThemeManager::getFlagIcon(const QString &countryIsoCode) const
|
QIcon UIThemeManager::getFlagIcon(const QString &countryIsoCode) const
|
||||||
{
|
{
|
||||||
if (countryIsoCode.isEmpty()) return {};
|
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
|
QColor UIThemeManager::getColor(const QString &id, const QColor &defaultColor) const
|
||||||
|
@ -62,6 +62,7 @@ private:
|
|||||||
static UIThemeManager *m_instance;
|
static UIThemeManager *m_instance;
|
||||||
QHash<QString, QColor> m_colors;
|
QHash<QString, QColor> m_colors;
|
||||||
mutable QHash<QString, QIcon> m_iconCache;
|
mutable QHash<QString, QIcon> m_iconCache;
|
||||||
|
mutable QHash<QString, QIcon> m_flagCache;
|
||||||
const bool m_useCustomTheme;
|
const bool m_useCustomTheme;
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
|
||||||
const bool m_useSystemTheme;
|
const bool m_useSystemTheme;
|
||||||
|
Loading…
Reference in New Issue
Block a user