diff options
author | Ken Moore <ken@pcbsd.org> | 2015-02-27 13:08:32 -0500 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-02-27 13:08:32 -0500 |
commit | e3fc2e3b7c634df819fa75629233e5f319ae6903 (patch) | |
tree | 649f4d5d91a1282e980feecd217bc03ca482d685 /libLumina/LuminaXDG.cpp | |
parent | Have lumina-search load the icons a moment after the application is done init... (diff) | |
download | lumina-e3fc2e3b7c634df819fa75629233e5f319ae6903.tar.gz lumina-e3fc2e3b7c634df819fa75629233e5f319ae6903.tar.bz2 lumina-e3fc2e3b7c634df819fa75629233e5f319ae6903.zip |
Update how lumina-open detects applications which are registered on the system for a particular mimetype. Now it uses the manual method (checking each *.desktop file for that particular mimetype - since it has to load all of them anyway), as well as use the results of any matches in the <XDG_DATA_DIRS>/applications/mimeinfo.cache file.
Diffstat (limited to 'libLumina/LuminaXDG.cpp')
-rw-r--r-- | libLumina/LuminaXDG.cpp | 29 |
1 files changed, 29 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); |