aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-01-17 11:15:40 -0500
committerKen Moore <ken@ixsystems.com>2017-01-17 11:15:40 -0500
commita3f14039845273c799ca7d2a8888cf7c36b5cac6 (patch)
treecac04604e86b03aa5e968356c630d62c2bc1c2de /src-qt5/desktop-utils/lumina-fm
parentGet rid of a random context menu when right-clicking on the menu bar (diff)
downloadlumina-a3f14039845273c799ca7d2a8888cf7c36b5cac6.tar.gz
lumina-a3f14039845273c799ca7d2a8888cf7c36b5cac6.tar.bz2
lumina-a3f14039845273c799ca7d2a8888cf7c36b5cac6.zip
Add an internal icon cache for the standardized mimetype icons. This seems to speed up the loading of individual items quite a bit (something in Qt is not re-using previously loaded QIcons any more?)
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp18
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.h3
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
bgstack15