From e22ce7dfc13348560af6b1d04d935dbc1358e2ce Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 21 Jul 2017 13:52:32 -0400 Subject: Start adding the application launch functionality to the session (untested) --- src-qt5/core/libLumina/ExternalProcess.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src-qt5/core/libLumina') 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); } } -- cgit From 003e1374d38ccd1a1ebb2296f191ac9a3b7efa48 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 21 Jul 2017 13:53:07 -0400 Subject: Add a new "XDGMime" class/files which can be used for non-graphical mimetype interactions --- src-qt5/core/libLumina/XDGMime.cpp | 362 +++++++++++++++++++++++++++++++++++++ src-qt5/core/libLumina/XDGMime.h | 57 ++++++ src-qt5/core/libLumina/XDGMime.pri | 10 + 3 files changed, 429 insertions(+) create mode 100644 src-qt5/core/libLumina/XDGMime.cpp create mode 100644 src-qt5/core/libLumina/XDGMime.h create mode 100644 src-qt5/core/libLumina/XDGMime.pri (limited to 'src-qt5/core/libLumina') 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 +#include + +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" + } + //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