aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp81
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.h47
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp70
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.h97
-rw-r--r--src-qt5/desktop-utils/lumina-fm/MainUI.cpp12
-rw-r--r--src-qt5/desktop-utils/lumina-fm/MainUI.h4
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp2
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h2
8 files changed, 305 insertions, 10 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
new file mode 100644
index 00000000..b207604c
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
@@ -0,0 +1,81 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "Browser.h"
+
+Browser::Browser(QObject *parent) : QObject(parent){
+ watcher = new QFileSystemWatcher(this);
+ connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(QString)) );
+ connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(dirChanged(QString)) );
+ showHidden = false;
+}
+
+Browser::~Browser(){
+ watcher->deleteLater();
+}
+
+QString Browser::currentDirectory(){ return currentDir; }
+
+void Browser::showHiddenFiles(bool show){
+ if(show !=showHidden){
+ showHidden = show;
+ QTimer::singleShot(0, this, SLOT(loadDirectory()) );
+ }
+}
+bool Browser::showingHiddenFiles(){
+ return showHidden;
+}
+
+// PRIVATE
+void Browser::loadItem(QFileInfo info){
+ LFileInfo linfo(info);
+ QIcon ico;
+ if(linfo.isImage()){
+ QPixmap pix;
+ if(pix.load(info.absoluteFilePath()) ){
+ if(pix.height()>128){ pix = pix.scaled(128, 128, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); }
+ ico.addPixmap(pix);
+ }
+ }else if(linfo.isDirectory()){
+ ico = LXDG::findIcon("folder","inode/directory");
+ }
+ if(ico.isNull()){ ico = LXDG::findIcon(linfo.mimetype(), "unknown"); }
+ emit ItemDataAvailable(ico, linfo);
+}
+
+// PRIVATE SLOTS
+void Browser::fileChanged(QString file){
+ if(file.startsWith(currentDir+"/")){ emit itemUpdated(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); }
+}
+
+// PUBLIC SLOTS
+QString Browser::loadDirectory(QString dir){
+ if(dir.isEmpty()){ dir = currentDir; } //reload current directory
+ if(dir.isEmpty()){ return; } //nothing to do - nothing previously loaded
+ //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
+ //QApplication::processEvents();
+ // read the given directory
+ QDir directory(dir);
+ if(directory.exists()){
+ QFileInfoList files;
+ if(showHidden){ files = directory.entryInfoList( QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotOrDotDot, QDir::NoSort); }
+ else{ files = directory.entryInfoList( QDir::Dirs | QDir::Files | QDir::NoDotOrDotDot, QDir::NoSort); }
+ for(int i=0; i<files.length(); i++){
+ watcher->addPath(files[i].absoluteFilePath());
+ QtConcurrent::run(this, &Browser::loadDirectory, files[i]);
+ }
+ watcher->addPath(directory.absolutePath());
+ }
+}
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h
new file mode 100644
index 00000000..ccc10c02
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.h
@@ -0,0 +1,47 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is the main browsing backend for the file manager
+//===========================================
+#ifndef _LUMINA_FM_BROWSE_BACKEND_H
+#define _LUMINA_FM_BROWSE_BACKEND_H
+
+class Browser : public QObject{
+ Q_OBJECT
+public:
+ Browser(QObject *parent = 0);
+ ~Browser();
+
+ QString currentDirectory();
+ void showHiddenFiles(bool);
+ bool showingHiddenFiles();
+
+private:
+ QString currentDir;
+ QFileSystemWatcher *watcher;
+ bool showHidden;
+
+ void loadItem(QFileInfo info); //this is the main loader class - multiple instances each run in a separate thread
+
+private slots:
+ void fileChanged(QString); //tied into the watcher - for file change notifications
+ void dirChanged(QString); // tied into the watcher - for new/removed files in the current dir
+
+public slots:
+ QString loadDirectory(QString dir = "");
+
+signals:
+ //Main Signals
+ void itemUpdated(QString item); //emitted if a file changes after the initial scan
+ void clearItems(); //emitted when dirs change for example
+ void itemDataAvailable(QIcon, LFileInfo);
+
+ //Start/Stop signals for loading of data
+ void itemsLoading(int); //number of items which are getting loaded
+
+};
+
+#endif
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
new file mode 100644
index 00000000..12fd36fe
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
@@ -0,0 +1,70 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "BrowserWidget.h"
+BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){
+ //Setup the Widget/UI
+ this->setLayout( new QVBoxLayout(this) );
+
+ //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(itemUpdated(QString)), this, SLOT(itemUpdated(QString)) );
+ connect(BROWSER, SIGNAL(itemUpdated(QString)), this, SLOT(itemUpdated(QString)) );
+
+ listWidget = 0;
+ treeWidget = 0;
+}
+
+BrowserWidget::~BrowserWidget(){
+
+}
+
+void BrowserWidget::changeDirectory(QString dir){
+ if(BROWSER->currentDirectory()==dir){ return; } //already on this directory
+ BROWSER->loadDirectory(dir);
+}
+
+// =================
+// PRIVATE SLOTS
+// =================
+void BrowserWidget::clearItems(){
+ if(listWidget!=0){ listWidget->clear(); }
+ else if(treeWidget!=0){ treeWidget->clear(); }
+ this->setEnabled(false);
+}
+
+void BrowserWidget::itemUpdated(QString item){
+ if(treeWidget==0){ return; } //only used for the tree widget/details
+ qDebug() << "item updated" << item;
+ QList<QTreeWidgetItem*> found = treeWidget->findItems(item.section("/",-1), Qt::MatchExactly, 0); //look for exact name match
+ if(found.isEmpty()){ return; } //no match
+ QTreeWidgetItem *it = found[0]; //onlyp update the first match (should only ever be one - duplicate file names are disallowed)
+ //it->setText(
+}
+
+void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){
+ int num = 0;
+ if(listWidget!=0){
+ listWidget->addItem( new QListWidgetItem(ico, info.fileName(), listWidget) );
+ num = listWidget->count();
+ }else if(treeWidget!=0){
+ //TODO
+ }
+ if(num < numItems){
+ //Still loading items
+ //this->setEnabled(false);
+ }else{
+ //Done loading items
+ this->setEnabled(true);
+ }
+}
+
+void BrowserWidget::itemsLoading(int total){
+ numItems = total; //save this for later
+}
+
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
new file mode 100644
index 00000000..a0dc535a
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
@@ -0,0 +1,97 @@
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is the main browsing frontend for the file manager
+//===========================================
+#ifndef _LUMINA_FM_BROWSE_FRONTEND_H
+#define _LUMINA_FM_BROWSE_FRONTEND_H
+
+#include "Browser.h"
+#include "widgets/DDListWidgets.h"
+
+class BrowserWidget : public QWidget{
+ Q_OBJECT
+private:
+ Browser *DIR:
+ QString ID;
+ int numItems; //used for checking if all the items have loaded yet
+ bool details; //show details or not
+
+ //The drag and drop brower widgets
+ DDListWidget *listWidget;
+ DDTreeWidget *treeWidget;
+
+public:
+ BrowserWidget(QString objID, QWidget *parent = 0);
+ ~BrowserWidget();
+
+ QString id(){ return ID; }
+
+ void changeDirectory(QString dir);
+
+ void showDetails(bool show);
+ bool hasDetails();
+
+public slots:
+
+private slots:
+ //Brower connections
+ void clearItems();
+ void itemUpdated(QString);
+ void itemDataAvailable(QIcon, LFileInfo);
+ void itemsLoading(int total);
+
+signals:
+ //void activated(QString); //current dir path
+ void dirChanged(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/MainUI.cpp b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp
index abe14c0d..59b671b5 100644
--- a/src-qt5/desktop-utils/lumina-fm/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp
@@ -59,11 +59,11 @@ QSize orig = settings->value("preferences/MainWindowSize", QSize()).toSize();
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() << " - 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);
@@ -187,7 +187,7 @@ void MainUI::OpenDirs(QStringList dirs){
DW->setDetails(details); //Which details to show and in which order (L->R)
DW->setShowThumbnails(ui->actionShow_Thumbnails->isChecked());
DW->setThumbnailSize(settings->value("iconsize", 32).toInt());
- DW->setDirCompleter(dirCompleter);
+ //DW->setDirCompleter(dirCompleter);
DW->setShowCloseButton(!radio_view_tabs->isChecked());
//Now load the directory
DW->ChangeDir(dirs[i]); //kick off loading the directory info
diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.h b/src-qt5/desktop-utils/lumina-fm/MainUI.h
index 6df10a89..19b40406 100644
--- a/src-qt5/desktop-utils/lumina-fm/MainUI.h
+++ b/src-qt5/desktop-utils/lumina-fm/MainUI.h
@@ -77,7 +77,7 @@ private:
DirData *worker;
//Internal non-ui widgets
QTabBar *tabBar;
- QFileSystemModel *fsmod;
+ //QFileSystemModel *fsmod;
QMenu *contextMenu;
QRadioButton *radio_view_details, *radio_view_list, *radio_view_tabs, *radio_view_cols;
QWidgetAction *detWA, *listWA, *tabsWA, *colsWA;
@@ -89,7 +89,7 @@ private:
QSettings *settings;
QShortcut *nextTabLShort, *nextTabRShort, *togglehiddenfilesShort, *focusDirWidgetShort;
- QCompleter *dirCompleter;
+ //QCompleter *dirCompleter;
//Simplification Functions
void setupConnections(); //used during initialization
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp
index b8b4da0b..d5f15a50 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp
@@ -26,7 +26,7 @@
#define DEBUG 0
-const QString sessionsettings_config_file = QDir::homePath() + "/.lumina/LuminaDE/sessionsettings.conf";
+const QString sessionsettings_config_file = QDir::homePath() + "/.config/lumina-desktop/sessionsettings.conf";
DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new Ui::DirWidget){
ui->setupUi(this); //load the designer file
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h
index 3ef9940b..afbb98cc 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h
@@ -73,7 +73,7 @@ public slots:
void UpdateButtons();
//Keyboard Shortcuts triggered
- void TryRenameSelection();
+ void TryRenameSelection();
void TryCutSelection();
void TryCopySelection();
void TryPasteSelection();
bgstack15