From 4f90da22cb075252d9cbb0e797a656ed8cd065bd Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 27 Sep 2016 16:34:15 -0400 Subject: More work on the new backend: still disabled for now. --- .../lumina-fm/widgets/DDListWidgets.h | 50 +++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h') diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h index e3de9b0e..e7dfb4d1 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h @@ -24,6 +24,8 @@ #include #include +#include + //============== // LIST WIDGET //============== @@ -237,4 +239,50 @@ protected: else{ QTreeWidget::mouseMoveEvent(ev); } //pass it along to the widget }*/ }; -#endif \ No newline at end of file + +/* + * 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 == 3 || column == 4) + return this->whatsThis(column) < tmp.whatsThis(column); + // We are in size text + else if(column == 1) { + 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 -- cgit From 04b5af3c9996f24764fddb4819f38e178c5dff4a Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 30 Sep 2016 14:40:40 -0400 Subject: Commit a large update to lumina-fm: The entire backend has been rewritten around multi-threading, and is much faster and more responsive now. The entire browsing widget has been redesigned for a better workflow and cleaner UI. The tabs/columns "group modes" have been removed. Instead, tabs are always used, but each browser supports a single/dual columns *within* each tab (via a couple simple buttons on the toolbar). Each column within a tab will share the same interface buttons (toolbar actions, ZFS snapshot slider,etc) - and they will reflect the settings on the "Active" column (with appropriate visual changes to indicate which one is active). The icon size options have also been removed from the menu bar and are now a couple small "zoom" buttons on the browsing widgets instead. KNOWN REGRESSION: Keyboard shortcuts have not been tested and re-added as necessary yet. --- .../lumina-fm/widgets/DDListWidgets.h | 41 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h') 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 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 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 -- cgit From 7ab900e41f5f15adccd573d459a80fe60cf6a044 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 7 Nov 2016 13:52:20 -0500 Subject: LARGE UPDATE: 1) Dismantle the Lumina library completely. 2) Setup lots of small subproject files (.pri) for the individual classes within the old library. 3) Move all the Lumina binaries to use the new subproject files 4) Split up the LuminaUtils class/files into LUtils and LDesktopUtils (generic utilities, and desktop-specific utilities) --- src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h') diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h index 8049600e..48127efa 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h @@ -24,7 +24,7 @@ #include #include -#include +#include //============== // LIST WIDGET -- cgit From 546bba1faf69e1aac06aa13fd0ecd28d23c09a7f Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 5 Dec 2016 09:31:56 -0500 Subject: Re-enable drag and drop within lumina-fm. --- .../lumina-fm/widgets/DDListWidgets.h | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h') diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h index 48127efa..f7373432 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h @@ -63,9 +63,10 @@ protected: if(items.length()<1){ return; } QList urilist; for(int i=0; iwhatsThis().section("::::",1,100)); + urilist << QUrl::fromLocalFile(items[i]->whatsThis()); } //Create the mime data + //qDebug() << "Start Drag:" << urilist; QMimeData *mime = new QMimeData; mime->setUrls(urilist); //Create the drag structure @@ -91,6 +92,7 @@ protected: if(ev->mimeData()->hasUrls() && !this->whatsThis().isEmpty() ){ //Change the drop type depending on the data/dir QString home = QDir::homePath(); + //qDebug() << "Drag Move:" << home << this->whatsThis(); if( this->whatsThis().startsWith(home) ){ ev->setDropAction(Qt::MoveAction); } else{ ev->setDropAction(Qt::CopyAction); } ev->acceptProposedAction(); //allow this to be dropped here @@ -107,7 +109,8 @@ protected: //See if the item under the drop point is a directory or not QListWidgetItem *it = this->itemAt( ev->pos()); if(it!=0){ - QFileInfo info(it->whatsThis().section("::::",1,100)); + //qDebug() << "Drop Item:" << it->whatsThis(); + QFileInfo info(it->whatsThis()); if(info.isDir() && info.isWritable()){ dirpath = info.absoluteFilePath(); } @@ -118,11 +121,12 @@ protected: foreach(const QUrl &url, ev->mimeData()->urls()){ const QString filepath = url.toLocalFile(); //If the target file is modifiable, assume a move - otherwise copy - if(QFileInfo(filepath).isWritable() && (filepath.startsWith(home) && dirpath.startsWith(home))){ files << "cut::::"+filepath; } - else{ files << "copy::::"+filepath; } + if(QFileInfo(filepath).isWritable() && (filepath.startsWith(home) && dirpath.startsWith(home))){ + if(filepath.section("/",0,-2)!=dirpath){ files << "cut::::"+filepath; } //don't "cut" a file into the same dir + }else{ files << "copy::::"+filepath; } } - //qDebug() << "Drop Event:" << dirpath; - emit DataDropped( dirpath, files ); + //qDebug() << "Drop Event:" << dirpath << files; + if(!files.isEmpty()){ emit DataDropped( dirpath, files ); } } void mouseReleaseEvent(QMouseEvent *ev){ @@ -175,7 +179,7 @@ protected: if(items.length()<1){ return; } QList urilist; for(int i=0; iwhatsThis(0).section("::::",1,100)); + urilist << QUrl::fromLocalFile(items[i]->whatsThis(0)); } //Create the mime data QMimeData *mime = new QMimeData; @@ -218,7 +222,7 @@ protected: //See if the item under the drop point is a directory or not QTreeWidgetItem *it = this->itemAt( ev->pos()); if(it!=0){ - QFileInfo info(it->whatsThis(0).section("::::",1,100)); + QFileInfo info(it->whatsThis(0)); if(info.isDir() && info.isWritable()){ dirpath = info.absoluteFilePath(); } @@ -229,9 +233,10 @@ protected: QString home = QDir::homePath(); foreach(const QUrl &url, ev->mimeData()->urls()){ const QString filepath = url.toLocalFile(); - //If the target file is modifiable, assume a move - otherwise copy - if(QFileInfo(filepath).isWritable() && (filepath.startsWith(home) && dirpath.startsWith(home)) ){ files << "cut::::"+filepath; } - else{ files << "copy::::"+filepath; } + //If the target file is modifiable, assume a move - otherwise copy + if(QFileInfo(filepath).isWritable() && (filepath.startsWith(home) && dirpath.startsWith(home))){ + if(filepath.section("/",0,-2)!=dirpath){ files << "cut::::"+filepath; } //don't "cut" a file into the same dir + }else{ files << "copy::::"+filepath; } } //qDebug() << "Drop Event:" << dirpath; emit DataDropped( dirpath, files ); -- cgit From 5e027876c9aea2f7d7aed8e7e26b7f6dfada31c7 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 5 Dec 2016 12:30:23 -0500 Subject: Commit a couple tweaks for lumina-fm - trying to get the drag and drop highlighting working. --- src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h') diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h index f7373432..254362fd 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h @@ -45,6 +45,7 @@ public: this->setWrapping(true); this->setMouseTracking(true); this->setSortingEnabled(true); //This sorts *only* by name - type is not preserved + //this->setStyleSheet("QListWidget::item{ border: 1px solid transparent; border-radius: 5px; background-color: transparent;} QListWidget::item:hover{ border-color: black; } QListWidget::item:focus{ border-color: lightblue; }"); } ~DDListWidget(){} @@ -85,7 +86,7 @@ protected: ev->acceptProposedAction(); //allow this to be dropped here }else{ ev->ignore(); - } + } } void dragMoveEvent(QDragMoveEvent *ev){ @@ -93,12 +94,15 @@ protected: //Change the drop type depending on the data/dir QString home = QDir::homePath(); //qDebug() << "Drag Move:" << home << this->whatsThis(); - if( this->whatsThis().startsWith(home) ){ ev->setDropAction(Qt::MoveAction); } - else{ ev->setDropAction(Qt::CopyAction); } + if( this->whatsThis().startsWith(home) ){ ev->setDropAction(Qt::MoveAction); this->setCursor(Qt::DragMoveCursor); } + else{ ev->setDropAction(Qt::CopyAction); this->setCursor(Qt::DragCopyCursor);} ev->acceptProposedAction(); //allow this to be dropped here + //this->setCursor(Qt::CrossCursor); }else{ + this->setCursor(Qt::ForbiddenCursor); ev->ignore(); } + this->update(); } void dropEvent(QDropEvent *ev){ @@ -127,6 +131,7 @@ protected: } //qDebug() << "Drop Event:" << dirpath << files; if(!files.isEmpty()){ emit DataDropped( dirpath, files ); } + this->setCursor(Qt::ArrowCursor); } void mouseReleaseEvent(QMouseEvent *ev){ -- cgit