aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-fm/widgets')
-rw-r--r--lumina-fm/widgets/DirWidget.cpp15
-rw-r--r--lumina-fm/widgets/DirWidget.h5
2 files changed, 16 insertions, 4 deletions
diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp
index 255bb461..d10028e1 100644
--- a/lumina-fm/widgets/DirWidget.cpp
+++ b/lumina-fm/widgets/DirWidget.cpp
@@ -54,6 +54,9 @@ DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new U
refreshShort = new QShortcut( QKeySequence(tr("F5")), this);
//Create the filesystem watcher
watcher = new QFileSystemWatcher(this);
+ synctimer = new QTimer(this);
+ synctimer->setInterval(100); // 1/10 second pause (combine simultaneous signals from the watcher)
+ synctimer->setSingleShot(true);
//Now update the rest of the UI
canmodify = false; //initial value
contextMenu = new QMenu(this);
@@ -260,7 +263,7 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){
//Update statistics
if(list[i].isDir()){ numdirs++; }
else{ filebytes += list[i].size(); }
- //watcher->addPath(list[i].absoluteFilePath());
+ watcher->addPath(list[i].absoluteFilePath());
if(showDetails){
//Now create all the individual items for the details tree
QTreeWidgetItem *it;
@@ -474,8 +477,9 @@ void DirWidget::setupConnections(){
connect(deleteFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_rm_clicked() ) );
connect(refreshShort, SIGNAL(activated()), this, SLOT( refresh()) );
//Filesystem Watcher
- connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(refresh()) );
- connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(refresh()) ); //just in case
+ connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(startSync()) );
+ connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(startSync()) ); //just in case
+ connect(synctimer, SIGNAL(timeout()), this, SLOT(refresh()) );
}
QStringList DirWidget::currentSelection(){
@@ -820,3 +824,8 @@ void DirWidget::SelectionChanged(){
ui->tool_act_run->setEnabled(hasselection);
ui->tool_act_runwith->setEnabled(hasselection);
}
+
+void DirWidget::startSync(){
+ if(synctimer->isActive()){ synctimer->stop(); }
+ synctimer->start();
+} \ No newline at end of file
diff --git a/lumina-fm/widgets/DirWidget.h b/lumina-fm/widgets/DirWidget.h
index 3e653ab9..55e6f8d1 100644
--- a/lumina-fm/widgets/DirWidget.h
+++ b/lumina-fm/widgets/DirWidget.h
@@ -15,7 +15,7 @@
#include <QLineEdit>
#include <QShortcut>
#include <QFileSystemWatcher>
-
+#include <QTimer>
#include "../DirData.h"
#include "DDListWidgets.h"
@@ -85,6 +85,7 @@ private:
QShortcut *copyFilesShort, *cutFilesShort, *pasteFilesShort, *deleteFilesShort, *refreshShort;
//Watcher to determine when the dir changes
QFileSystemWatcher *watcher;
+ QTimer *synctimer;
//Functions for internal use
void setupConnections();
@@ -124,10 +125,12 @@ private slots:
void openTerminal();
void NewFile();
void NewDir();
+
//Browser Functions
void OpenContextMenu();
void SelectionChanged();
+ void startSync(); //used internally to collect/pause before updating the dir
signals:
//Directory loading/finding signals
bgstack15