aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/libLumina/LuminaXDG.h24
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp94
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h2
3 files changed, 76 insertions, 44 deletions
diff --git a/src-qt5/core/libLumina/LuminaXDG.h b/src-qt5/core/libLumina/LuminaXDG.h
index d159ef43..cc250c7e 100644
--- a/src-qt5/core/libLumina/LuminaXDG.h
+++ b/src-qt5/core/libLumina/LuminaXDG.h
@@ -12,8 +12,6 @@
// *.desktop Exec Compliance Updated: 9/9/2014
// Mime Application Version Compliance: 1.0.1 (11/14/14) (Skips random *.desktop parsing: ~80% compliant)
//===========================================
-
-
#ifndef _LUMINA_LIBRARY_XDG_H
#define _LUMINA_LIBRARY_XDG_H
@@ -83,7 +81,7 @@ public:
bool saveDesktopFile(bool merge = true); //This will use the "filePath" variable for where to save the file
- bool setAutoStarted(bool autostart = true);
+ bool setAutoStarted(bool autostart = true);
};
// ========================
@@ -127,29 +125,29 @@ private:
XDGDesktop *desk;
void loadExtraInfo();
-
+
public:
//Couple overloaded contructors
LFileInfo();
LFileInfo(QString filepath);
LFileInfo(QFileInfo info);
- ~LFileInfo(){
- desk->deleteLater();
+ ~LFileInfo(){
+ desk->deleteLater();
}
-
+
//Functions for accessing the extra information
// -- Return the mimetype for the file
QString mimetype();
-
+
// -- Return the icon file to use for this file
QString iconfile(); //Note: This string is auto-formatted for use in the LXDG::findIcon() routine.
-
+
// -- Check if this is an XDG desktop file
bool isDesktopFile();
-
+
// -- Allow access to the internal XDG desktop data structure
XDGDesktop* XDG();
-
+
//Other file type identification routines
bool isImage(); //Is a readable image file (for thumbnail support)
bool isAVFile(); //Is an audio/video file
@@ -165,7 +163,7 @@ public:
//static XDGDesktop* loadDesktopFile(QString filepath, bool&ok, QObject *parent = 0);
//static bool saveDesktopFile(XDGDesktop *dFile, bool merge = true);
//Check a *.desktop file for validity (showAll skips the DE-exclusivity checks)
- //static bool checkValidity(XDGDesktop *dFile, bool showAll = true);
+ //static bool checkValidity(XDGDesktop *dFile, bool showAll = true);
//Check for a valid executable
static bool checkExec(QString exec);
//Get a list of all the directories where *.desktop files exist
@@ -210,7 +208,7 @@ public:
static QStringList findAVFileExtensions();
//Load all the "globs2" mime database files
static QStringList loadMimeFileGlobs2();
-
+
//Find all the autostart *.desktop files
static QList<XDGDesktop*> findAutoStartFiles(bool includeInvalid = false);
//static bool setAutoStarted(bool autostart, XDGDesktop *app);
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
index 7214dba9..3790d145 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
@@ -295,35 +295,15 @@ void DirWidget::createMenus(){
*/
//---------------------------------------------------//
- /*
- 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(cOpenWithMenu==0){
+ cOpenWithMenu = new QMenu(this);
+ connect(cOpenWithMenu, SIGNAL(triggered(QAction*)), this, SLOT(OpenWithApp(QAction*)) );
+ }
+ else{ cOpenWithMenu->clear(); }
+ cOpenWithMenu->setTitle(tr("Open with..."));
+ cOpenWithMenu->setIcon( LXDG::findIcon("system-run-with","") );
+
//---------------------------------------------------//
if(cFViewMenu==0){ cFViewMenu = new QMenu(this); }
else{ cFViewMenu->clear(); }
@@ -560,7 +540,8 @@ void DirWidget::UpdateContextMenu(){
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->addMenu(cOpenWithMenu);
}
contextMenu->addSection(LXDG::findIcon("unknown",""), tr("File Operations"));
// contextMenu->addMenu(cFModMenu);
@@ -589,6 +570,50 @@ void DirWidget::UpdateContextMenu(){
contextMenu->addMenu(cNewMenu);
}
contextMenu->addMenu(cOpenMenu);
+ //=====================
+ //PREFAPPS = getPreferredApplications();
+ //qDebug() << "Preferred Apps:" << PREFAPPS;
+ cOpenWithMenu->clear();
+ //Now get the application mimetype for the file extension (if available)
+ QStringList mimetypes;
+ for(int i=0; i<sel.length(); i++){
+ QStringList mimes = LXDG::findAppMimeForFile(sel[i], true).split("::::"); //use all mimetypes
+ if(mimetypes.isEmpty()){ mimetypes << mimes; }
+ else{
+ //need to verify that the mimetypes are the same before adding them.
+ QStringList test; test << mimetypes << mimes;
+ if(test.removeDuplicates()>0){ mimetypes = test; }
+ else{
+ //Bad match - incompatible file types are selected - disable the recommendations
+ mimetypes.clear();
+ break;
+ }
+ }
+ }
+ //Now add all the detected applications
+ if(!mimetypes.isEmpty()){
+ static XDGDesktopList applist;
+ applist.updateList();
+ QList<XDGDesktop*> apps = applist.apps(false,true);
+ QList<XDGDesktop*> found;
+ for(int a=0; a<apps.length(); a++){
+ if(apps[a]->mimeList.isEmpty()){ continue; } //no corresponding mime types for this app
+ QStringList test; test << mimetypes << apps[a]->mimeList;
+ if(test.removeDuplicates()>0){ found << apps[a]; }
+ }
+ if(!found.isEmpty()){
+ //sort the apps by name
+ found = LXDG::sortDesktopNames(found);
+ //add apps to the menu
+ for(int i=0; i<found.length(); i++){
+ QAction *act = cOpenWithMenu->addAction( LXDG::findIcon(found[i]->icon, ""), found[i]->name );
+ act->setToolTip(found[i]->comment);
+ act->setWhatsThis(found[i]->filePath);
+ }
+ cOpenWithMenu->addSeparator();
+ }
+ }
+ cOpenWithMenu->addAction(LXDG::findIcon("system-run-with",""), tr("Other..."), this, SLOT(runWithFiles()) );
}
void DirWidget::currentDirectoryChanged(bool widgetonly){
@@ -844,6 +869,15 @@ void DirWidget::openMultimedia(){
if(!list.isEmpty()){ emit PlayFiles(list); }
}
+void DirWidget::OpenWithApp(QAction* act){
+ if(act->whatsThis().isEmpty()){ return; }
+ QStringList sel = currentBrowser()->currentSelection();
+ //Now we need to open the app file, and create the process
+ XDGDesktop desk(act->whatsThis());
+ QString exec = desk.generateExec(sel);
+ ExternalProcess::launch(exec);
+}
+
void DirWidget::autoExtractFiles(){
QStringList files = currentBrowser()->currentSelection();
qDebug() << "Starting auto-extract:" << files;
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
index 284bf337..e1dafaa8 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
@@ -162,7 +162,7 @@ private slots:
// - Context-specific operations
void openInSlideshow();
void openMultimedia();
-
+ void OpenWithApp(QAction*);
signals:
//Directory loading/finding signals
bgstack15