diff options
author | Ken Moore <ken@ixsystems.com> | 2017-08-03 13:36:21 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-08-03 14:04:05 -0400 |
commit | 767e04875146b081f0956805fd7d2932304441d0 (patch) | |
tree | 534e301285bd918788f5ccae99eb618353f63038 /src-qt5/core/libLumina/LIconCache.cpp | |
parent | Fix up a bit more of the lumina-theme-engine (diff) | |
download | lumina-767e04875146b081f0956805fd7d2932304441d0.tar.gz lumina-767e04875146b081f0956805fd7d2932304441d0.tar.bz2 lumina-767e04875146b081f0956805fd7d2932304441d0.zip |
Get the icon loading routines all switched over to the old QIcon::fromTheme() routine now that we have a theme engine available out-of-box.
Diffstat (limited to 'src-qt5/core/libLumina/LIconCache.cpp')
-rw-r--r-- | src-qt5/core/libLumina/LIconCache.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src-qt5/core/libLumina/LIconCache.cpp b/src-qt5/core/libLumina/LIconCache.cpp index 38367cef..9d122df7 100644 --- a/src-qt5/core/libLumina/LIconCache.cpp +++ b/src-qt5/core/libLumina/LIconCache.cpp @@ -80,7 +80,7 @@ QString LIconCache::findFile(QString icon){ fall << getChildIconDirs(paths[i]+"hicolor"); //XDG fallback (apps add to this) } //Now load all the icon theme dependencies in order (Theme1 -> Theme2 -> Theme3 -> Fallback) - + //fall << LOS::AppPrefix()+"share/pixmaps"; //always use this as well as a final fallback QDir::setSearchPaths("icontheme", theme); QDir::setSearchPaths("default", oxy); @@ -121,6 +121,10 @@ QString LIconCache::findFile(QString icon){ void LIconCache::loadIcon(QAbstractButton *button, QString icon, bool noThumb){ if(icon.isEmpty()){ return; } + if(isThemeIcon(icon)){ + button->setIcon( iconFromTheme(icon)); + return ; + } //See if the icon has already been loaded into the HASH bool needload = !HASH.contains(icon); if(!needload){ @@ -138,6 +142,10 @@ void LIconCache::loadIcon(QAbstractButton *button, QString icon, bool noThumb){ void LIconCache::loadIcon(QAction *action, QString icon, bool noThumb){ if(icon.isEmpty()){ return; } + if(isThemeIcon(icon)){ + action->setIcon( iconFromTheme(icon)); + return ; + } //See if the icon has already been loaded into the HASH bool needload = !HASH.contains(icon); if(!needload){ @@ -155,6 +163,10 @@ void LIconCache::loadIcon(QAction *action, QString icon, bool noThumb){ void LIconCache::loadIcon(QLabel *label, QString icon, bool noThumb){ if(icon.isEmpty()){ return; } + if(isThemeIcon(icon)){ + label->setPixmap( iconFromTheme(icon).pixmap(label->sizeHint()) ); + return ; + } //See if the icon has already been loaded into the HASH bool needload = !HASH.contains(icon); if(!needload){ @@ -164,7 +176,7 @@ void LIconCache::loadIcon(QLabel *label, QString icon, bool noThumb){ //Need to load the icon icon_data idata; if(HASH.contains(icon)){ idata = HASH.value(icon); } - else { idata = createData(icon); + else { idata = createData(icon); if(idata.fullpath.isEmpty()){ return; } //nothing to do } idata.pendingLabels << QPointer<QLabel>(label); //save this QLabel for later @@ -183,6 +195,8 @@ void LIconCache::clearIconTheme(){ QIcon LIconCache::loadIcon(QString icon, bool noThumb){ if(icon.isEmpty()){ return QIcon(); } + if(isThemeIcon(icon)){ return iconFromTheme(icon); } + if(HASH.contains(icon)){ if(!HASH[icon].icon.isNull()){ return HASH[icon].icon; } else if(!HASH[icon].thumbnail.isNull() && !noThumb){ return HASH[icon].thumbnail; } @@ -290,6 +304,14 @@ void LIconCache::ReadFile(LIconCache *obj, QString id, QString path){ obj->emit InternalIconLoaded(id, cdt, BA); } +bool LIconCache::isThemeIcon(QString id){ + return (!id.contains("/") && !id.contains(".") ); +} + +QIcon LIconCache::iconFromTheme(QString id){ + return QIcon::fromTheme(id); +} + // === PRIVATE SLOTS === void LIconCache::IconLoaded(QString id, QDateTime sync, QByteArray *data){ //qDebug() << "Icon Loaded:" << id << HASH.contains(id); |