From 3cf07e54a83516ed23e93ba4afef262391c2d4bf Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 14 Mar 2019 08:12:05 -0400 Subject: A couple quick changes to lumina-fm: 1. Fix up the loading of new/renamed files in a directory on-demand. 2. Ensure that we only keep a small thumbnail in memory instead of the full image. --- src-qt5/desktop-utils/lumina-fm/Browser.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp index 4a3c8fef..02f1fc89 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp +++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp @@ -62,7 +62,11 @@ bool Browser::showingThumbnails(){ // PRIVATE void Browser::loadItem(const QString info, Browser *obj){ //qDebug() << "Load Thumbnail in separate thread:" << info; - const QImage pix(info); + QImage pix(info); + //Make sure we only keep a small version in memory - not the full thing + if(pix.width() > 256 || pix.height() > 256 ){ + pix = pix.scaled(256,256, Qt::KeepAspectRatio, Qt::FastTransformation); + } obj->emit threadDone(info, pix); //qDebug() << " - Done:" << info; /* QImage* pix = new QImage(); @@ -96,15 +100,23 @@ void Browser::fileChanged(QString file){ //qDebug() << "Got File Changed:" << file; if(file.section("/",0,-2) == currentDir){ if(QFile::exists(file) ){ + //qDebug() << "File exists:" << file; updateList << file; if(!updateTimer->isActive()){ updateTimer->start(); } //QtConcurrent::run(this, &Browser::loadItem, file, this); //file modified but not removed }else if(oldFiles.contains(file) ){ + //qDebug() << "OldFile removed: " << file; oldFiles.removeAll(file); emit itemRemoved(file); + updateList << currentDir; + if(!updateTimer->isActive()){ updateTimer->start(); } + }else{ + //qDebug() << "File does not exist:" << file; + updateList << currentDir; + if(!updateTimer->isActive()){ updateTimer->start(); } } - }//else if(file==currentDir){ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); } + } } void Browser::dirChanged(QString dir){ @@ -147,9 +159,10 @@ void Browser::updateRequested(){ //Clear the cache list ASAP QStringList list = updateList; updateList.clear(); + //qDebug() << "Got Update List:" << list; list.removeDuplicates(); //Now look to see if an all-dir update is needed - if(list.contains(currentDir)){ QTimer::singleShot(10, this, SLOT(loadDirectory()) ); } + if(list.contains(currentDir) || list.isEmpty()){ QTimer::singleShot(10, this, SLOT(loadDirectory()) ); } else{ //individual file updates for(int i=0; i