From dc0cde517da67c6f41b5e56e72035d4df2293d08 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 26 May 2017 08:20:49 -0400 Subject: Oops - forgot to include the changes to the LIconCache files in that last commit. --- src-qt5/core/libLumina/LIconCache.cpp | 53 ++++++++++++++++++----------------- src-qt5/core/libLumina/LIconCache.h | 5 +++- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src-qt5/core/libLumina/LIconCache.cpp b/src-qt5/core/libLumina/LIconCache.cpp index 18fc48c1..3ce17439 100644 --- a/src-qt5/core/libLumina/LIconCache.cpp +++ b/src-qt5/core/libLumina/LIconCache.cpp @@ -8,10 +8,12 @@ #include #include +#include #include +#include -LIconCache::LIconCache(QObject *parent = 0{ +LIconCache::LIconCache(QObject *parent) : QObject(parent){ } @@ -23,10 +25,10 @@ LIconCache::~LIconCache(){ // === PUBLIC === //Icon Checks bool LIconCache::exists(QString icon){ - if(HASH.contains(icon){ return true; } //already + if(HASH.contains(icon)){ return true; } //already else if(!icon.startsWith("/")){ //relative path to file (from icon theme?) - QString path = findFile(QString icon); + QString path = findFile(icon); if(!path.isEmpty() && QFile::exists(path)){ return true; } }else{ //absolute path to file @@ -36,7 +38,7 @@ bool LIconCache::exists(QString icon){ } bool LIconCache::isLoaded(QString icon){ - if(HASH.contains(icon){ + if(HASH.contains(icon)){ return !HASH[icon].icon.isNull(); } return false; @@ -62,7 +64,7 @@ QString LIconCache::findFile(QString icon){ } //Now load all the dirs into the search paths QStringList theme, oxy, fall; - QStringList themedeps = getIconThemeDepChain(cTheme, paths); + QStringList themedeps = LXDG::getIconThemeDepChain(cTheme, paths); for(int i=0; isetIcon( HASH[icon].thumbnail ); return; } - else if(!HASH[icon].icon.isNull()){ button->setIcon( HASH[icon].icon ); return; } + if(!noThumb && !HASH[icon].thumbnail.isNull()){ label->setPixmap( HASH[icon].thumbnail.pixmap(label->sizeHint()) ); return; } + else if(!HASH[icon].icon.isNull()){ label->setPixmap( HASH[icon].icon.pixmap(label->sizeHint()) ); return; } } //Need to load the icon icon_data idata; if(HASH.contains(icon)){ idata = HASH.value(icon); } - else { idata = icon_data createData(QString icon); } + else { idata = createData(icon); } idata.pendingLabels << label; //save this QLabel for later HASH.insert(icon, idata); QtConcurrent::run(this, &LIconCache::ReadFile, this, icon, idata.fullpath); @@ -172,15 +174,13 @@ icon_data LIconCache::createData(QString icon){ icon_data idat; //Find the real path of the icon if(icon.startsWith("/")){ idat.fullpath = icon; } //already full path - else{ - idat.fullpath = findFile(icon); - } + else{ idat.fullpath = findFile(icon); } return idat; } QStringList LIconCache::getChildIconDirs(QString path){ //This is a recursive function that returns the absolute path(s) of directories with *.png files - QDir D(parent); + QDir D(path); QStringList out; QStringList dirs = D.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); if(!dirs.isEmpty() && (dirs.contains("32x32") || dirs.contains("scalable")) ){ @@ -205,7 +205,7 @@ QStringList LIconCache::getChildIconDirs(QString path){ return out; } -QStringList LXDG::getIconThemeDepChain(QString theme, QStringList paths){ +QStringList LIconCache::getIconThemeDepChain(QString theme, QStringList paths){ QStringList results; for(int i=0; isetIcon(idat.icon); } idat.pendingButtons.clear(); - for(int i=0; isetPixmap(pix.scaled(idat.pendingLabels[i]->sizeHint(), Qt::KeepAspectRatio, Qt::SmoothTransformation); } + for(int i=0; isetPixmap(pix.scaled(idat.pendingLabels[i]->sizeHint(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); } idat.pendingLabels.clear(); //Now update the hash and let the world know it is available now HASH.insert(id, idat); diff --git a/src-qt5/core/libLumina/LIconCache.h b/src-qt5/core/libLumina/LIconCache.h index e2335c01..d89ddd70 100644 --- a/src-qt5/core/libLumina/LIconCache.h +++ b/src-qt5/core/libLumina/LIconCache.h @@ -14,6 +14,8 @@ #include #include #include +#include +#include //Data structure for saving the icon/information internally struct icon_data{ @@ -50,8 +52,9 @@ private: icon_data createData(QString icon); QStringList getChildIconDirs(QString path); //recursive function to find directories with icons in them + QStringList getIconThemeDepChain(QString theme, QStringList paths); - static void ReadFile(LIconCache *obj, QString id, QString path); + void ReadFile(LIconCache *obj, QString id, QString path); private slots: void IconLoaded(QString id, QDateTime sync, QByteArray *data); -- cgit