aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2017-06-16 09:55:20 -0400
committerZackaryWelch <welch.zackary@gmail.com>2017-06-16 09:55:20 -0400
commite6ee4bc612c79fc35f68e8e5324a9c9c23e720c1 (patch)
tree1c3e9d3a233877d499a920f1d7dda3a81891b98d /src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
parentUpdated syntax files (diff)
parentadd prototype for autoextract menu entry (diff)
downloadlumina-e6ee4bc612c79fc35f68e8e5324a9c9c23e720c1.tar.gz
lumina-e6ee4bc612c79fc35f68e8e5324a9c9c23e720c1.tar.bz2
lumina-e6ee4bc612c79fc35f68e8e5324a9c9c23e720c1.zip
Merge branch 'master' of https://github.com/trueos/lumina
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp99
1 files changed, 96 insertions, 3 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
index a2adc94f..a32a0478 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
@@ -1,4 +1,4 @@
- //===========================================
+ //===========================================
// Lumina-DE source code
// Copyright (c) 2015, Ken Moore
// Available under the 3-clause BSD license
@@ -64,6 +64,8 @@
connect(BW, SIGNAL(updateDirectoryStatus(QString)), this, SLOT(dirStatusChanged(QString)) );
connect(BW, SIGNAL(hasFocus(QString)), this, SLOT(setCurrentBrowser(QString)) );
+ //---------------------------------------------------//
+
// Create treeviewpane QFileSystemModel model and populate
QString folderTreePath = QDir::rootPath();
dirtreeModel = new QFileSystemModel(this);
@@ -71,10 +73,12 @@
dirtreeModel->setRootPath(folderTreePath);
//ui->folderViewPane->setModel(dirtreeModel)
+ //---------------------------------------------------//
+
//Now update the rest of the UI
canmodify = false; //initial value
contextMenu = new QMenu(this);
- cNewMenu = cOpenMenu = cFModMenu = cFViewMenu = 0; //not created yet
+ cNewMenu = cOpenMenu = cFModMenu = cFViewMenu = cOpenWithMenu = 0; //not created yet
connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(UpdateContextMenu()) );
UpdateIcons();
@@ -138,6 +142,7 @@
ui->tool_zoom_out->setEnabled(px >16); //lower limit on image sizes
}
+ //---------------------------------------------------//
//====================
// Folder Pane
//====================
@@ -152,6 +157,14 @@
return showdirtree;
}
+ /*
+ void DirWidget::on_folderViewPane_clicked(const QModelIndex &index){
+ QString tPath = dirtreeModel->fileInfo(index).absoluteFilePath(); // get what was clicked
+ ChangeDir(tPath);
+ }
+ */
+ //---------------------------------------------------//
+
// ================
// PUBLIC SLOTS
@@ -232,6 +245,7 @@
kCopy= new QShortcut(QKeySequence(QKeySequence::Copy),this);
kPaste= new QShortcut(QKeySequence(QKeySequence::Paste),this);
kRename= new QShortcut(QKeySequence(Qt::Key_F2),this);
+ kExtract= new QShortcut(QKeySequence(Qt::CTRL+Qt::Key_E), this);
kFav= new QShortcut(QKeySequence(Qt::Key_F3),this);
kDel= new QShortcut(QKeySequence(QKeySequence::Delete),this);
kOpSS= new QShortcut(QKeySequence(Qt::Key_F6),this);
@@ -247,6 +261,7 @@
connect(kCopy, SIGNAL(activated()), this, SLOT(copyFiles()) );
connect(kPaste, SIGNAL(activated()), this, SLOT(pasteFiles()) );
connect(kRename, SIGNAL(activated()), this, SLOT(renameFiles()) );
+ connect(kExtract, SIGNAL(activated()), this, SLOT(autoextractfiles()) );
connect(kFav, SIGNAL(activated()), this, SLOT(favoriteFiles()) );
connect(kDel, SIGNAL(activated()), this, SLOT(removeFiles()) );
connect(kOpSS, SIGNAL(activated()), this, SLOT(openInSlideshow()) );
@@ -284,6 +299,38 @@
cFModMenu->addSeparator();
cFModMenu->addAction(LXDG::findIcon("edit-delete",""), tr("Delete Selection"), this, SLOT(removeFiles()), kDel->key() );
*/
+
+ //---------------------------------------------------//
+ /*
+ if(cOpenWithMenu==0){ cOpenWithMenu = new QMenu(this); }
+ else{ cOpenWithMenu->clear(); }
+ cOpenWithMenu->setTitle(tr("Open with..."));
+ cOpenWithMenu->setIcon( LXDG::findIcon("run-build-configure","") );
+ XDGDesktopList applist;
+ applist.updateList();
+ PREFAPPS = getPreferredApplications();
+ //qDebug() << "Preferred Apps:" << PREFAPPS;
+ cOpenWithMenu->clear();
+ //Now get the application mimetype for the file extension (if available)
+ QStringList mimetypes = LXDG::findAppMimeForFile(filePath, true).split("::::"); //use all mimetypes
+ //Now add all the detected applications
+ QHash< QString, QList<XDGDesktop*> > hash = LXDG::sortDesktopCats( applist.apps(false,true) );
+ QStringList cat = hash.keys();
+ cat.sort(); //sort alphabetically
+ for(int c=0; c<cat.length(); c++){
+ QList<XDGDesktop*> app = hash[cat[c]];
+ if(app.length()<1){ cOpenWithMenu =0; continue; }
+ for(int a=0; a<app.length(); a++){
+ QString program = app[a]->filePath;
+ QStringList arguments;
+ arguments << "%u";
+ QProcess *p = new QProcess();
+ p->start(program, arguments);
+
+ cOpenWithMenu->addAction(LXDG::findIcon(app[a]->icon), (app[a]->name), this, SLOT(p->start(program, arguments)) );}}
+ cOpenWithMenu->addAction(LXDG::findIcon("run-build-configure",""), tr("Other..."), this, SLOT(runWithFiles()) );
+ */
+ //---------------------------------------------------//
if(cFViewMenu==0){ cFViewMenu = new QMenu(this); }
else{ cFViewMenu->clear(); }
cFViewMenu->setTitle(tr("View Files..."));
@@ -515,7 +562,7 @@
if(!sel.isEmpty()){
contextMenu->addAction(LXDG::findIcon("system-run",""), tr("Open"), this, SLOT(runFiles()) );
- contextMenu->addAction(LXDG::findIcon("system-run-with",""), tr("Open With..."), this, SLOT(runWithFiles()) );
+ //contextMenu->addAction(LXDG::findIcon("system-run-with",""), tr("Open With..."), this, SLOT(runWithFiles()) );
}
contextMenu->addSection(LXDG::findIcon("unknown",""), tr("File Operations"));
// contextMenu->addMenu(cFModMenu);
@@ -525,6 +572,9 @@
contextMenu->addAction(LXDG::findIcon("edit-rename",""), tr("Rename..."), this, SLOT(renameFiles()), kRename->key() )->setEnabled(canmodify);
contextMenu->addAction(LXDG::findIcon("edit-cut",""), tr("Cut Selection"), this, SLOT(cutFiles()), kCut->key() )->setEnabled(canmodify);
contextMenu->addAction(LXDG::findIcon("edit-copy",""), tr("Copy Selection"), this, SLOT(copyFiles()), kCopy->key() )->setEnabled(canmodify);
+ //---------------------------------------------------//
+ contextMenu->addAction(LXDG::findIcon("archive",""), tr("Auto-Extract"), this, SLOT(autoExtractFiles()), kExtract->key() )->setEnabled(canmodify);
+ //---------------------------------------------------//
}
if( QApplication::clipboard()->mimeData()->hasFormat("x-special/lumina-copied-files") ){
contextMenu->addAction(LXDG::findIcon("edit-paste",""), tr("Paste"), this, SLOT(pasteFiles()), QKeySequence(Qt::CTRL+Qt::Key_V) )->setEnabled(canmodify);
@@ -660,6 +710,38 @@
}*/
// - Selected FILE operations
+
+ //---------------------------------------------------//
+ /*
+ QStringList DirWidget::getPreferredApplications(){
+ QStringList out;
+ //First list all the applications registered for that same mimetype
+ QString mime = fileEXT;
+ out << LXDG::findAvailableAppsForMime(mime);
+
+ //Now search the internal settings for that extension and find any applications last used
+ QStringList keys = settings->allKeys();
+ for(int i=0; i<keys.length(); i++){
+ if(keys[i].startsWith("default/")){ continue; } //ignore the defaults (they will also be in the main)
+ if(keys[i].toLower() == fileEXT.toLower()){
+ QStringList files = settings->value(keys[i]).toString().split(":::");
+ qDebug() << "Found Files:" << keys[i] << files;
+ bool cleaned = false;
+ for(int j=0; j<files.length(); j++){
+ if(QFile::exists(files[j])){ out << files[j]; }
+ else{ files.removeAt(j); j--; cleaned=true; } //file no longer available - remove it
+ }
+ if(cleaned){ settings->setValue(keys[i], files.join(":::")); } //update the registry
+ if(!out.isEmpty()){ break; } //already found files
+ }
+ }
+ //Make sure we don't have any duplicates before we return the list
+ out.removeDuplicates();
+ return out;
+ }
+ */
+ //---------------------------------------------------//
+
void DirWidget::cutFiles(){
QStringList sel = currentBrowser()->currentSelection();
if(sel.isEmpty() || !canmodify){ return; }
@@ -763,6 +845,17 @@
if(!list.isEmpty()){ emit PlayFiles(list); }
}
+ //---------------------------------------------------//
+ void DirWidget::autoExtractFiles(){
+ QProcess *pExtract= new QProcess(this);
+ QString program = "lumina-archiver --ax";
+ QStringList file = currentBrowser()->currentSelection();
+ pExtract->start(program, QStringList() << file);
+
+ }
+ //---------------------------------------------------//
+
+
//====================
// PROTECTED
bgstack15