From 32b3ed0a1362a4b0798ad71fac3450fb77cb7e41 Mon Sep 17 00:00:00 2001 From: Thomas Groman Date: Thu, 19 Sep 2019 00:41:48 -0700 Subject: merged from 0.6.7 codebase --- libraries/iconfix/xdgicon.cpp | 108 +++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 54 deletions(-) (limited to 'libraries/iconfix/xdgicon.cpp') 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; } -- cgit v1.2.3