diff options
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.cpp | 43 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 11 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp | 195 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.h | 82 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/DirData.h | 35 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/MainUI.cpp | 176 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/MainUI.h | 21 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/MainUI.ui | 29 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/lumina-fm.pro | 6 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h | 41 |
10 files changed, 397 insertions, 242 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp index 8c9b27c3..7455e5ea 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp +++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp @@ -67,25 +67,17 @@ void Browser::loadItem(QString info){ // PRIVATE SLOTS void Browser::fileChanged(QString file){ - if(file.startsWith(currentDir+"/")){ emit itemUpdated(file); } + if(file.startsWith(currentDir+"/")){ QtConcurrent::run(this, &Browser::loadItem, file ); } else if(file==currentDir){ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); } } void Browser::dirChanged(QString dir){ if(dir==currentDir){ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); } - else if(dir.startsWith(currentDir)){ emit itemUpdated(dir); } + else if(dir.startsWith(currentDir)){ QtConcurrent::run(this, &Browser::loadItem, dir ); } } void Browser::futureFinished(QString name, QByteArray icon){ //Note: this will be called once for every item that loads - //qDebug() << "Future Finished" << name; - //for(int i=0; i<fwatchers.length(); i++){ - //if(fwatchers[i]->isFinished()){ - //FileItem FI = fwatchers[i]->result(); - //qDebug() << "Found finished:" << FI.name << i; - //disconnect(fwatchers[i]); - //fwatchers.takeAt(i)->deleteLater(); - //fwatchers.removeAt(i); QIcon ico; LFileInfo info(name); if(!icon.isEmpty()){ @@ -94,13 +86,11 @@ void Browser::futureFinished(QString name, QByteArray icon){ }else if(info.isDir()){ ico = LXDG::findIcon("folder","inode/directory"); } - if(ico.isNull()){ ico = LXDG::findIcon( info.mimetype(), "unknown" ); } + if(ico.isNull()){ + //qDebug() << "MimeType:" << info.fileName() << info.mimetype(); + ico = LXDG::findIcon( info.iconfile(), "unknown" ); + } this->emit itemDataAvailable( ico, info ); - //qDebug() << "- done"; - //i--; - //return; - //} - //} } // PUBLIC SLOTS @@ -108,22 +98,41 @@ void Browser::loadDirectory(QString dir){ //qDebug() << "Load Directory" << dir; if(dir.isEmpty()){ dir = currentDir; } //reload current directory if(dir.isEmpty()){ return; } //nothing to do - nothing previously loaded + if(currentDir != dir){ //let the main widget know to clear all current items (completely different dir) + oldFiles.clear(); + emit clearItems(); + } + currentDir = dir; //save this for later //clean up the watcher first QStringList watched; watched << watcher->files() << watcher->directories(); if(!watched.isEmpty()){ watcher->removePaths(watched); } - emit clearItems(); //let the main widget know to clear all current items + QStringList old = oldFiles; //copy this over for the moment (both lists will change in a moment) + oldFiles.clear(); //get ready for re-creating this list // read the given directory QDir directory(dir); if(directory.exists()){ QStringList files; if(showHidden){ files = directory.entryList( QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDir::NoSort); } else{ files = directory.entryList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::NoSort); } + emit itemsLoading(files.length()); + QCoreApplication::processEvents(); for(int i=0; i<files.length(); i++){ watcher->addPath(directory.absoluteFilePath(files[i])); //qDebug() << "Future Starting:" << files[i]; QString path = directory.absoluteFilePath(files[i]); + if(old.contains(path)){ old.removeAll(path); } + oldFiles << path; //add to list for next time QtConcurrent::run(this, &Browser::loadItem, path ); + QCoreApplication::sendPostedEvents(); } watcher->addPath(directory.absolutePath()); + if(!old.isEmpty()){ + old.removeAll(directory.absolutePath()); + for(int i=0; i<old.length(); i++){ + emit itemRemoved(old[i]); + } + } + }else{ + emit itemsLoading(0); //nothing to load } } diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h index 870e9fe1..7b180da9 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.h +++ b/src-qt5/desktop-utils/lumina-fm/Browser.h @@ -13,17 +13,17 @@ #include <QString> #include <QFileSystemWatcher> #include <QIcon> -#include <QFutureWatcher> +//#include <QFutureWatcher> #include <LuminaXDG.h> -class FileItem{ +/*class FileItem{ public: QString name; QByteArray icon; FileItem(){} ~FileItem(){}; -}; +};*/ class Browser : public QObject{ Q_OBJECT @@ -40,9 +40,8 @@ public: private: QString currentDir; QFileSystemWatcher *watcher; - QList< QFutureWatcher<FileItem>* > fwatchers; bool showHidden; - QStringList imageFormats; + QStringList imageFormats, oldFiles; void loadItem(QString info); //this is the main loader class - multiple instances each run in a separate thread @@ -57,7 +56,7 @@ public slots: signals: //Main Signals - void itemUpdated(QString item); //emitted if a file changes after the initial scan + void itemRemoved(QString item); //emitted if a file was removed from the underlying void clearItems(); //emitted when dirs change for example void itemDataAvailable(QIcon, LFileInfo); diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp index bec99667..e007b974 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp @@ -11,22 +11,25 @@ #include <QSettings> #include <LuminaUtils.h> +#include <LuminaOS.h> BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){ //Setup the Widget/UI this->setLayout( new QVBoxLayout(this) ); ID = objID; - //this->setWhatsThis(objID); //Setup the backend browser object BROWSER = new Browser(this); connect(BROWSER, SIGNAL(clearItems()), this, SLOT(clearItems()) ); - connect(BROWSER, SIGNAL(itemUpdated(QString)), this, SLOT(itemUpdated(QString)) ); + connect(BROWSER, SIGNAL(itemRemoved(QString)), this, SLOT(itemRemoved(QString)) ); connect(BROWSER, SIGNAL(itemDataAvailable(QIcon, LFileInfo)), this, SLOT(itemDataAvailable(QIcon, LFileInfo)) ); connect(BROWSER, SIGNAL(itemsLoading(int)), this, SLOT(itemsLoading(int)) ); connect(this, SIGNAL(dirChange(QString)), BROWSER, SLOT(loadDirectory(QString)) ); listWidget = 0; treeWidget = 0; readDateFormat(); + freshload = true; //nothing loaded yet + numItems = 0; + } BrowserWidget::~BrowserWidget(){ @@ -34,37 +37,75 @@ BrowserWidget::~BrowserWidget(){ } void BrowserWidget::changeDirectory(QString dir){ + qDebug() << "Change Directory:" << dir << historyList; if(BROWSER->currentDirectory()==dir){ return; } //already on this directory + + if( !dir.contains("/.zfs/snapshot/") ){ + if(historyList.isEmpty() || !dir.isEmpty()){ historyList << dir; } + }else{ + //Need to remove the zfs snapshot first and ensure that it is not the same dir (just a diff snapshot) + QString cleaned = dir.replace( QRegExp("/\\.zfs/snapshot/(.)+/"), "/" ); + if( (historyList.isEmpty() || historyList.last()!=cleaned) && !cleaned.isEmpty() ){ historyList << cleaned; } + } + qDebug() << "History:" << historyList; emit dirChange(dir); } void BrowserWidget::showDetails(bool show){ //Clean up widgets first + QSize iconsize; if(show && listWidget!=0){ //Clean up list widget + iconsize = listWidget->iconSize(); + this->layout()->removeWidget(listWidget); listWidget->deleteLater(); listWidget = 0; }else if(!show && treeWidget!=0){ + iconsize = treeWidget->iconSize(); + this->layout()->removeWidget(treeWidget); treeWidget->deleteLater(); treeWidget = 0; } + qDebug() << "Create Widget: details:" << show; //Now create any new widgets if(show && treeWidget == 0){ treeWidget = new DDTreeWidget(this); + treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); + if(!iconsize.isNull()){ treeWidget->setIconSize(iconsize); } this->layout()->addWidget(treeWidget); + connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SIGNAL(itemsActivated()) ); + connect(treeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SIGNAL(contextMenuRequested()) ); + connect(treeWidget, SIGNAL(DataDropped(QString, QStringList)), this, SIGNAL(DataDropped(QString, QStringList)) ); + connect(treeWidget, SIGNAL(GotFocus()), this, SLOT(selectionChanged()) ); retranslate(); + treeWidget->sortItems(0, Qt::AscendingOrder); if(!BROWSER->currentDirectory().isEmpty()){ emit dirChange(""); } }else if(!show && listWidget==0){ listWidget = new DDListWidget(this); + listWidget->setContextMenuPolicy(Qt::CustomContextMenu); + if(!iconsize.isNull()){ listWidget->setIconSize(iconsize); } this->layout()->addWidget(listWidget); + connect(listWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SIGNAL(itemsActivated()) ); + connect(listWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SIGNAL(contextMenuRequested()) ); + connect(listWidget, SIGNAL(DataDropped(QString, QStringList)), this, SIGNAL(DataDropped(QString, QStringList)) ); + connect(listWidget, SIGNAL(GotFocus()), this, SLOT(selectionChanged()) ); if(!BROWSER->currentDirectory().isEmpty()){ emit dirChange(""); } } + qDebug() << " Done making widget"; } bool BrowserWidget::hasDetails(){ return (treeWidget!=0); } +void BrowserWidget::showHiddenFiles(bool show){ + BROWSER->showHiddenFiles(show); +} + +bool BrowserWidget::hasHiddenFiles(){ + return BROWSER->showingHiddenFiles(); +} + void BrowserWidget::setThumbnailSize(int px){ bool larger = true; if(listWidget!=0){ @@ -74,12 +115,31 @@ void BrowserWidget::setThumbnailSize(int px){ larger = treeWidget->iconSize().height() < px; treeWidget->setIconSize(QSize(px,px)); } + //qDebug() << "Changing Icon Size:" << px << larger; if(BROWSER->currentDirectory().isEmpty() || !larger ){ return; } //don't need to reload icons unless the new size is larger emit dirChange(""); } -QStringList BrowserWidget::getDateFormat() { - return date_format; +int BrowserWidget::thumbnailSize(){ + if(listWidget!=0){ return listWidget->iconSize().height(); } + else if(treeWidget!=0){ return treeWidget->iconSize().height(); } + return 0; +} + +void BrowserWidget::setHistory(QStringList paths){ + //NOTE: later items are used first + historyList = paths; +} + +QStringList BrowserWidget::history(){ + return historyList; +} + +void BrowserWidget::setShowActive(bool show){ + if(!show){ this->setStyleSheet("QAbstractScrollArea{ background-color: rgba(10,10,10,10); }"); } + else{ + this->setStyleSheet( "QAbstractScrollArea{ background-color: white; }"); + } } // This function is only called if user changes sessionsettings. By doing so, operations like sorting by date @@ -93,6 +153,51 @@ void BrowserWidget::readDateFormat() { date_format << settings.value("TimeFormat").toString(); } + +QStringList BrowserWidget::currentSelection(){ + QStringList out; + if(listWidget!=0){ + QList<QListWidgetItem*> sel = listWidget->selectedItems(); + //qDebug() << "Selection number:" << sel.length(); + //if(sel.isEmpty() && listWidget->currentItem()!=0){ sel << listWidget->currentItem(); } + //qDebug() << "Selection number:" << sel.length(); + for(int i=0; i<sel.length(); i++){ out << sel[i]->whatsThis(); qDebug() << "Selection:" << sel[i]->text() << sel[i]->whatsThis(); } + }else if(treeWidget!=0){ + QList<QTreeWidgetItem*> sel = treeWidget->selectedItems(); + //if(sel.isEmpty() && treeWidget->currentItem()!=0){ sel << treeWidget->currentItem(); } + for(int i=0; i<sel.length(); i++){ out << sel[i]->whatsThis(0); } + } + out.removeDuplicates(); //just in case - tree widgets sometimes "select" each column as an individual item + return out; +} + +QStringList BrowserWidget::currentItems(int type){ + //type: 0=all, -1=files, +1=dirs + QStringList paths; + if(listWidget!=0){ + for(int i=0; i<listWidget->count(); i++){ + if(i<0 && (listWidget->item(i)->data(Qt::UserRole).toString()=="file") ){ //FILES + paths << listWidget->item(i)->whatsThis(); + }else if(i>0 && (listWidget->item(i)->data(Qt::UserRole).toString()=="dir")){ //DIRS + paths << listWidget->item(i)->whatsThis(); + }else if(i==0){ //ALL + paths << listWidget->item(i)->whatsThis(); + } + } + }else if(treeWidget!=0){ + for(int i=0; i<treeWidget->topLevelItemCount(); i++){ + if(i<0 && !treeWidget->topLevelItem(i)->text(1).isEmpty()){ //FILES + paths << treeWidget->topLevelItem(i)->whatsThis(0); + }else if(i>0 && treeWidget->topLevelItem(i)->text(1).isEmpty()){ //DIRS + paths << treeWidget->topLevelItem(i)->whatsThis(0); + }else if(i==0){ //ALL + paths << treeWidget->topLevelItem(i)->whatsThis(0); + } + } + } + return paths; +} + // ================= // PUBLIC SLOTS // ================= @@ -117,7 +222,7 @@ void BrowserWidget::retranslate(){ // PRIVATE // ================= QString BrowserWidget::DTtoString(QDateTime dt){ - QStringList fmt = getDateFormat(); + QStringList fmt = date_format; if(fmt.isEmpty() || fmt.length()!=2 || (fmt[0].isEmpty() && fmt[1].isEmpty()) ){ //Default formatting return dt.toString(Qt::DefaultLocaleShortDate); @@ -137,9 +242,10 @@ QString BrowserWidget::DTtoString(QDateTime dt){ // PRIVATE SLOTS // ================= void BrowserWidget::clearItems(){ + //qDebug() << "Clear Items"; if(listWidget!=0){ listWidget->clear(); } else if(treeWidget!=0){ treeWidget->clear(); } - this->setEnabled(false); + freshload = true; } void BrowserWidget::itemRemoved(QString item){ @@ -156,7 +262,7 @@ void BrowserWidget::itemRemoved(QString item){ } void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){ - qDebug() << "Item Data Available:" << info.fileName(); + //qDebug() << "Item Data Available:" << info.fileName(); int num = 0; if(listWidget!=0){ //LIST WIDGET - name and icon only @@ -168,7 +274,10 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){ it->setIcon(ico); }else{ //New item - listWidget->addItem( new QListWidgetItem(ico, info.fileName(), listWidget) ); + QListWidgetItem *it = new CQListWidgetItem(ico, info.fileName(), listWidget); + it->setWhatsThis(info.absoluteFilePath()); + it->setData(Qt::UserRole, (info.isDir() ? "dir" : "file")); //used for sorting + listWidget->addItem(it); } num = listWidget->count(); }else if(treeWidget!=0){ @@ -180,7 +289,8 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){ treeWidget->addTopLevelItem(it); } //Now set/update all the data - it->setText(1, LUtils::BytesToDisplaySize(info.size()) ); //size (1) + it->setIcon(0, ico); + it->setText(1, info.isDir() ? "" : LUtils::BytesToDisplaySize(info.size()) ); //size (1) it->setText(2, info.mimetype() ); //type (2) it->setText(3, DTtoString(info.lastModified() )); //modification date (3) it->setText(4, DTtoString(info.created()) ); //creation date (4) @@ -194,11 +304,74 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){ //Still loading items //this->setEnabled(false); }else{ + if(freshload && treeWidget!=0){ + //qDebug() << "Resize Tree Widget Contents"; + for(int i=0; i<treeWidget->columnCount(); i++){ treeWidget->resizeColumnToContents(i); } + } + freshload = false; //any further changes are updates - not a fresh load of a dir //Done loading items - this->setEnabled(true); - } + //this->setEnabled(true); + //Assemble any status message + QString stats = QString(tr("Capacity: %1")).arg(LOS::FileSystemCapacity(BROWSER->currentDirectory())); + int nF, nD; + double bytes = 0; + nF = nD = 0; + if(listWidget!=0){ + bytes = -1; //not supported for this widget + for(int i=0; i<listWidget->count(); i++){ + if(listWidget->item(i)->data(Qt::UserRole).toString()=="dir"){ nD++; } //directory + else{ nF++; } //file + } + }else if(treeWidget!=0){ + for(int i=0; i<treeWidget->topLevelItemCount(); i++){ + if(treeWidget->topLevelItem(i)->text(1).isEmpty()){ + nD++; //directory + }else{ + nF++; //file + bytes+=LUtils::DisplaySizeToBytes(treeWidget->topLevelItem(i)->text(1)); + } + } + } + + if( (nF+nD) >0){ + stats.prepend("\t"); + if(nF>0){ + //Has Files + if(bytes>0){ + stats.prepend( QString(tr("Files: %1 (%2)")).arg(QString::number(nF), LUtils::BytesToDisplaySize(bytes)) ); + }else{ + stats.prepend( QString(tr("Files: %1")).arg(QString::number(nF)) ); + } + } + if(nD > 0){ + //Has Dirs + if(nF>0){ stats.prepend(" / "); }//has files output already + stats.prepend( QString(tr("Dirs: %1")).arg(QString::number(nD)) ); + } + } + emit updateDirectoryStatus( stats.simplified() ); + statustip = stats.simplified(); //save for later + }//end check for finished loading items } void BrowserWidget::itemsLoading(int total){ + //qDebug() << "Got number of items loading:" << total; numItems = total; //save this for later + if(total<1){ + emit updateDirectoryStatus( tr("No Directory Contents") ); + this->setEnabled(true); + } +} + +void BrowserWidget::selectionChanged(){ + emit hasFocus(ID); //let the parent know the widget is "active" with the user +} + +void BrowserWidget::resizeEvent(QResizeEvent *ev){ + QWidget::resizeEvent(ev); //do the normal processing first + //The list widget needs to be poked to rearrange the items to fit the new size + // tree widget does this fine at the moment. + if(listWidget!=0){ + listWidget->sortItems(Qt::AscendingOrder); + } } diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h index 84b68b2c..803a036d 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h @@ -10,6 +10,7 @@ #include <QString> #include <QWidget> +#include <QThread> #include "Browser.h" #include "widgets/DDListWidgets.h" @@ -18,9 +19,11 @@ class BrowserWidget : public QWidget{ Q_OBJECT private: Browser *BROWSER; + //QThread *bThread; //browserThread int numItems; //used for checking if all the items have loaded yet - QString ID; - QStringList date_format; + QString ID, statustip; + QStringList date_format, historyList; + bool freshload; //The drag and drop brower widgets DDListWidget *listWidget; @@ -40,12 +43,26 @@ public: void showDetails(bool show); bool hasDetails(); + void showHiddenFiles(bool show); + bool hasHiddenFiles(); + void setThumbnailSize(int px); + int thumbnailSize(); + + void setHistory(QStringList); + QStringList history(); + + void setShowActive(bool show); //used for accenting if the widget is "active" + + QString status(){ return statustip; } //Date format for show items - QStringList getDateFormat(); void readDateFormat(); + //Return all the items which are currently selected + QStringList currentSelection(); + QStringList currentItems(int type = 0); //type: 0=all, -1=files, +1=dirs + public slots: void retranslate(); @@ -55,56 +72,21 @@ private slots: void itemRemoved(QString); void itemDataAvailable(QIcon, LFileInfo); void itemsLoading(int total); + void selectionChanged(); + +protected: + void resizeEvent(QResizeEvent *ev); signals: - //void activated(QString); //current dir path + //External signals + void itemsActivated(); + void updateDirectoryStatus(QString); + void contextMenuRequested(); + void DataDropped(QString, QStringList); + void hasFocus(QString); //ID output + + //Internal signal void dirChange(QString); //current dir path }; - -/* - * Virtual class for managing the sort of folders/files items. The problem with base class is that it only manages texts fields and - * we have dates and sizes. - * - * On this class, we overwrite the function operator<. - */ - -/*class CQTreeWidgetItem : public QTreeWidgetItem { -public: - CQTreeWidgetItem(int type = Type) : QTreeWidgetItem(type) {} - CQTreeWidgetItem(const QStringList & strings, int type = Type) : QTreeWidgetItem(strings, type) {} - CQTreeWidgetItem(QTreeWidget * parent, int type = Type) : QTreeWidgetItem(parent, type) {} - CQTreeWidgetItem(QTreeWidget * parent, const QStringList & strings, int type = Type) : QTreeWidgetItem(parent, strings, type) {} - CQTreeWidgetItem(QTreeWidget * parent, QTreeWidgetItem * preceding, int type = Type) : QTreeWidgetItem(parent, preceding, type) {} - CQTreeWidgetItem(QTreeWidgetItem * parent, int type = Type) : QTreeWidgetItem(parent, type) {} - CQTreeWidgetItem(QTreeWidgetItem * parent, const QStringList & strings, int type = Type) : QTreeWidgetItem(parent, strings, type) {} - CQTreeWidgetItem(QTreeWidgetItem * parent, QTreeWidgetItem * preceding, int type = Type) : QTreeWidgetItem(parent, preceding, type) {} - virtual ~CQTreeWidgetItem() {} - inline virtual bool operator<(const QTreeWidgetItem &tmp) const { - int column = this->treeWidget()->sortColumn(); - // We are in date text - if(column == DirWidget::DATEMOD || column == DirWidget::DATECREATE) - return this->whatsThis(column) < tmp.whatsThis(column); - // We are in size text - else if(column == DirWidget::SIZE) { - QString text = this->text(column); - QString text_tmp = tmp.text(column); - double filesize, filesize_tmp; - // On folders, text is empty so we check for that - // In case we are in folders, we put -1 for differentiate of regular files with 0 bytes. - // Doing so, all folders we'll be together instead of mixing with files with 0 bytes. - if(text.isEmpty()) - filesize = -1; - else - filesize = LUtils::DisplaySizeToBytes(text); - if(text_tmp.isEmpty()) - filesize_tmp = -1; - else - filesize_tmp = LUtils::DisplaySizeToBytes(text_tmp); - return filesize < filesize_tmp; - } - // In other cases, we trust base class implementation - return QTreeWidgetItem::operator<(tmp); - } -};*/ #endif diff --git a/src-qt5/desktop-utils/lumina-fm/DirData.h b/src-qt5/desktop-utils/lumina-fm/DirData.h index c3ace5a4..546dd6c5 100644 --- a/src-qt5/desktop-utils/lumina-fm/DirData.h +++ b/src-qt5/desktop-utils/lumina-fm/DirData.h @@ -32,6 +32,7 @@ public: QString dirpath; //directory this structure was reading QString snapdir; //base snapshot directory (if one was requested/found) bool hashidden; + QStringList mntpoints; //Access Functions LDirInfoList(QString path = ""){ @@ -39,6 +40,11 @@ public: list.clear(); fileNames.clear(); hashidden = false; + //Generate the list of all mountpoints if possible + if(LUtils::isValidBinary("zfs")){ + mntpoints = LUtils::getCmdOutput("zfs list -H -o mountpoint").filter("/"); + mntpoints.removeDuplicates(); + } } ~LDirInfoList(){} @@ -72,23 +78,21 @@ public: } void findSnapDir(){ - //Search the filesystem + //Search the filesystem if(dirpath.contains(ZSNAPDIR)){ snapdir = dirpath.section(ZSNAPDIR,0,0)+ZSNAPDIR; //no need to go looking for it + }else if(mntpoints.isEmpty()){ + snapdir.clear(); //no zfs dirs available }else{ - //Need to backtrack - QDir dir(dirpath); - bool found = false; - while(dir.canonicalPath()!="/" && !found){ - //qDebug() << " -- Checking for snapshot dir:" << dir.canonicalPath(); - if(dir.exists(".zfs/snapshot")){ - snapdir = dir.canonicalPath()+ZSNAPDIR; - found = true; - }else{ - dir.cdUp(); - } - }//end loop - } + //Only check the mountpoint associated with this directory + QString mnt; + for(int i=0; i<mntpoints.length(); i++){ + if(dirpath == mntpoints[i]){ mnt = mntpoints[i]; break; } + else if(dirpath.startsWith(mntpoints[i]) && mntpoints[i].length()>mnt.length()){ mnt = mntpoints[i]; } + } + if(QFile::exists(mnt+ZSNAPDIR)){ snapdir = mnt+ZSNAPDIR; } + else{ snapdir.clear(); } //none found + } } }; @@ -119,6 +123,7 @@ public: public slots: void GetDirData(QString ID, QString dirpath){ + return; if(pauseData){ return; } if(DIR_DEBUG){ qDebug() << "GetDirData:" << ID << dirpath; } //The ID is used when returning the info in a moment @@ -146,7 +151,7 @@ public slots: //Only check if ZFS is flagged as available if(zfsavailable){ //First find if the hash already has an entry for this directory - if(false){ //!HASH.contains(dirpath)){ + if(!HASH.contains(dirpath)){ LDirInfoList info(dirpath); HASH.insert(dirpath,info); } diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.cpp b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp index 59b671b5..bac365e1 100644 --- a/src-qt5/desktop-utils/lumina-fm/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp @@ -15,11 +15,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ //for Signal/slot we must register the Typedef of QFileInfoList - qRegisterMetaType<QFileInfoList>("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>"); + //qRegisterMetaType< QVector<int> >("QVector<int>"); + //qRegisterMetaType< QList<QPersistentModelIndex> >("QList<QPersistentModelIndex>"); ui->setupUi(this); @@ -27,9 +27,6 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ if(DEBUG){ qDebug() << "Initilization:"; } settings = new QSettings( QSettings::UserScope, "lumina-desktop", "lumina-fm", this); - //syncTimer = new QTimer(this); - //syncTimer->setInterval(200); //1/5 second (collect as many signals/slots as necessary - //syncTimer->setSingleShot(true); //Reset the UI to the previously used size (if possible) QSize orig = settings->value("preferences/MainWindowSize", QSize()).toSize(); if(!orig.isEmpty() && orig.isValid()){ @@ -56,34 +53,29 @@ QSize orig = settings->value("preferences/MainWindowSize", QSize()).toSize(); workThread->setObjectName("Lumina-fm filesystem worker"); worker = new DirData(); worker->zfsavailable = LUtils::isValidBinary("zfs"); - connect(worker, SIGNAL(DirDataAvailable(QString, QString, LFileInfoList)), this, SLOT(DirDataAvailable(QString, QString, LFileInfoList)) ); + //connect(worker, SIGNAL(DirDataAvailable(QString, QString, LFileInfoList)), this, SLOT(DirDataAvailable(QString, QString, LFileInfoList)) ); connect(worker, SIGNAL(SnapshotDataAvailable(QString, QString, QStringList)), this, SLOT(SnapshotDataAvailable(QString, QString, QStringList)) ); worker->moveToThread(workThread); - //if(DEBUG){ qDebug() << " - File System Model"; } - //fsmod = new QFileSystemModel(this); - //fsmod->setRootPath(QDir::homePath()); - //dirCompleter = new QCompleter(fsmod, this); - //dirCompleter->setModelSorting( QCompleter::CaseInsensitivelySortedModel ); if(DEBUG){ qDebug() << " - Context Menu"; } contextMenu = new QMenu(this); radio_view_details = new QRadioButton(tr("Detailed List"), this); radio_view_list = new QRadioButton(tr("Basic List"), this); - radio_view_tabs = new QRadioButton(tr("Prefer Tabs"), this); - radio_view_cols = new QRadioButton(tr("Prefer Columns"), this); + //radio_view_tabs = new QRadioButton(tr("Prefer Tabs"), this); + //radio_view_cols = new QRadioButton(tr("Prefer Columns"), this); ui->menuView_Mode->clear(); - ui->menuGroup_Mode->clear(); + //ui->menuGroup_Mode->clear(); detWA = new QWidgetAction(this); detWA->setDefaultWidget(radio_view_details); listWA = new QWidgetAction(this); listWA->setDefaultWidget(radio_view_list); - tabsWA = new QWidgetAction(this); - tabsWA->setDefaultWidget(radio_view_tabs); - colsWA = new QWidgetAction(this); - colsWA->setDefaultWidget(radio_view_cols); + //tabsWA = new QWidgetAction(this); + //tabsWA->setDefaultWidget(radio_view_tabs); + //colsWA = new QWidgetAction(this); + //colsWA->setDefaultWidget(radio_view_cols); ui->menuView_Mode->addAction(detWA); ui->menuView_Mode->addAction(listWA); - ui->menuGroup_Mode->addAction(tabsWA); - ui->menuGroup_Mode->addAction(colsWA); + //ui->menuGroup_Mode->addAction(tabsWA); + //ui->menuGroup_Mode->addAction(colsWA); //Setup the pages //ui->BrowserLayout->clear(); ui->page_player->setLayout(new QVBoxLayout()); @@ -113,8 +105,6 @@ QSize orig = settings->value("preferences/MainWindowSize", QSize()).toSize(); if(DEBUG){ qDebug() << " - Devices"; } RebuildDeviceMenu(); //Make sure we start on the browser page - if(DEBUG){ qDebug() << " - Load Browser Page"; } - //goToBrowserPage(); if(DEBUG){ qDebug() << " - Done with init"; } } @@ -149,7 +139,7 @@ void MainUI::OpenDirs(QStringList dirs){ DWLIST << DW; //Connect the signals/slots for it connect(DW, SIGNAL(OpenDirectories(QStringList)), this, SLOT(OpenDirs(QStringList)) ); - connect(DW, SIGNAL(LoadDirectory(QString, QString)), worker, SLOT(GetDirData(QString, QString)) ); + //connect(DW, SIGNAL(LoadDirectory(QString, QString)), worker, SLOT(GetDirData(QString, QString)) ); connect(DW, SIGNAL(findSnaps(QString, QString)), worker, SLOT(GetSnapshotData(QString, QString)) ); connect(DW, SIGNAL(PlayFiles(LFileInfoList)), this, SLOT(OpenPlayer(LFileInfoList)) ); connect(DW, SIGNAL(ViewFiles(LFileInfoList)), this, SLOT(OpenImages(LFileInfoList)) ); @@ -161,12 +151,13 @@ void MainUI::OpenDirs(QStringList dirs){ connect(DW, SIGNAL(RemoveFiles(QStringList)), this, SLOT(RemoveFiles(QStringList)) ); connect(DW, SIGNAL(PasteFiles(QString,QStringList)), this, SLOT(PasteFiles(QString, QStringList)) ); connect(DW, SIGNAL(CloseBrowser(QString)), this, SLOT(CloseBrowser(QString)) ); + connect(DW, SIGNAL(TabNameChanged(QString,QString)), this, SLOT(TabNameChanged(QString, QString)) ); //Now create the tab for this - if(radio_view_tabs->isChecked()){ + //if(radio_view_tabs->isChecked()){ int index = tabBar->addTab( LXDG::findIcon("folder-open",""), dirs[i].section("/",-1) ); tabBar->setTabWhatsThis( index, "DW-"+QString::number(id) ); tabBar->setCurrentIndex(index); - }else{ + /*}else{ //Just make sure the browser tab is visible bool found = false; for(int i=0; i<tabBar->count() && !found; i++){ @@ -178,17 +169,11 @@ void MainUI::OpenDirs(QStringList dirs){ tabBar->setTabWhatsThis( index, "browser" ); tabBar->setCurrentIndex(index); } - } + }*/ //Initialize the widget with the proper settings - DW->setShowDetails(radio_view_details->isChecked()); - DW->setShowSidebar(ui->actionShow_Action_Buttons->isChecked()); - QList<DirWidget::DETAILTYPES> details; details <<DirWidget::NAME << DirWidget::SIZE << DirWidget::TYPE << DirWidget::DATEMOD; - DW->setDetails(details); //Which details to show and in which order (L->R) - DW->setShowThumbnails(ui->actionShow_Thumbnails->isChecked()); + DW->setShowDetails(radio_view_details->isChecked()); DW->setThumbnailSize(settings->value("iconsize", 32).toInt()); - //DW->setDirCompleter(dirCompleter); - DW->setShowCloseButton(!radio_view_tabs->isChecked()); //Now load the directory DW->ChangeDir(dirs[i]); //kick off loading the directory info } @@ -225,9 +210,6 @@ void MainUI::setupIcons(){ // View menu ui->actionRefresh->setIcon( LXDG::findIcon("view-refresh","") ); ui->menuView_Mode->setIcon( LXDG::findIcon("view-choose","") ); - ui->menuGroup_Mode->setIcon( LXDG::findIcon("tab-duplicate","") ); - ui->actionLarger_Icons->setIcon( LXDG::findIcon("zoom-in","") ); - ui->actionSmaller_Icons->setIcon( LXDG::findIcon("zoom-out", "") ); // Bookmarks menu ui->actionManage_Bookmarks->setIcon( LXDG::findIcon("bookmarks-organize","") ); @@ -253,8 +235,8 @@ void MainUI::setupConnections(){ //Radio Buttons connect(radio_view_details, SIGNAL(toggled(bool)), this, SLOT(viewModeChanged(bool)) ); connect(radio_view_list, SIGNAL(toggled(bool)), this, SLOT(viewModeChanged(bool)) ); - connect(radio_view_tabs, SIGNAL(toggled(bool)), this, SLOT(groupModeChanged(bool)) ); - connect(radio_view_cols, SIGNAL(toggled(bool)), this, SLOT(groupModeChanged(bool)) ); + //connect(radio_view_tabs, SIGNAL(toggled(bool)), this, SLOT(groupModeChanged(bool)) ); + //connect(radio_view_cols, SIGNAL(toggled(bool)), this, SLOT(groupModeChanged(bool)) ); //Special Keyboard Shortcuts connect(nextTabLShort, SIGNAL(activated()), this, SLOT( prevTab() ) ); @@ -280,25 +262,28 @@ void MainUI::togglehiddenfiles() void MainUI::loadSettings(){ //Note: make sure this is run after all the UI elements are created and connected to slots // but before the first directory gets loaded - ui->actionView_Hidden_Files->setChecked( settings->value("showhidden", false).toBool() ); + QSettings SET("lumina-desktop","lumina-fm"); + ui->actionView_Hidden_Files->setChecked( SET.value("showhidden", false).toBool() ); on_actionView_Hidden_Files_triggered(); //make sure to update the models too - ui->actionShow_Action_Buttons->setChecked(settings->value("showactions", true).toBool() ); - on_actionShow_Action_Buttons_triggered(); //make sure to update the UI - ui->actionShow_Thumbnails->setChecked( settings->value("showthumbnails", true).toBool() ); + //ui->actionShow_Action_Buttons->setChecked(settings->value("showactions", true).toBool() ); + //on_actionShow_Action_Buttons_triggered(); //make sure to update the UI + //ui->actionShow_Thumbnails->setChecked( settings->value("showthumbnails", true).toBool() ); //View Type - bool showDetails = (settings->value("viewmode","details").toString()=="details"); + //qDebug() << "View Mode:" << SET.value("viewmode","details").toString(); + bool showDetails = (SET.value("viewmode","details").toString()=="details"); if(showDetails){ radio_view_details->setChecked(true); } else{ radio_view_list->setChecked(true); } //Grouping type - bool usetabs = (settings->value("groupmode","tabs").toString()=="tabs"); - if(usetabs){ radio_view_tabs->setChecked(true); } - else{ radio_view_cols->setChecked(true); } + //bool usetabs = (SET.value("groupmode","tabs").toString()=="tabs"); + //if(usetabs){ radio_view_tabs->setChecked(true); } + // else{ radio_view_cols->setChecked(true); } } void MainUI::RebuildBookmarksMenu(){ //Create the bookmarks menu - QStringList BM = settings->value("bookmarks", QStringList()).toStringList(); + QSettings SET("lumina-desktop","lumina-fm"); + QStringList BM = SET.value("bookmarks", QStringList()).toStringList(); ui->menuBookmarks->clear(); ui->menuBookmarks->addAction(ui->actionManage_Bookmarks); ui->menuBookmarks->addAction(ui->actionAdd_Bookmark); @@ -306,18 +291,19 @@ void MainUI::RebuildBookmarksMenu(){ bool changed = false; BM.sort(); //Sort alphabetically for(int i=0; i<BM.length(); i++){ - if(QFile::exists(BM[i].section("::::",1,1)) ){ + //NOTE 9/28/16: Don't do existance checks here - if a network drive is specified it can cause the loading process to hang significantly + //if(QFile::exists(BM[i].section("::::",1,1)) ){ QAction *act = new QAction(BM[i].section("::::",0,0),this); act->setWhatsThis(BM[i].section("::::",1,1)); ui->menuBookmarks->addAction(act); - }else{ + /*}else{ //Invalid directory - remove the bookmark BM.removeAt(i); i--; changed = true; - } + }*/ } - if(changed){ settings->setValue("bookmarks",BM); } + if(changed){ SET.setValue("bookmarks",BM); } ui->actionManage_Bookmarks->setEnabled(BM.length()>0); } @@ -434,16 +420,16 @@ void MainUI::on_actionClose_triggered(){ this->close(); } -void MainUI::on_actionRename_triggered(){ +/*void MainUI::on_actionRename_triggered(){ DirWidget *dir = FindActiveBrowser(); if(DEBUG){ qDebug() << "Rename Shortcut Pressed:" << dir << dir->currentDir(); } - if(dir!=0){ QTimer::singleShot(0, dir, SLOT(TryRenameSelection()) ); } + if(dir!=0){ QTimer::singleShot(0, dir, SLOT(renameFiles()) ); } } void MainUI::on_actionCut_Selection_triggered(){ DirWidget *dir = FindActiveBrowser(); if(DEBUG){ qDebug() << "Cut Shortcut Pressed:" << dir << dir->currentDir(); } - if(dir!=0){ QTimer::singleShot(0, dir, SLOT(TryCutSelection()) ); } + if(dir!=0){ QTimer::singleShot(0, dir, SLOT(cutFiles()) ); } } void MainUI::on_actionCopy_Selection_triggered(){ @@ -462,7 +448,7 @@ void MainUI::on_actionDelete_Selection_triggered(){ DirWidget *dir = FindActiveBrowser(); if(DEBUG){ qDebug() << "Delete Shortcut Pressed:" << dir << dir->currentDir(); } if(dir!=0){ QTimer::singleShot(0, dir, SLOT(TryDeleteSelection()) ); } -} +}*/ void MainUI::on_actionRefresh_triggered(){ DirWidget *cur = FindActiveBrowser(); @@ -473,24 +459,24 @@ void MainUI::on_actionView_Hidden_Files_triggered(){ worker->showHidden = ui->actionView_Hidden_Files->isChecked(); //Now save this setting for later settings->setValue("showhidden", ui->actionView_Hidden_Files->isChecked()); - worker->showHidden = ui->actionView_Hidden_Files->isChecked(); + //worker->showHidden = ui->actionView_Hidden_Files->isChecked(); //Re-load the current browsers - for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refresh(); } + for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->showHidden( ui->actionView_Hidden_Files->isChecked() ); }//DWLIST[i]->refresh(); } } -void MainUI::on_actionShow_Action_Buttons_triggered(){ +/*void MainUI::on_actionShow_Action_Buttons_triggered(){ bool show = ui->actionShow_Action_Buttons->isChecked(); settings->setValue("showactions", show); - for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setShowSidebar(show); } -} + //for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setShowSidebar(show); } +}*/ -void MainUI::on_actionShow_Thumbnails_triggered(){ +/*void MainUI::on_actionShow_Thumbnails_triggered(){ //Now save this setting for later bool show = ui->actionShow_Thumbnails->isChecked(); settings->setValue("showthumbnails", show); - for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setShowThumbnails(show); } -} + //for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setShowThumbnails(show); } +}*/ void MainUI::goToBookmark(QAction *act){ if(act==ui->actionManage_Bookmarks){ @@ -529,8 +515,9 @@ void MainUI::goToDevice(QAction *act){ void MainUI::viewModeChanged(bool active){ if(!active){ return; } //on every view change, all radio buttons will call this function - only run this once though bool showDetails = radio_view_details->isChecked(); - if(showDetails){ settings->setValue("viewmode","details"); } - else{ settings->setValue("viewmode","list"); } + QSettings SET("lumina-desktop","lumina-fm"); + if(showDetails){ SET.setValue("viewmode","details"); } + else{ SET.setValue("viewmode","list"); } //Re-load the view widgets for(int i=0; i<DWLIST.length(); i++){ @@ -539,11 +526,11 @@ void MainUI::viewModeChanged(bool active){ } -void MainUI::groupModeChanged(bool active){ +/*void MainUI::groupModeChanged(bool active){ if(!active){ return; } //on every change, all radio buttons will call this function - only run this once though - bool usetabs = radio_view_tabs->isChecked(); - if(usetabs){ - settings->setValue("groupmode","tabs"); + //bool usetabs = radio_view_tabs->isChecked(); + //if(usetabs){ + //settings->setValue("groupmode","tabs"); //Now clean up all the tabs (remove the generic one and add the specific ones) for(int i=0; i<tabBar->count(); i++){ //Remove all the browser tabs @@ -557,7 +544,7 @@ void MainUI::groupModeChanged(bool active){ qDebug() << "Add specific tab:" << DWLIST[i]->currentDir() << DWLIST[i]->id(); int tab = tabBar->addTab( LXDG::findIcon("folder-open",""), DWLIST[i]->currentDir().section("/",-1) ); tabBar->setTabWhatsThis(tab, DWLIST[i]->id() ); - DWLIST[i]->setShowCloseButton(false); + //DWLIST[i]->setShowCloseButton(false); } }else{ settings->setValue("groupmode","columns"); @@ -572,12 +559,12 @@ void MainUI::groupModeChanged(bool active){ //Now create the generic "browser" tab int tab = tabBar->addTab( LXDG::findIcon("folder-open",""), tr("Browser") ); tabBar->setTabWhatsThis(tab, "browser" ); - for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setShowCloseButton(true); } + //for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setShowCloseButton(true); } } if(tabBar->currentIndex()<0){ tabBar->setCurrentIndex(0); } tabBar->setVisible( tabBar->count() > 1 ); QTimer::singleShot(20, this, SLOT(tabChanged()) ); -} +}*/ void MainUI::on_actionLarger_Icons_triggered(){ int size = settings->value("iconsize", 32).toInt(); @@ -645,16 +632,16 @@ void MainUI::tabChanged(int tab){ else if(info=="#SW"){ ui->stackedWidget->setCurrentWidget(ui->page_image); } else{ ui->stackedWidget->setCurrentWidget(ui->page_browser); - if(radio_view_tabs->isChecked()){ + //if(radio_view_tabs->isChecked()){ for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setVisible(DWLIST[i]->id()==info); } - }else{ + /*}else{ //For columns, all widgets need to be visible for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setVisible(true); } - } + }*/ } tabBar->setVisible( tabBar->count() > 1 ); } @@ -695,22 +682,6 @@ void MainUI::nextTab(){ else{ tabBar->setCurrentIndex( cur+1 ); } } -void MainUI::DirDataAvailable(QString id, QString dir, LFileInfoList list){ - for(int i=0; i<DWLIST.length(); i++){ - if(id == DWLIST[i]->id()){ - DWLIST[i]->LoadDir(dir, list); - break; - } - } - if(radio_view_tabs->isChecked()){ - //Need to update the text for the tab so it corresponds to the current directory loaded - for(int i=0; i<tabBar->count(); i++){ - if(tabBar->tabWhatsThis(i)==id){ - tabBar->setTabText(i, dir.section("/",-1)); - } - } - } -} void MainUI::SnapshotDataAvailable(QString id , QString dir, QStringList list){ for(int i=0; i<DWLIST.length(); i++){ @@ -789,7 +760,7 @@ void MainUI::CutFiles(QStringList list){ QApplication::clipboard()->clear(); QApplication::clipboard()->setMimeData(dat); //Update all the buttons to account for clipboard change - for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refreshButtons(); } + //for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refreshButtons(); } } void MainUI::CopyFiles(QStringList list){ @@ -809,7 +780,7 @@ void MainUI::CopyFiles(QStringList list){ QApplication::clipboard()->clear(); QApplication::clipboard()->setMimeData(dat); //Update all the buttons to account for clipboard change - for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refreshButtons(); } + //for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refreshButtons(); } } void MainUI::PasteFiles(QString dir, QStringList raw){ @@ -864,7 +835,7 @@ void MainUI::PasteFiles(QString dir, QStringList raw){ } } //Update all the buttons to account for clipboard change - for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refresh(); } + //for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refresh(); } } void MainUI::FavoriteFiles(QStringList list){ @@ -930,13 +901,13 @@ void MainUI::RemoveFiles(QStringList list){ //Now remove the file/dir qDebug() << " - Delete: "<<paths; - worker->pauseData = true; //pause any info requests + //worker->pauseData = true; //pause any info requests FODialog dlg(this); dlg.RemoveFiles(paths); dlg.show(); dlg.exec(); - worker->pauseData = false; //resume info requests - for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refresh(); } + //worker->pauseData = false; //resume info requests + //for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refresh(); } } void MainUI::CloseBrowser(QString ID){ @@ -959,3 +930,12 @@ void MainUI::CloseBrowser(QString ID){ OpenDirs(QStringList() << QDir::homePath()); } } + +void MainUI::TabNameChanged(QString id, QString name){ + for(int i=0; i<tabBar->count(); i++){ + if(tabBar->tabWhatsThis(i)==id){ + tabBar->setTabText(i, name); + return; + } + } +} diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.h b/src-qt5/desktop-utils/lumina-fm/MainUI.h index 19b40406..94c6f6c2 100644 --- a/src-qt5/desktop-utils/lumina-fm/MainUI.h +++ b/src-qt5/desktop-utils/lumina-fm/MainUI.h @@ -55,7 +55,7 @@ #include "DirData.h" #include "widgets/MultimediaWidget.h" #include "widgets/SlideshowWidget.h" -#include "widgets/DirWidget.h" +#include "widgets/DirWidget2.h" namespace Ui{ class MainUI; @@ -79,8 +79,8 @@ private: QTabBar *tabBar; //QFileSystemModel *fsmod; QMenu *contextMenu; - QRadioButton *radio_view_details, *radio_view_list, *radio_view_tabs, *radio_view_cols; - QWidgetAction *detWA, *listWA, *tabsWA, *colsWA; + QRadioButton *radio_view_details, *radio_view_list;//, *radio_view_tabs, *radio_view_cols; + QWidgetAction *detWA, *listWA;//, *tabsWA, *colsWA; //UI Widgets QList<DirWidget*> DWLIST; @@ -116,19 +116,19 @@ private slots: void on_actionSearch_triggered(); void on_actionClose_Browser_triggered(); void on_actionClose_triggered(); - void on_actionRename_triggered(); + /*void on_actionRename_triggered(); void on_actionCut_Selection_triggered(); void on_actionCopy_Selection_triggered(); void on_actionPaste_triggered(); - void on_actionDelete_Selection_triggered(); + void on_actionDelete_Selection_triggered();*/ void on_actionRefresh_triggered(); void on_actionView_Hidden_Files_triggered(); - void on_actionShow_Action_Buttons_triggered(); - void on_actionShow_Thumbnails_triggered(); + //void on_actionShow_Action_Buttons_triggered(); + //void on_actionShow_Thumbnails_triggered(); void goToBookmark(QAction*); void goToDevice(QAction*); void viewModeChanged(bool); - void groupModeChanged(bool); + //void groupModeChanged(bool); void on_actionLarger_Icons_triggered(); void on_actionSmaller_Icons_triggered(); void CreateBookMark(); @@ -148,7 +148,7 @@ private slots: void focusDirWidget(); //Backend Info passing - void DirDataAvailable(QString, QString, LFileInfoList); + //void DirDataAvailable(QString, QString, LFileInfoList); void SnapshotDataAvailable(QString, QString, QStringList); //Dir Browser Interactions @@ -162,7 +162,8 @@ private slots: void RenameFiles(QStringList); //file selection void RemoveFiles(QStringList); //file selection void CloseBrowser(QString); //ID - + void TabNameChanged(QString, QString); // ID/name + //file info in status bar void DisplayStatusBar(QString); diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.ui b/src-qt5/desktop-utils/lumina-fm/MainUI.ui index 3c11d87e..f356eadb 100644 --- a/src-qt5/desktop-utils/lumina-fm/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-fm/MainUI.ui @@ -131,23 +131,11 @@ </property> <addaction name="actionTabs"/> </widget> - <widget class="QMenu" name="menuGroup_Mode"> - <property name="title"> - <string>Group Mode</string> - </property> - <addaction name="actionTabs_2"/> - </widget> <addaction name="actionRefresh"/> <addaction name="separator"/> - <addaction name="actionShow_Thumbnails"/> <addaction name="actionView_Hidden_Files"/> - <addaction name="actionShow_Action_Buttons"/> <addaction name="separator"/> <addaction name="menuView_Mode"/> - <addaction name="menuGroup_Mode"/> - <addaction name="separator"/> - <addaction name="actionLarger_Icons"/> - <addaction name="actionSmaller_Icons"/> </widget> <widget class="QMenu" name="menuBookmarks"> <property name="title"> @@ -164,18 +152,6 @@ <addaction name="actionScan"/> <addaction name="separator"/> </widget> - <widget class="QMenu" name="menuEdit"> - <property name="title"> - <string>Edit</string> - </property> - <addaction name="actionRename"/> - <addaction name="separator"/> - <addaction name="actionCut_Selection"/> - <addaction name="actionCopy_Selection"/> - <addaction name="actionPaste"/> - <addaction name="separator"/> - <addaction name="actionDelete_Selection"/> - </widget> <widget class="QMenu" name="menuGit"> <property name="title"> <string>Git</string> @@ -184,7 +160,6 @@ <addaction name="actionClone_Repository"/> </widget> <addaction name="menuFile"/> - <addaction name="menuEdit"/> <addaction name="menuView"/> <addaction name="menuBookmarks"/> <addaction name="menuExternal_Devices"/> @@ -193,7 +168,7 @@ <widget class="QStatusBar" name="statusbar"/> <action name="actionNew_Tab"> <property name="text"> - <string>New Browser</string> + <string>New Tab</string> </property> <property name="toolTip"> <string>New Browser</string> @@ -425,7 +400,7 @@ </action> <action name="actionClose_Browser"> <property name="text"> - <string>Close Browser</string> + <string>Close Tab</string> </property> <property name="shortcut"> <string>Ctrl+W</string> diff --git a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro index 487a6421..8fb482c7 100644 --- a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro +++ b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro @@ -15,7 +15,7 @@ SOURCES += main.cpp \ BMMDialog.cpp \ widgets/MultimediaWidget.cpp \ widgets/SlideshowWidget.cpp \ - widgets/DirWidget.cpp \ + widgets/DirWidget2.cpp \ gitCompat.cpp \ gitWizard.cpp \ Browser.cpp \ @@ -29,7 +29,7 @@ HEADERS += MainUI.h \ widgets/DDListWidgets.h \ widgets/MultimediaWidget.h \ widgets/SlideshowWidget.h \ - widgets/DirWidget.h \ + widgets/DirWidget2.h \ gitCompat.h \ gitWizard.h \ Browser.h \ @@ -40,7 +40,7 @@ FORMS += MainUI.ui \ BMMDialog.ui \ widgets/MultimediaWidget.ui \ widgets/SlideshowWidget.ui \ - widgets/DirWidget.ui \ + widgets/DirWidget2.ui \ gitWizard.ui icons.files = Insight-FileManager.png diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h index e7dfb4d1..8049600e 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h @@ -44,14 +44,20 @@ public: this->setFlow(QListView::TopToBottom); this->setWrapping(true); this->setMouseTracking(true); - //this->setSortingEnabled(true); //This sorts *only* by name - type is not preserved + this->setSortingEnabled(true); //This sorts *only* by name - type is not preserved } ~DDListWidget(){} signals: void DataDropped(QString, QStringList); //Dir path, List of commands - + void GotFocus(); + protected: + void focusInEvent(QFocusEvent *ev){ + QListWidget::focusInEvent(ev); + emit GotFocus(); + } + void startDrag(Qt::DropActions act){ QList<QListWidgetItem*> items = this->selectedItems(); if(items.length()<1){ return; } @@ -157,8 +163,13 @@ public: signals: void DataDropped(QString, QStringList); //Dir path, List of commands - + void GotFocus(); + protected: + void focusInEvent(QFocusEvent *ev){ + QTreeWidget::focusInEvent(ev); + emit GotFocus(); + } void startDrag(Qt::DropActions act){ QList<QTreeWidgetItem*> items = this->selectedItems(); if(items.length()<1){ return; } @@ -261,10 +272,10 @@ public: inline virtual bool operator<(const QTreeWidgetItem &tmp) const { int column = this->treeWidget()->sortColumn(); // We are in date text - if(column == 3 || column == 4) + if(column == 3 || column == 4){ return this->whatsThis(column) < tmp.whatsThis(column); // We are in size text - else if(column == 1) { + }else if(column == 1) { QString text = this->text(column); QString text_tmp = tmp.text(column); double filesize, filesize_tmp; @@ -280,9 +291,29 @@ public: else filesize_tmp = LUtils::DisplaySizeToBytes(text_tmp); return filesize < filesize_tmp; + + //Name column - still sort by type too (folders first) + }else if(column == 0 && (this->text(2).isEmpty() || tmp.text(2).isEmpty()) ){ + if(this->text(2) != tmp.text(2)){ return this->text(2).isEmpty(); } } // In other cases, we trust base class implementation return QTreeWidgetItem::operator<(tmp); } }; + +//Item override for sorting purposes of list widget items +class CQListWidgetItem : public QListWidgetItem { +public: + CQListWidgetItem(const QIcon &icon, const QString &text, QListWidget *parent = Q_NULLPTR) : QListWidgetItem(icon,text,parent) {} + virtual ~CQListWidgetItem() {} + inline virtual bool operator<(const QListWidgetItem &tmp) const { + QString type = this->data(Qt::UserRole).toString(); + QString tmptype = tmp.data(Qt::UserRole).toString(); + //Sort by type first + if(type!=tmptype){ return (QString::compare(type,tmptype)<0); } + //Then sort by name using the normal rules + return QListWidgetItem::operator<(tmp); + } +}; + #endif |