diff options
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.cpp | 18 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp index 9aeb70ac..d3e1b453 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp +++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp @@ -56,14 +56,20 @@ void Browser::loadItem(QString info){ if(pix.height()>128){ pix = pix.scaled(128, 128, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); } item.icon.addPixmap(pix); }*/ - }/*else if(item.info.isDir()){ - item.icon = LXDG::findIcon("folder","inode/directory"); } - if(item.icon.isNull()){ item.icon = LXDG::findIcon(item.info.mimetype(), "unknown"); }*/ //qDebug() << " - done with item:" << info; this->emit threadDone(info, bytes); } +QIcon Browser::loadIcon(QString icon){ + if(!mimeIcons.contains(icon)){ + mimeIcons.insert(icon, LXDG::findIcon(icon, "unknown")); + } + + return mimeIcons[icon]; +} + + // PRIVATE SLOTS void Browser::fileChanged(QString file){ if(file.startsWith(currentDir+"/") ){ @@ -85,11 +91,13 @@ void Browser::futureFinished(QString name, QByteArray icon){ QPixmap pix; if(pix.loadFromData(icon) ){ ico.addPixmap(pix); } }else if(info.isDir()){ - ico = LXDG::findIcon("folder","inode/directory"); + ico = loadIcon("folder"); + //LXDG::findIcon("folder","inode/directory"); } if(ico.isNull()){ //qDebug() << "MimeType:" << info.fileName() << info.mimetype(); - ico = LXDG::findIcon( info.iconfile(), "unknown" ); + ico = loadIcon(info.iconfile()); + //ico = LXDG::findIcon( info.iconfile(), "unknown" ); } this->emit itemDataAvailable( ico, info ); } diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h index 7b180da9..c4641277 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.h +++ b/src-qt5/desktop-utils/lumina-fm/Browser.h @@ -42,8 +42,11 @@ private: QFileSystemWatcher *watcher; bool showHidden; QStringList imageFormats, oldFiles; + QHash<QString, QIcon> mimeIcons; //cache for quickly re-using QIcons + void loadItem(QString info); //this is the main loader class - multiple instances each run in a separate thread + QIcon loadIcon(QString icon); //simplification for using/populating the mimIcons cache private slots: void fileChanged(QString); //tied into the watcher - for file change notifications |