aboutsummaryrefslogtreecommitdiff
path: root/libLumina
diff options
context:
space:
mode:
authorwilliam os4y <william.os4y@gmail.com>2015-03-02 10:02:47 +0100
committerwilliam os4y <william.os4y@gmail.com>2015-03-02 10:02:47 +0100
commitf8221bd9482a3d14179653e27383069b014b6903 (patch)
tree99df35cd86bfc40712f4f4a3020a2c470acd5b58 /libLumina
parentdisplay Items count in the bottom bar (diff)
parentUpdate how lumina-open detects applications which are registered on the syste... (diff)
downloadlumina-f8221bd9482a3d14179653e27383069b014b6903.tar.gz
lumina-f8221bd9482a3d14179653e27383069b014b6903.tar.bz2
lumina-f8221bd9482a3d14179653e27383069b014b6903.zip
Merge remote-tracking branch 'upstream/master' into fmNumbers
Diffstat (limited to 'libLumina')
-rw-r--r--libLumina/LuminaXDG.cpp29
-rw-r--r--libLumina/LuminaXDG.h2
2 files changed, 31 insertions, 0 deletions
diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp
index 3ec16887..27b3b637 100644
--- a/libLumina/LuminaXDG.cpp
+++ b/libLumina/LuminaXDG.cpp
@@ -569,6 +569,35 @@ QString LXDG::findDefaultAppForMime(QString mime){
return cdefault;
}
+QStringList LXDG::findAvailableAppsForMime(QString mime){
+ QStringList dirs = LXDG::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 LXDG::setDefaultAppForMime(QString mime, QString app){
QString filepath = QString(getenv("XDG_CONFIG_HOME"))+"/lumina-mimeapps.list";
QStringList cinfo = LUtils::readFile(filepath);
diff --git a/libLumina/LuminaXDG.h b/libLumina/LuminaXDG.h
index ad09d490..fe44a4fd 100644
--- a/libLumina/LuminaXDG.h
+++ b/libLumina/LuminaXDG.h
@@ -91,6 +91,8 @@ public:
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
bgstack15