aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-fm')
-rw-r--r--lumina-fm/MainUI.cpp10
-rw-r--r--lumina-fm/lumina-fm.pro2
-rw-r--r--lumina-fm/widgets/DirWidget.cpp28
-rw-r--r--lumina-fm/widgets/DirWidget.h4
4 files changed, 37 insertions, 7 deletions
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp
index 815f9ed2..54b61a30 100644
--- a/lumina-fm/MainUI.cpp
+++ b/lumina-fm/MainUI.cpp
@@ -15,6 +15,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
//for Signal/slot we must register the Typedef of QFileInfoList
qRegisterMetaType<QFileInfoList>("QFileInfoList");
qRegisterMetaType< LFileInfoList >("LFileInfoList");
+ //just to silence/fix some Qt connect warnings in QtConcurrent
+ qRegisterMetaType< QVector<int> >("QVector<int>");
+ qRegisterMetaType< QList<QPersistentModelIndex> >("QList<QPersistentModelIndex>");
+
+
ui->setupUi(this);
if(DEBUG){ qDebug() << "Initilization:"; }
//Be careful about the QSettings setup, it must match the lumina-desktop setup
@@ -106,7 +111,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
}
MainUI::~MainUI(){
+ for(int i=0; i<DWLIST.length(); i++){
+ DWLIST[i]->cleanup();
+ }
workThread->quit();
+ //Also ensure the work thread is stopped
workThread->wait();
}
@@ -556,6 +565,7 @@ void MainUI::tabClosed(int tab){
if(DWLIST.length()<2){ return; }
for(int i=0; i<DWLIST.length(); i++){
if(info == DWLIST[i]->id()){
+ DWLIST[i]->cleanup();
delete DWLIST.takeAt(i);
break;
}
diff --git a/lumina-fm/lumina-fm.pro b/lumina-fm/lumina-fm.pro
index 1c71733e..5dcdf0a3 100644
--- a/lumina-fm/lumina-fm.pro
+++ b/lumina-fm/lumina-fm.pro
@@ -1,6 +1,6 @@
QT += core gui
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets multimedia multimediawidgets network
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets multimedia multimediawidgets network concurrent
TARGET = lumina-fm
diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp
index b154b708..21029fb5 100644
--- a/lumina-fm/widgets/DirWidget.cpp
+++ b/lumina-fm/widgets/DirWidget.cpp
@@ -15,6 +15,7 @@
#include <QInputDialog>
#include <QScrollBar>
#include <QSettings>
+#include <QtConcurrent/QtConcurrentRun>
#include <LuminaOS.h>
#include <LuminaXDG.h>
@@ -74,7 +75,12 @@ DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new U
}
DirWidget::~DirWidget(){
-
+ stopload = true; //just in case another thread is still loading/running
+}
+
+void DirWidget::cleanup(){
+ stopload = true; //just in case another thread is still loading/running
+ if(thumbThread.isRunning()){ thumbThread.waitForFinished(); } //this will stop really quickly with the flag set
}
void DirWidget::ChangeDir(QString dirpath){
@@ -473,7 +479,7 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){
if(!canmodify){ stats.prepend(tr("(Limited Access) ")); }
ui->label_status->setText( stats.simplified() );
if(DEBUG){ qDebug() << "DONE:" << time.elapsed(); }
- if(showThumbs){ QTimer::singleShot(0,this, SLOT(startLoadThumbs())); }
+ if(showThumbs){ thumbThread = QtConcurrent::run(this, &DirWidget::startLoadThumbs); }
}
void DirWidget::LoadSnaps(QString basedir, QStringList snaps){
@@ -603,22 +609,24 @@ void DirWidget::startLoadThumbs(){
if(DEBUG){ qDebug() << "Start Loading Thumbnails:" << needThumbs; }
if(needThumbs.isEmpty()){ return; }
needThumbs.removeDuplicates(); //just in case
- QTime updatetime = QTime::currentTime().addMSecs(500);
+ //QTime updatetime = QTime::currentTime().addMSecs(500);
for(int i=0; i<needThumbs.length() && !stopload; i++){
if(showDetails){
//Use the tree widget
QList<QTreeWidgetItem*> items = treeWidget->findItems(needThumbs[i], Qt::MatchExactly);
if(items.isEmpty()){ continue; } //invalid item for some reason
+ if(stopload){ return; } //stop right now
QTreeWidgetItem *it = items.first();
it->setIcon(0, QIcon( QPixmap(it->whatsThis(0).section("::::",1,100)).scaled(listWidget->iconSize(),Qt::IgnoreAspectRatio, Qt::FastTransformation) ) );
}else{
//Use the list widget
QList<QListWidgetItem*> items = listWidget->findItems(needThumbs[i], Qt::MatchExactly);
if(items.isEmpty()){ continue; }
+ if(stopload){ return; } //stop right now
QListWidgetItem *it = items.first();
it->setIcon(QIcon( QPixmap(it->whatsThis().section("::::",1,100)).scaled(listWidget->iconSize(),Qt::IgnoreAspectRatio, Qt::FastTransformation) ) );
}
- if(QTime::currentTime() > updatetime){ QApplication::processEvents(); updatetime = QTime::currentTime().addMSecs(500); }//keep the UI snappy while loading a directory
+ //if(QTime::currentTime() > updatetime){ QApplication::processEvents(); updatetime = QTime::currentTime().addMSecs(500); }//keep the UI snappy while loading a directory
}
}
@@ -780,8 +788,8 @@ void DirWidget::on_slider_snap_valueChanged(int val){
ui->tool_snap_older->setEnabled(val > ui->slider_snap->minimum());
if(val >= snapshots.length() || val < 0){
ui->label_snap->setText(tr("Current"));
- }else{
- ui->label_snap->setText( QFileInfo(snapbasedir+snapshots[val]).created().toString(Qt::DefaultLocaleShortDate) );
+ }else if(QFile::exists(snapbasedir+snapshots[val])){
+ ui->label_snap->setText( QFileInfo(snapbasedir+snapshots[val]).lastModified().toString(Qt::DefaultLocaleShortDate) );
}
//Exit if a non-interactive snapshot change
if(!ui->group_snaps->isEnabled()){ return; } //internal change - do not try to change the actual info
@@ -794,6 +802,14 @@ void DirWidget::on_slider_snap_valueChanged(int val){
dir = normalbasedir;
}else{
dir = snapbasedir+snapshots[val]+"/";
+ if(!QFile::exists(dir)){
+ //This snapshot must have been removed in the background by pruning tools
+ // move to a newer snapshot or the current base dir as necessary
+ qDebug() << "Snapshot no longer available:" << dir;
+ qDebug() << " - Reloading available snapshots";
+ emit findSnaps(ID, normalbasedir);
+ return;
+ }
if(snaprelpath.isEmpty()){
//Need to figure out the relative path within the snapshot
snaprelpath = normalbasedir.section(snapbasedir.section(ZSNAPDIR,0,0), 1,1000);
diff --git a/lumina-fm/widgets/DirWidget.h b/lumina-fm/widgets/DirWidget.h
index f26002af..274873e2 100644
--- a/lumina-fm/widgets/DirWidget.h
+++ b/lumina-fm/widgets/DirWidget.h
@@ -16,6 +16,7 @@
#include <QShortcut>
#include <QFileSystemWatcher>
#include <QTimer>
+#include <QFuture>
#include "../DirData.h"
#include "DDListWidgets.h"
@@ -33,6 +34,8 @@ public:
DirWidget(QString objID, QWidget *parent = 0); //needs a unique ID (to distinguish from other DirWidgets)
~DirWidget();
+ void cleanup(); //called before the browser is closed down
+
//Directory Managment
void ChangeDir(QString dirpath);
void setDirCompleter(QCompleter *comp);
@@ -77,6 +80,7 @@ private:
bool showDetails, showThumbs, canmodify, stopload; //which widget to use for showing items
QList<DETAILTYPES> listDetails;
QMenu *contextMenu;
+ QFuture<void> thumbThread;
//The Toolbar and associated items
QToolBar *toolbar;
QLineEdit *line_dir;
bgstack15