aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/OS-detect.pri7
-rw-r--r--src-qt5/core/libLumina/ExternalProcess.h6
-rw-r--r--src-qt5/core/libLumina/XDGMime.cpp362
-rw-r--r--src-qt5/core/libLumina/XDGMime.h57
-rw-r--r--src-qt5/core/libLumina/XDGMime.pri10
-rw-r--r--src-qt5/core/lumina-desktop-unified/LSession.cpp41
-rw-r--r--src-qt5/core/lumina-desktop-unified/LSession.h4
-rw-r--r--src-qt5/core/lumina-desktop-unified/defaults/desktop/keys.conf4
-rw-r--r--src-qt5/core/lumina-desktop-unified/global-includes.h1
-rw-r--r--src-qt5/core/lumina-desktop-unified/lumina-desktop.pro1
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h2
11 files changed, 484 insertions, 11 deletions
diff --git a/src-qt5/OS-detect.pri b/src-qt5/OS-detect.pri
index eb7fd231..ac195000 100644
--- a/src-qt5/OS-detect.pri
+++ b/src-qt5/OS-detect.pri
@@ -75,7 +75,12 @@ isEmpty(OS){
#Apply any special rules for particular distros
equals(LINUX_DISTRO,"Fedora"){
isEmpty(L_ETCDIR){ L_ETCDIR=/etc }
- }
+ }
+ equals(LINUX_DISTRO,"Gentoo"){
+ isEmpty(L_BINDIR){ L_BINDIR = $${PREFIX}/bin }
+ isEmpty(L_ETCDIR){ L_ETCDIR = $${PREFIX}/../etc }
+ isEmpty(L_MANDIR){ L_MANDIR = $${PREFIX}/share/man }
+ }
}else{
OS="Unknown";
}
diff --git a/src-qt5/core/libLumina/ExternalProcess.h b/src-qt5/core/libLumina/ExternalProcess.h
index a8a5e605..b1e56af8 100644
--- a/src-qt5/core/libLumina/ExternalProcess.h
+++ b/src-qt5/core/libLumina/ExternalProcess.h
@@ -44,7 +44,7 @@ private slots:
}
public:
- ExternalProcess(QString logfile = "", bool manageCursors = true) : QProcess(){
+ ExternalProcess(QString logfile = "", bool manageCursors = false) : QProcess(){
this->setProcessChannelMode(QProcess::MergedChannels);
cursorRestored = !manageCursors;
if(logfile.isEmpty()){
@@ -62,9 +62,9 @@ public:
}*/
}
- static void launch(QString program, QStringList args = QStringList()){
+ static void launch(QString program, QStringList args = QStringList(), bool manageCursors = false){
//Quick launch of a process with logging disabled and automatic cleanup
- ExternalProcess *tmp = new ExternalProcess();
+ ExternalProcess *tmp = new ExternalProcess("", manageCursors);
if(args.isEmpty()){ tmp->start(program); }
else{ tmp->start(program, args); }
}
diff --git a/src-qt5/core/libLumina/XDGMime.cpp b/src-qt5/core/libLumina/XDGMime.cpp
new file mode 100644
index 00000000..3983f6b5
--- /dev/null
+++ b/src-qt5/core/libLumina/XDGMime.cpp
@@ -0,0 +1,362 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2013-2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "XDGMime.h"
+#include <LUtils.h>
+#include <LuminaOS.h>
+
+static QStringList mimeglobs;
+static qint64 mimechecktime;
+
+QString XDGMime::fromFileName(QString filename){
+ //Convert a filename into a mimetype
+ return findAppMimeForFile(filename.section("/",-1),false);
+}
+
+QStringList XDGMime::listFromFileName(QString filename){
+ //Convert a filename into a list of mimetypes (arranged in descending priority)
+ return findAppMimeForFile(filename.section("/",-1),true).split("::::");
+}
+QString XDGMime::toIconName(QString mime){
+ if(!mime.contains("/") || mime.isEmpty() ){ return "unknown"; } //not a mime type
+ //Mime type to icon name
+ mime.replace("/","-"); //translate to icon mime name
+ return mime;
+}
+
+
+QStringList XDGMime::toFileExtensions(QString mime){
+ QStringList out;
+ QStringList mimes = XDGMime::loadMimeFileGlobs2().filter(mime);
+ for(int i=0; i<mimes.length(); i++){
+ out << mimes[i].section(":",2,2); // "*.<extension>"
+ }
+ //qDebug() << "Mime to Files:" << mime << out;
+ return out;
+}
+
+// ====================
+// BACKEND FUNCTIONS
+// ====================
+QStringList XDGMime::systemMimeDirs(){
+ //Returns a list of all the directories where *.xml MIME files can be found
+ QStringList appDirs = QString(getenv("XDG_DATA_HOME")).split(":");
+ appDirs << QString(getenv("XDG_DATA_DIRS")).split(":");
+ if(appDirs.isEmpty()){ appDirs << "/usr/local/share" << "/usr/share"; }
+ //Now create a valid list
+ QStringList out;
+ for(int i=0; i<appDirs.length(); i++){
+ if( QFile::exists(appDirs[i]+"/mime") ){
+ out << appDirs[i]+"/mime";
+ }
+ }
+ return out;
+}
+
+QString XDGMime::findAppMimeForFile(QString filename, bool multiple){
+ QString out;
+ QString extension = filename.section(".",1,-1);
+ if("."+extension == filename){ extension.clear(); } //hidden file without extension
+ //qDebug() << "MIME SEARCH:" << filename << extension;
+ QStringList mimefull = XDGMime::loadMimeFileGlobs2();
+ QStringList mimes;
+ //Just in case the filename is a mimetype itself
+ if( mimefull.filter(":"+filename+":").length() == 1){
+ return filename;
+ }
+while(mimes.isEmpty()){
+ //Check for an exact mimetype match
+ if(mimefull.filter(":"+extension+":").length() == 1){
+ return extension;
+ }
+ //Look for globs at the end of the filename
+ if(!extension.isEmpty()){
+ mimes = mimefull.filter(":*."+extension);
+ //If nothing found, try a case-insensitive search
+ if(mimes.isEmpty()){ mimes = mimefull.filter(":*."+extension, Qt::CaseInsensitive); }
+ //Now ensure that the filter was accurate (*.<extention>.<something> will still be caught)
+ for(int i=0; i<mimes.length(); i++){
+ if(!filename.endsWith( mimes[i].section(":*",-1), Qt::CaseInsensitive )){ mimes.removeAt(i); i--; }
+ else if(mimes[i].section(":",0,0).length()==2){ mimes[i].prepend("0"); } //ensure 3-character priority number
+ else if(mimes[i].section(":",0,0).length()==1){ mimes[i].prepend("00"); } //ensure 3-character priority number
+ }
+ }
+ //Look for globs at the start of the filename
+ if(mimes.isEmpty()){
+ mimes = mimefull.filter(":"+filename.left(2)); //look for the first 2 characters initially
+ //Note: This initial filter will only work if the wildcard (*) is not within the first 2 characters of the pattern
+ //Now ensure that the filter was accurate
+ for(int i=0; i<mimes.length(); i++){
+ if(!filename.startsWith( mimes[i].section(":",3,-1,QString::SectionSkipEmpty).section("*",0,0), Qt::CaseInsensitive )){ mimes.removeAt(i); i--; }
+ }
+ }
+ if(mimes.isEmpty()){
+ if(extension.contains(".")){ extension = extension.section(".",1,-1); }
+ else{ break; }
+ }
+ } //end of mimes while loop
+ mimes.sort(); //this automatically puts them in reverse weight order (100 on down)
+ QStringList matches;
+ //qDebug() << "Mimes:" << mimes;
+ for(int m=mimes.length()-1; m>=0; m--){
+ QString mime = mimes[m].section(":",1,1,QString::SectionSkipEmpty);
+ matches << mime;
+ }
+ //qDebug() << "Matches:" << matches;
+ if(multiple && !matches.isEmpty() ){ out = matches.join("::::"); }
+ else if( !matches.isEmpty() ){ out = matches.first(); }
+ else{ //no mimetype found - assign one (internal only - no system database changes)
+ if(extension.isEmpty()){ out = "unknown/"+filename.toLower(); }
+ else{ out = "unknown/"+extension.toLower(); }
+ }
+ //qDebug() << "Out:" << out;
+ return out;
+}
+
+QStringList XDGMime::listFileMimeDefaults(){
+ //This will spit out a itemized list of all the mimetypes and relevant info
+ // Output format: <mimetype>::::<extension>::::<default>::::<localized comment>
+ QStringList mimes = XDGMime::loadMimeFileGlobs2();
+ //Now start filling the output list
+ QStringList out;
+ for(int i=0; i<mimes.length(); i++){
+ QString mimetype = mimes[i].section(":",1,1);
+ QStringList tmp = mimes.filter(mimetype);
+ //Collect all the different extensions with this mimetype
+ QStringList extlist;
+ for(int j=0; j<tmp.length(); j++){
+ mimes.removeAll(tmp[j]);
+ extlist << tmp[j].section(":",2,2);
+ }
+ extlist.removeDuplicates(); //just in case
+ //Now look for a current default for this mimetype
+ QString dapp = XDGMime::findDefaultAppForMime(mimetype); //default app;
+
+ //Create the output entry
+ //qDebug() << "Mime entry:" << i << mimetype << dapp;
+ out << mimetype+"::::"+extlist.join(", ")+"::::"+dapp+"::::"+XDGMime::findMimeComment(mimetype);
+
+ i--; //go back one (continue until the list is empty)
+ }
+ return out;
+}
+
+QString XDGMime::findMimeComment(QString mime){
+ QString comment;
+ QStringList dirs = XDGMime::systemMimeDirs();
+ QString lang = QString(getenv("LANG")).section(".",0,0);
+ QString shortlang = lang.section("_",0,0);
+ for(int i=0; i<dirs.length(); i++){
+ if(QFile::exists(dirs[i]+"/"+mime+".xml")){
+ QStringList info = LUtils::readFile(dirs[i]+"/"+mime+".xml");
+ QStringList filter = info.filter("<comment xml:lang=\""+lang+"\">");
+ //First look for a full language match, then short language, then general comment
+ if(filter.isEmpty()){ filter = info.filter("<comment xml:lang=\""+shortlang+"\">"); }
+ if(filter.isEmpty()){ filter = info.filter("<comment>"); }
+ if(!filter.isEmpty()){
+ comment = filter.first().section(">",1,1).section("</",0,0);
+ break;
+ }
+ }
+ }
+ return comment;
+}
+
+QString XDGMime::findDefaultAppForMime(QString mime){
+ //First get the priority-ordered list of default file locations
+ QStringList dirs;
+ dirs << QString(getenv("XDG_CONFIG_HOME"))+"/lumina-mimeapps.list" \
+ << QString(getenv("XDG_CONFIG_HOME"))+"/mimeapps.list";
+ QStringList tmp = QString(getenv("XDG_CONFIG_DIRS")).split(":");
+ for(int i=0; i<tmp.length(); i++){ dirs << tmp[i]+"/lumina-mimeapps.list"; }
+ for(int i=0; i<tmp.length(); i++){ dirs << tmp[i]+"/mimeapps.list"; }
+ dirs << QString(getenv("XDG_DATA_HOME"))+"/applications/lumina-mimeapps.list" \
+ << QString(getenv("XDG_DATA_HOME"))+"/applications/mimeapps.list";
+ tmp = QString(getenv("XDG_DATA_DIRS")).split(":");
+ for(int i=0; i<tmp.length(); i++){ dirs << tmp[i]+"/applications/lumina-mimeapps.list"; }
+ for(int i=0; i<tmp.length(); i++){ dirs << tmp[i]+"/applications/mimeapps.list"; }
+
+ //Now go through all the files in order of priority until a default is found
+ QString cdefault;
+ for(int i=0; i<dirs.length() && cdefault.isEmpty(); i++){
+ if(!QFile::exists(dirs[i])){ continue; }
+ QStringList info = LUtils::readFile(dirs[i]);
+ if(info.isEmpty()){ continue; }
+ QStringList white; //lists to keep track of during the search (black unused at the moment)
+ QString workdir = dirs[i].section("/",0,-2); //just the directory
+ // qDebug() << "Check File:" << mime << dirs[i] << workdir;
+ int def = info.indexOf("[Default Applications]"); //find this line to start on
+ if(def>=0){
+ for(int d=def+1; d<info.length(); d++){
+ //qDebug() << "Check Line:" << info[d];
+ if(info[d].startsWith("[")){ break; } //starting a new section now - finished with defaults
+ if(info[d].contains(mime+"=") ){
+ white = info[d].section("=",1,-1).split(";") + white; //exact mime match - put at front of list
+ break; //already found exact match
+ }else if(info[d].contains("*") && info[d].contains("=") ){
+ QRegExp rg(info[d].section("=",0,0), Qt::CaseSensitive, QRegExp::WildcardUnix);
+ if(rg.exactMatch(mime)){
+ white << info[d].section("=",1,-1).split(";"); //partial mime match - put at end of list
+ }
+ }
+ }
+ }
+ // Now check for any white-listed files in this work dir
+ // find the full path to the file (should run even if nothing in this file)
+ //qDebug() << "WhiteList:" << white;
+ for(int w=0; w<white.length(); w++){
+ if(white[w].isEmpty()){ continue; }
+ //First check for absolute paths to *.desktop file
+ if( white[w].startsWith("/") ){
+ if( QFile::exists(white[w]) ){ cdefault=white[w]; break; }
+ else{ white.removeAt(w); w--; } //invalid file path - remove it from the list
+ }
+ //Now check for relative paths to file (in current priority-ordered work dir)
+ else if( QFile::exists(workdir+"/"+white[w]) ){ cdefault=workdir+"/"+white[w]; break; }
+ //Now go through the XDG DATA dirs and see if the file is in there
+ else{
+ white[w] = LUtils::AppToAbsolute(white[w]);
+ if(QFile::exists(white[w])){ cdefault = white[w]; }
+ }
+ }
+ /* WRITTEN BUT UNUSED CODE FOR MIMETYPE ASSOCIATIONS
+ //Skip using this because it is simply an alternate/unsupported standard that conflicts with
+ the current mimetype database standards. It is better/faster to parse 1 or 2 database glob files
+ rather than have to iterate through hundreds of *.desktop files *every* time you need to
+ find an application
+
+ if(addI<0 && remI<0){
+ //Simple Format: <mimetype>=<*.desktop file>;<*.desktop file>;.....
+ // (usually only one desktop file listed)
+ info = info.filter(mimetype+"=");
+ //Load the listed default(s)
+ for(int w=0; w<info.length(); w++){
+ white << info[w].section("=",1,50).split(";");
+ }
+ }else{
+ //Non-desktop specific mimetypes file: has a *very* convoluted/inefficient algorithm (required by spec)
+ if(addI<0){ addI = info.length(); } //no add section
+ if(remI<0){ remI = info.length(); } // no remove section:
+ //Whitelist items
+ for(int a=addI+1; a!=remI && a<info.length(); a++){
+ if(info[a].contains(mimetype+"=")){
+ QStringList tmp = info[a].section("=",1,50).split(";");
+ for(int t=0; t<tmp.length(); t++){
+ if(!black.contains(tmp[t])){ white << tmp[t]; } //make sure this item is not on the black list
+ }
+ break;
+ }
+ }
+ //Blacklist items
+ for(int a=remI+1; a!=addI && a<info.length(); a++){
+ if(info[a].contains(mimetype+"=")){ black << info[a].section("=",1,50).split(";"); break;}
+ }
+
+ //STEPS 3/4 not written yet
+
+ } //End of non-DE mimetypes file */
+
+ } //End loop over file
+ return cdefault;
+}
+
+QStringList XDGMime::findAvailableAppsForMime(QString mime){
+ QStringList dirs = LUtils::systemApplicationDirs();
+ QStringList out;
+ //Loop over all possible directories that contain *.destop files
+ // and check for the mimeinfo.cache file
+ for(int i=0; i<dirs.length(); i++){
+ if(QFile::exists(dirs[i]+"/mimeinfo.cache")){
+ QStringList matches = LUtils::readFile(dirs[i]+"/mimeinfo.cache").filter(mime+"=");
+ //Find any matches for our mimetype in the cache
+ for(int j=0; j<matches.length(); j++){
+ QStringList files = matches[j].section("=",1,1).split(";",QString::SkipEmptyParts);
+ //Verify that each file exists before putting the full path to the file in the output
+ for(int m=0; m<files.length(); m++){
+ if(QFile::exists(dirs[i]+"/"+files[m])){
+ out << dirs[i]+"/"+files[m];
+ }else if(files[m].contains("-")){ //kde4-<filename> -> kde4/<filename> (stupid KDE variations!!)
+ files[m].replace("-","/");
+ if(QFile::exists(dirs[i]+"/"+files[m])){
+ out << dirs[i]+"/"+files[m];
+ }
+ }
+ }
+ }
+ }
+ }
+ //qDebug() << "Found Apps for Mime:" << mime << out << dirs;
+ return out;
+}
+
+void XDGMime::setDefaultAppForMime(QString mime, QString app){
+ QString filepath = QString(getenv("XDG_CONFIG_HOME"))+"/lumina-mimeapps.list";
+ QStringList cinfo = LUtils::readFile(filepath);
+ //If this is a new file, make sure to add the header appropriately
+ if(cinfo.isEmpty()){ cinfo << "#Automatically generated with lumina-config" << "# DO NOT CHANGE MANUALLY" << "[Default Applications]"; }
+ //Check for any current entry for this mime type
+ QStringList tmp = cinfo.filter(mime+"=");
+ int index = -1;
+ if(!tmp.isEmpty()){ index = cinfo.indexOf(tmp.first()); }
+ //Now add the new default entry (if necessary)
+ if(app.isEmpty()){
+ if(index>=0){ cinfo.removeAt(index); } //Remove entry
+ }else{
+ if(index<0){
+ cinfo << mime+"="+app+";"; //new entry
+ }else{
+ cinfo[index] = mime+"="+app+";"; //overwrite existing entry
+ }
+ }
+ LUtils::writeFile(filepath, cinfo, true);
+ return;
+}
+
+QStringList XDGMime::findAVFileExtensions(){
+ //output format: QDir name filter for valid A/V file extensions
+ QStringList globs = XDGMime::loadMimeFileGlobs2();
+ QStringList av = globs.filter(":audio/");
+ av << globs.filter(":video/");
+ for(int i=0; i<av.length(); i++){
+ //Just use all audio/video mimetypes (for now)
+ av[i] = av[i].section(":",2,2);
+ //Qt5 Auto detection (broken - QMediaPlayer seg faults with Qt 5.3 - 11/24/14)
+ /*if( QMultimedia::NotSupported != QMediaPlayer::hasSupport(av[i].section(":",1,1)) ){ av[i] = av[i].section(":",2,2); }
+ else{ av.removeAt(i); i--; }*/
+ }
+ av.removeDuplicates();
+ return av;
+}
+
+QStringList XDGMime::loadMimeFileGlobs2(){
+ //output format: <weight>:<mime type>:<file extension (*.something)>
+ if(mimeglobs.isEmpty() || (mimechecktime < (QDateTime::currentMSecsSinceEpoch()-30000)) ){
+ //qDebug() << "Loading globs2 mime DB files";
+ mimeglobs.clear();
+ mimechecktime = QDateTime::currentMSecsSinceEpoch(); //save the current time this was last checked
+ QStringList dirs = XDGMime::systemMimeDirs();
+ for(int i=0; i<dirs.length(); i++){
+ if(QFile::exists(dirs[i]+"/globs2")){
+ QFile file(dirs[i]+"/globs2");
+ if(!file.exists()){ continue; }
+ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ continue; }
+ QTextStream in(&file);
+ while(!in.atEnd()){
+ QString line = in.readLine();
+ if(!line.startsWith("#")){
+ mimeglobs << line.simplified();
+ }
+ }
+ file.close();
+ }
+ if(i==dirs.length()-1 && mimeglobs.isEmpty()){
+ //Could not find the mimetype database on the system - use the fallback file distributed with Lumina
+ if(dirs.last()!= LOS::LuminaShare()){ dirs << LOS::LuminaShare(); } //just in case it was not installed
+ }
+ }//end loop over dirs
+ }
+ return mimeglobs;
+}
diff --git a/src-qt5/core/libLumina/XDGMime.h b/src-qt5/core/libLumina/XDGMime.h
new file mode 100644
index 00000000..a8d91142
--- /dev/null
+++ b/src-qt5/core/libLumina/XDGMime.h
@@ -0,0 +1,57 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2013-2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// These structures/classes are for conforming to the FreeDesktop standards
+// REFERENCE:
+// (DATABASE) https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/
+// (APPLICATIONS) https://www.freedesktop.org/wiki/Specifications/mime-apps-spec/
+// Mime Application Version Compliance: 1.0.1 (11/14/14) (Skips random *.desktop parsing: ~80% compliant)
+//===========================================
+#ifndef _LUMINA_LIBRARY_XDG_MIME_CLASS_H
+#define _LUMINA_LIBRARY_XDG_MIME_CLASS_H
+
+#include <QFile>
+#include <QDir>
+#include <QFileInfo>
+#include <QStringList>
+#include <QString>
+#include <QList>
+#include <QDateTime>
+#include <QTextStream>
+#include <QRegExp>
+#include <QDebug>
+
+class XDGMime{
+public:
+ // PRIMARY FUNCTIONS
+ static QString fromFileName(QString filename); //Convert a filename into a mimetype
+ static QStringList listFromFileName(QString filename); //Convert a filename into a list of mimetypes (arranged in descending priority)
+ static QString toIconName(QString mime); //Mime type to icon name
+ //Find the file extension for a particular mime-type
+ static QStringList toFileExtensions(QString mime);
+
+ // LESSER-USED FUNCTIONS
+ //List all the mime-type directories
+ static QStringList systemMimeDirs();
+ //Find the mime-type of a particular file extension
+ static QString findAppMimeForFile(QString filename, bool multiple = false);
+ // Simplification function for finding all info regarding current mime defaults
+ static QStringList listFileMimeDefaults();
+ //Find the localized comment string for a particular mime-type
+ static QString findMimeComment(QString mime);
+ //Find the default application for a mime-type
+ static QString findDefaultAppForMime(QString mime);
+ //Fine the available applications for a mime-type
+ static QStringList findAvailableAppsForMime(QString mime);
+ //Set the default application for a mime-type
+ static void setDefaultAppForMime(QString mime, QString app);
+ //List all the registered audio/video file extensions
+ static QStringList findAVFileExtensions();
+ //Load all the "globs2" mime database files
+ static QStringList loadMimeFileGlobs2();
+
+};
+#endif
diff --git a/src-qt5/core/libLumina/XDGMime.pri b/src-qt5/core/libLumina/XDGMime.pri
new file mode 100644
index 00000000..f7cb8b6d
--- /dev/null
+++ b/src-qt5/core/libLumina/XDGMime.pri
@@ -0,0 +1,10 @@
+#QT *= multimedia svg
+
+#XDG Mime Files
+SOURCES *= $${PWD}/XDGMime.cpp
+HEADERS *= $${PWD}/XDGMime.h
+
+INCLUDEPATH *= ${PWD}
+
+#include LUtils and LuminaOS
+include(LUtils.pri)
diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp
index 60ed1a39..c6f79584 100644
--- a/src-qt5/core/lumina-desktop-unified/LSession.cpp
+++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp
@@ -381,11 +381,46 @@ void LSession::StartReboot(bool skipupdates){
QCoreApplication::exit(0);
}
-void LSession::LaunchApplication(QString app){
-
+void LSession::LaunchApplication(QString exec){
+ ExternalProcess::launch(exec);
}
-void LSession::LaunchStandardApplication(QString app){
+void LSession::LaunchStandardApplication(QString app, QStringList args){
+ //Find/replace standardized apps with thier mimetypes
+ if(app.startsWith("--")){ app = "application/"+app.section("--",-1).simplified(); }
+ //First see if this is a mimetype with a default application
+ if(app.count("/")==1 && !app.startsWith("/")){
+ QString mimeapp = XDGMime::findDefaultAppForMime(app);
+ if(!mimeapp.isEmpty()){ app = mimeapp; }
+ }
+ if(app.endsWith(".desktop")){
+ //Get the XDGDesktop structure
+ XDGDesktop *desk = 0; bool cleanup = false;
+ if(app.startsWith("/") && QFile::exists(app)){ desk = new XDGDesktop(app); cleanup = true; }
+ if(!desk->isValid()){
+ //Need to find the app within the current list
+ QHash<QString, XDGDesktop*>applist = Lumina::APPLIST->files;
+ if(cleanup){ desk->deleteLater(); desk = 0; cleanup = false; }
+ app = app.section("/",-1); //make sure this is a relative path
+ QStringList list = applist.keys().filter("/"+app);
+ if(!list.filter(QDir::homePath()).isEmpty()){ desk = applist[list.filter(QDir::homePath()).first()]; } //prefer user-override files
+ if(desk==0 || !desk->isValid()){
+ desk = 0;
+ for(int i=0; i<list.length() && desk==0; i++){
+ XDGDesktop *tmp = applist[list[i]];
+ if(tmp->isValid()){ desk = tmp; }
+ }
+ }
+ }
+ if(desk!=0 && desk->isValid()){
+ //Got the application - go ahead and assemble the startup command
+ QString exec = desk->generateExec(args); //args are embedded into the exec command as needed
+ ExternalProcess::launch(exec, QStringList(), desk->startupNotify);
+ }
+ if(cleanup){ desk->deleteLater(); }
+ }else{
+ ExternalProcess::launch(app, args, false); // do not use startup notify cursor
+ }
}
diff --git a/src-qt5/core/lumina-desktop-unified/LSession.h b/src-qt5/core/lumina-desktop-unified/LSession.h
index 0d666bfa..85cc050c 100644
--- a/src-qt5/core/lumina-desktop-unified/LSession.h
+++ b/src-qt5/core/lumina-desktop-unified/LSession.h
@@ -32,8 +32,8 @@ public slots:
void StartLogout();
void StartShutdown(bool skipupdates = false);
void StartReboot(bool skipupdates = false);
- void LaunchApplication(QString app);
- void LaunchStandardApplication(QString app);
+ void LaunchApplication(QString exec);
+ void LaunchStandardApplication(QString app, QStringList args = QStringList());
void reloadIconTheme(); //will emit the IconThemeChanged signal when ready
void switchLocale(QString localeCode); //will emit the LocaleChanged signal when ready
diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/keys.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/keys.conf
index c1417b85..59959194 100644
--- a/src-qt5/core/lumina-desktop-unified/defaults/desktop/keys.conf
+++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/keys.conf
@@ -4,5 +4,5 @@ Pause=Lockscreen
Alt+L=Lockscreen
[desktop]
-Alt+F1=Launch: terminal
-Print=Launch: screenshot
+Alt+F1=Launch: --terminal
+Print=Launch: --screenshot
diff --git a/src-qt5/core/lumina-desktop-unified/global-includes.h b/src-qt5/core/lumina-desktop-unified/global-includes.h
index 1d0ab068..92f895c2 100644
--- a/src-qt5/core/lumina-desktop-unified/global-includes.h
+++ b/src-qt5/core/lumina-desktop-unified/global-includes.h
@@ -62,6 +62,7 @@
#include <NativeWindow.h>
#include <NativeWindowSystem.h>
#include <NativeEventFilter.h>
+#include <XDGMime.h>
// Standard C includes
#include <unistd.h>
diff --git a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
index defa66f4..79f2ba6f 100644
--- a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
+++ b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
@@ -19,6 +19,7 @@ include(../libLumina/DesktopSettings.pri)
include(../libLumina/RootWindow.pri)
include(../libLumina/ExternalProcess.pri)
include(../libLumina/NativeWindow.pri)
+include(../libLumina/XDGMime.pri)
#include all the main individual source groups
include(src-screensaver/screensaver.pri)
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h
index 1e3165ec..7fd21967 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h
@@ -32,6 +32,8 @@ private slots:
signals:
void LockSession();
void showLeaveDialog();
+ void LaunchStandardApplication(QString);
+ void LaunchApplication(QString);
};
#endif
bgstack15