From 5312b9161aa82ec8139c73b5f7dddd269120f15d Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 17 Nov 2017 07:28:08 -0500 Subject: Fix up the visibility of the archive options in lumina-fm. Also fix the OpenWith launching of applications. --- src-qt5/core/libLumina/LuminaXDG.cpp | 8 ++++++-- src-qt5/desktop-utils/lumina-fm/lumina-fm.pro | 2 +- .../desktop-utils/lumina-fm/widgets/DirWidget2.cpp | 22 ++++++++++++++++++---- .../desktop-utils/lumina-fm/widgets/DirWidget2.h | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index 1991a82d..b4954a26 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -237,8 +237,9 @@ QString XDGDesktop::generateExec(QStringList inputfiles, QString ActionID){ //Does the app need the input files in URL or File syntax? bool URLsyntax = (exec.contains("%u") || exec.contains("%U")); //Adjust the input file formats as needed + //qDebug() << "Got inputfiles:" << inputfiles << URLsyntax; for(int i=0; i #include "../ScrollDialog.h" +#include #define DEBUG 0 extern bool rootmode; @@ -86,7 +87,7 @@ DirWidget::DirWidget(QString objID, QSettings *settings, QWidget *parent) : QWid //Now update the rest of the UI canmodify = false; //initial value contextMenu = new QMenu(this); - cNewMenu = cOpenMenu = cFModMenu = cFViewMenu = cOpenWithMenu = 0; //not created yet + cNewMenu = cOpenMenu = cFModMenu = cFViewMenu = cOpenWithMenu = cArchiveMenu =0; //not created yet connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(UpdateContextMenu()) ); connect(ui->splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(splitterMoved()) ); @@ -289,6 +290,11 @@ void DirWidget::createMenus(){ cOpenMenu->addAction(LXDG::findIcon("media-slideshow",""), tr("SlideShow"), this, SLOT(openInSlideshow()), kOpSS->key()); cOpenMenu->addAction(LXDG::findIcon("media-playback-start-circled","media-playback-start"), tr("Multimedia Player"), this, SLOT(openMultimedia()), kOpMM->key()); if(LUtils::isValidBinary("qsudo")){ cOpenMenu->addAction(LXDG::findIcon("", ""), tr("Open Current Dir as Root"), this, SLOT(openRootFM())); + + if(cArchiveMenu==0){ cArchiveMenu = new QMenu(this); } + cArchiveMenu->setTitle(tr("Archive Options")); + cArchiveMenu->setIcon( LXDG::findIcon("utilities-file-archiver","application-x-compressed-tar") ); + /* if(cFModMenu==0){ cFModMenu = new QMenu(this); } else{ cFModMenu->clear(); } @@ -560,9 +566,6 @@ void DirWidget::UpdateContextMenu(){ 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); - if(LUtils::isValidBinary("lumina-archiver") && sel.length() ==1){ contextMenu->addAction(LXDG::findIcon("archive",""), tr("Auto-Extract"), this, SLOT(autoExtractFiles()), kExtract->key() )->setEnabled(canmodify); } - if(LUtils::isValidBinary("lumina-archiver") && sel.length() >=1){ contextMenu->addAction(LXDG::findIcon("archive",""), tr("Auto-Archive"), this, SLOT(autoArchiveFiles()), kArchive->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); @@ -572,6 +575,15 @@ void DirWidget::UpdateContextMenu(){ contextMenu->addAction(LXDG::findIcon("edit-delete",""), tr("Delete Selection"), this, SLOT(removeFiles()), kDel->key() )->setEnabled(canmodify); contextMenu->addSeparator(); } + if(LUtils::isValidBinary("lumina-archiver") && sel.length() >=1 && canmodify){ + cArchiveMenu->clear(); + if(sel.length()==1 && XDGMime::fromFileName(sel[0]).endsWith("-tar") ){ + cArchiveMenu->addAction(LXDG::findIcon("archive",""), tr("Extract Here"), this, SLOT(autoExtractFiles()), kExtract->key() ); + }else{ + cArchiveMenu->addAction(LXDG::findIcon("archive",""), tr("Archive Selection"), this, SLOT(autoArchiveFiles()), kArchive->key() ); + } + contextMenu->addMenu(cArchiveMenu); + } contextMenu->addMenu(cFViewMenu); cFViewMenu->setEnabled(!sel.isEmpty()); @@ -862,6 +874,8 @@ void DirWidget::OpenWithApp(QAction* act){ //Now we need to open the app file, and create the process XDGDesktop desk(act->whatsThis()); QString exec = desk.generateExec(sel); + //qDebug() << "Launch App with selection:" << act->whatsThis() << sel; + //qDebug() << "Generating exec:" << exec; ExternalProcess::launch(exec); } diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h index 5c39d262..a99c64c7 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h @@ -83,7 +83,7 @@ private: QLineEdit *line_dir; //The context menu and associated items - QMenu *contextMenu, *cNewMenu, *cOpenMenu, *cFModMenu, *cFViewMenu, *cOpenWithMenu; + QMenu *contextMenu, *cNewMenu, *cOpenMenu, *cFModMenu, *cFViewMenu, *cOpenWithMenu, *cArchiveMenu; //The keyboard shortcuts for context menu items QShortcut *kZoomIn, *kZoomOut, *kNewFile, *kNewDir, *kNewXDG, *kCut, *kCopy, *kPaste, *kRename, \ -- cgit