summaryrefslogtreecommitdiffstats
path: root/libraries/iconfix/xdgicon.cpp
diff options
context:
space:
mode:
authorThomas Groman <tgroman@nuegia.net>2019-09-19 00:41:48 -0700
committerThomas Groman <tgroman@nuegia.net>2019-09-19 00:41:48 -0700
commit32b3ed0a1362a4b0798ad71fac3450fb77cb7e41 (patch)
tree7be7a2f602e6a5af7bc2db86bef9cf2a659c3d3d /libraries/iconfix/xdgicon.cpp
parent5fb2c6334e7d5237db11695b4c0ec0f2d1e47c88 (diff)
downloadMultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.tar
MultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.tar.gz
MultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.tar.lz
MultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.tar.xz
MultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.zip
merged from 0.6.7 codebase
Diffstat (limited to 'libraries/iconfix/xdgicon.cpp')
-rw-r--r--libraries/iconfix/xdgicon.cpp108
1 files changed, 54 insertions, 54 deletions
diff --git a/libraries/iconfix/xdgicon.cpp b/libraries/iconfix/xdgicon.cpp
index a36d80a9..36fb7d42 100644
--- a/libraries/iconfix/xdgicon.cpp
+++ b/libraries/iconfix/xdgicon.cpp
@@ -46,17 +46,17 @@ namespace
{
struct QtIconCache : public IconCache
{
- QtIconCache()
- {
- qAddPostRoutine(qt_cleanup_icon_cache);
- }
+ QtIconCache()
+ {
+ qAddPostRoutine(qt_cleanup_icon_cache);
+ }
};
}
-Q_GLOBAL_STATIC(IconCache, qtIconCache);
+Q_GLOBAL_STATIC(IconCache, qtIconCache)
static void qt_cleanup_icon_cache()
{
- qtIconCache()->clear();
+ qtIconCache()->clear();
}
/************************************************
@@ -78,7 +78,7 @@ XdgIcon::~XdgIcon()
************************************************/
QString XdgIcon::themeName()
{
- return QIcon::themeName();
+ return QIcon::themeName();
}
/************************************************
@@ -86,8 +86,8 @@ QString XdgIcon::themeName()
************************************************/
void XdgIcon::setThemeName(const QString &themeName)
{
- QIcon::setThemeName(themeName);
- QtXdg::QIconLoader::instance()->updateSystemTheme();
+ QIcon::setThemeName(themeName);
+ QtXdg::QIconLoader::instance()->updateSystemTheme();
}
/************************************************
@@ -96,43 +96,43 @@ void XdgIcon::setThemeName(const QString &themeName)
************************************************/
QIcon XdgIcon::fromTheme(const QString &iconName, const QIcon &fallback)
{
- if (iconName.isEmpty())
- return fallback;
-
- bool isAbsolute = (iconName[0] == '/');
-
- QString name = QFileInfo(iconName).fileName();
- if (name.endsWith(".png", Qt::CaseInsensitive) ||
- name.endsWith(".svg", Qt::CaseInsensitive) ||
- name.endsWith(".xpm", Qt::CaseInsensitive))
- {
- name.truncate(name.length() - 4);
- }
-
- QIcon icon;
-
- if (qtIconCache()->contains(name))
- {
- icon = *qtIconCache()->object(name);
- }
- else
- {
- QIcon *cachedIcon;
- if (!isAbsolute)
- cachedIcon = new QIcon(new QtXdg::QIconLoaderEngineFixed(name));
- else
- cachedIcon = new QIcon(iconName);
- qtIconCache()->insert(name, cachedIcon);
- icon = *cachedIcon;
- }
-
- // Note the qapp check is to allow lazy loading of static icons
- // Supporting fallbacks will not work for this case.
- if (qApp && !isAbsolute && icon.availableSizes().isEmpty())
- {
- return fallback;
- }
- return icon;
+ if (iconName.isEmpty())
+ return fallback;
+
+ bool isAbsolute = (iconName[0] == '/');
+
+ QString name = QFileInfo(iconName).fileName();
+ if (name.endsWith(".png", Qt::CaseInsensitive) ||
+ name.endsWith(".svg", Qt::CaseInsensitive) ||
+ name.endsWith(".xpm", Qt::CaseInsensitive))
+ {
+ name.truncate(name.length() - 4);
+ }
+
+ QIcon icon;
+
+ if (qtIconCache()->contains(name))
+ {
+ icon = *qtIconCache()->object(name);
+ }
+ else
+ {
+ QIcon *cachedIcon;
+ if (!isAbsolute)
+ cachedIcon = new QIcon(new QtXdg::QIconLoaderEngineFixed(name));
+ else
+ cachedIcon = new QIcon(iconName);
+ qtIconCache()->insert(name, cachedIcon);
+ icon = *cachedIcon;
+ }
+
+ // Note the qapp check is to allow lazy loading of static icons
+ // Supporting fallbacks will not work for this case.
+ if (qApp && !isAbsolute && icon.availableSizes().isEmpty())
+ {
+ return fallback;
+ }
+ return icon;
}
/************************************************
@@ -141,12 +141,12 @@ QIcon XdgIcon::fromTheme(const QString &iconName, const QIcon &fallback)
************************************************/
QIcon XdgIcon::fromTheme(const QStringList &iconNames, const QIcon &fallback)
{
- foreach (QString iconName, iconNames)
- {
- QIcon icon = fromTheme(iconName);
- if (!icon.isNull())
- return icon;
- }
-
- return fallback;
+ foreach (QString iconName, iconNames)
+ {
+ QIcon icon = fromTheme(iconName);
+ if (!icon.isNull())
+ return icon;
+ }
+
+ return fallback;
}