From 838477d0b6bca5327082095711b59eb533affa52 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 14 Oct 2015 14:01:12 -0400 Subject: Clean up some more of lumina-fm: 1) Put the status label on a line below all the buttons (they get crushed together with multiple columns) 2) Fix the time-based event processing when loading a directory (1/2 second updates now) 3) Update the drag/drop indicator items based on the directory underneath. 4) Fix the F5 keyboard shortcut to refresh a directory. --- lumina-fm/MainUI.cpp | 8 +++ lumina-fm/MainUI.h | 3 +- lumina-fm/widgets/DDListWidgets.h | 12 +++- lumina-fm/widgets/DirWidget.cpp | 25 +++---- lumina-fm/widgets/DirWidget.h | 2 +- lumina-fm/widgets/DirWidget.ui | 147 +++++++++++++++++++++----------------- 6 files changed, 114 insertions(+), 83 deletions(-) diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index dfd3e2c9..1305e12d 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -85,6 +85,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ nextTabLShort = new QShortcut( QKeySequence(tr("Shift+Left")), this); nextTabRShort = new QShortcut( QKeySequence(tr("Shift+Right")), this); closeTabShort = new QShortcut( QKeySequence(tr("Ctrl+W")), this); + refreshShort = new QShortcut( QKeySequence(tr("F5")), this); //Finish loading the interface workThread->start(); @@ -215,6 +216,8 @@ void MainUI::setupConnections(){ connect(nextTabLShort, SIGNAL(activated()), this, SLOT( prevTab() ) ); connect(nextTabRShort, SIGNAL(activated()), this, SLOT( nextTab() ) ); connect(closeTabShort, SIGNAL(activated()), this, SLOT( tabClosed() ) ); + connect(refreshShort , SIGNAL(activated()), this, SLOT( refreshTabs() ) ); + } @@ -571,6 +574,11 @@ void MainUI::nextTab(){ else{ tabBar->setCurrentIndex( cur+1 ); } } +void MainUI::refreshTabs(){ + DirWidget *cur = FindActiveBrowser(); + if(cur!=0){ cur->refresh(); } +} + void MainUI::DirDataAvailable(QString id, QString dir, LFileInfoList list){ for(int i=0; iid()){ diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index 0a68334a..f4dda453 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -88,7 +88,7 @@ private: SlideshowWidget *SW; QSettings *settings; - QShortcut *nextTabLShort, *nextTabRShort, *closeTabShort; + QShortcut *nextTabLShort, *nextTabRShort, *closeTabShort, *refreshShort; QCompleter *dirCompleter; //Simplification Functions @@ -129,6 +129,7 @@ private slots: void tabClosed(int tab = -1); void nextTab(); //For keyboard shortcuts void prevTab(); //For keyboard shortcuts + void refreshTabs(); //For keyboard shortcut //Backend Info passing void DirDataAvailable(QString, QString, LFileInfoList); diff --git a/lumina-fm/widgets/DDListWidgets.h b/lumina-fm/widgets/DDListWidgets.h index c2601335..2c51e8cc 100644 --- a/lumina-fm/widgets/DDListWidgets.h +++ b/lumina-fm/widgets/DDListWidgets.h @@ -81,7 +81,11 @@ protected: void dragMoveEvent(QDragMoveEvent *ev){ if(ev->mimeData()->hasUrls() && !this->whatsThis().isEmpty() ){ - ev->acceptProposedAction(); //allow this to be dropped here + //Change the drop type depending on the data/dir + QString home = QDir::homePath(); + if( this->whatsThis().startsWith(home) ){ ev->setDropAction(Qt::MoveAction); } + else{ ev->setDropAction(Qt::CopyAction); } + ev->accept(); //allow this to be dropped here }else{ ev->ignore(); } @@ -184,7 +188,11 @@ protected: void dragMoveEvent(QDragMoveEvent *ev){ if(ev->mimeData()->hasUrls() && !this->whatsThis().isEmpty() ){ - ev->acceptProposedAction(); //allow this to be dropped here + //Change the drop type depending on the data/dir + QString home = QDir::homePath(); + if( this->whatsThis().startsWith(home) ){ ev->setDropAction(Qt::MoveAction); } + else{ ev->setDropAction(Qt::CopyAction); } + ev->accept(); //allow this to be dropped here }else{ ev->ignore(); } diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp index 8f4ed9f1..2cef549f 100644 --- a/lumina-fm/widgets/DirWidget.cpp +++ b/lumina-fm/widgets/DirWidget.cpp @@ -23,7 +23,7 @@ #include "../ScrollDialog.h" #ifndef DEBUG -#define DEBUG 0 +#define DEBUG 1 #endif @@ -59,11 +59,10 @@ DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new U pasteFilesShort = new QShortcut( QKeySequence(tr("Ctrl+V")), this); cutFilesShort = new QShortcut( QKeySequence(tr("Ctrl+X")), this); deleteFilesShort = new QShortcut( QKeySequence(tr("Delete")), this); - refreshShort = new QShortcut( QKeySequence(tr("F5")), this); //Create the filesystem watcher watcher = new QFileSystemWatcher(this); synctimer = new QTimer(this); - synctimer->setInterval(1000); // 1 second pause (combine simultaneous signals from the watcher) + synctimer->setInterval(300); // 300 millisecond pause (combine simultaneous signals from the watcher) synctimer->setSingleShot(true); //Now update the rest of the UI canmodify = false; //initial value @@ -306,10 +305,11 @@ void DirWidget::LoadDir(QString dir, QList list){ int numdirs = 0; qint64 filebytes = 0; //Setup the timer to see when we should process events - QTimer updatetime; + /*QTimer updatetime; updatetime.setInterval(1000); //1 second updates updatetime.setSingleShot(true); - updatetime.start(); + updatetime.start();*/ + QTime updatetime = QTime::currentTime().addMSecs(500); if(DEBUG){ qDebug() << "Start Loop over items:" << time.elapsed(); } for(int i=0; iactionStopLoad->setVisible(false); return; } //stop right now @@ -430,7 +430,7 @@ void DirWidget::LoadDir(QString dir, QList list){ listWidget->scrollToItem(it); } } - if(!updatetime.isActive()){ QApplication::processEvents(); updatetime.start(); }//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 if(DEBUG){ qDebug() << " - item finished:" << i << time.elapsed(); } } tmpSel.clear(); @@ -572,7 +572,7 @@ void DirWidget::setupConnections(){ connect(cutFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_cut_clicked() ) ); connect(pasteFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_paste_clicked() ) ); 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(startSync(const QString &)) ); connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(startSync(const QString &)) ); //just in case @@ -603,10 +603,7 @@ void DirWidget::startLoadThumbs(){ //This just runs through the dir and loads all the thumbnails as needed if(needThumbs.isEmpty()){ return; } needThumbs.removeDuplicates(); //just in case - QTimer updatetime; - updatetime.setInterval(1000); //1 second updates - updatetime.setSingleShot(true); - updatetime.start(); + QTime updatetime = QTime::currentTime().addMSecs(500); for(int i=0; ifindItems(needThumbs[i], Qt::MatchExactly).first(); it->setIcon(QIcon( QPixmap(it->whatsThis().section("::::",1,100)).scaled(listWidget->iconSize(),Qt::IgnoreAspectRatio, Qt::FastTransformation) ) ); } - if(!updatetime.isActive()){ QApplication::processEvents(); updatetime.start(); } //it has been a second - process events + if(QTime::currentTime() > updatetime){ QApplication::processEvents(); updatetime = QTime::currentTime().addMSecs(500); }//keep the UI snappy while loading a directory } } @@ -953,10 +950,10 @@ void DirWidget::startSync(const QString &file){ //Update date_format based on user settings if(file == sessionsettings_config_file){ setDateFormat(); } else if(file == snapbasedir){ emit findSnaps(ID, normalbasedir); } //snapshot list changed - else if(file == normalbasedir){ + /*else if(file == normalbasedir){ if(synctimer->isActive()){ synctimer->stop(); } //already starting a sync emit LoadDirectory(ID, normalbasedir); //Directory changed (new/removed files) - }else{ + }*/else{ //Some file in the directory got changed - start the time for a dir reload // -- This prevents a directory from refreshing constantly if a file within the directory is changing all the time (such as a log file) if(!synctimer->isActive()){ synctimer->start(); } diff --git a/lumina-fm/widgets/DirWidget.h b/lumina-fm/widgets/DirWidget.h index d9573150..799251f4 100644 --- a/lumina-fm/widgets/DirWidget.h +++ b/lumina-fm/widgets/DirWidget.h @@ -90,7 +90,7 @@ private: DDTreeWidget *treeWidget; //Keyboard Shortcuts - QShortcut *copyFilesShort, *cutFilesShort, *pasteFilesShort, *deleteFilesShort, *refreshShort; + QShortcut *copyFilesShort, *cutFilesShort, *pasteFilesShort, *deleteFilesShort; //Watcher to determine when the dir changes QFileSystemWatcher *watcher; QTimer *synctimer; diff --git a/lumina-fm/widgets/DirWidget.ui b/lumina-fm/widgets/DirWidget.ui index 68eb3274..1825cd0d 100644 --- a/lumina-fm/widgets/DirWidget.ui +++ b/lumina-fm/widgets/DirWidget.ui @@ -36,7 +36,88 @@ - + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Create a new file + + + New File + + + Qt::ToolButtonTextBesideIcon + + + + + + + Create a new directory + + + New Dir + + + Qt::ToolButtonTextBesideIcon + + + + + + + Add selected images to slideshow + + + Slideshow + + + + 20 + 20 + + + + Qt::ToolButtonTextBesideIcon + + + + + + + Enqueue selection in multimedia player + + + Play + + + + 20 + 20 + + + + Qt::ToolButtonTextBesideIcon + + + + + @@ -47,70 +128,6 @@ - - - - Create a new directory - - - New Dir - - - Qt::ToolButtonTextBesideIcon - - - - - - - Create a new file - - - New File - - - Qt::ToolButtonTextBesideIcon - - - - - - - Add selected images to slideshow - - - Slideshow - - - - 20 - 20 - - - - Qt::ToolButtonTextBesideIcon - - - - - - - Enqueue selection in multimedia player - - - Play - - - - 20 - 20 - - - - Qt::ToolButtonTextBesideIcon - - - -- cgit