aboutsummaryrefslogtreecommitdiff
path: root/libLumina/LuminaXDG.cpp
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2014-11-17 18:53:12 -0500
committerKen Moore <moorekou@gmail.com>2014-11-17 18:53:12 -0500
commit08fbc54ef9b30f5db1eea4ffbb4cbf6e3e52d99f (patch)
treefac7027b2a0b413f3e7b8662dd95f0aa96ef4341 /libLumina/LuminaXDG.cpp
parentUpdate the XDG MIME inplementation to support the draft standards for registe... (diff)
downloadlumina-08fbc54ef9b30f5db1eea4ffbb4cbf6e3e52d99f.tar.gz
lumina-08fbc54ef9b30f5db1eea4ffbb4cbf6e3e52d99f.tar.bz2
lumina-08fbc54ef9b30f5db1eea4ffbb4cbf6e3e52d99f.zip
Finish up the new Mime type default app usage in lumina-config and lumina-open. The new buttons in lumina config set the backends fine, but the file manager/terminal options will not be respected yet until I update the menu plugins in lumina-desktop.
Diffstat (limited to 'libLumina/LuminaXDG.cpp')
-rw-r--r--libLumina/LuminaXDG.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp
index 802722d4..057954dd 100644
--- a/libLumina/LuminaXDG.cpp
+++ b/libLumina/LuminaXDG.cpp
@@ -364,16 +364,26 @@ QIcon LXDG::findMimeIcon(QString extension){
return ico;
}
-QString LXDG::findAppMimeForFile(QString extension){
+QString LXDG::findAppMimeForFile(QString filename, bool multiple){
QString out;
+ QString extension = filename.section(".",-1);
+ if("."+extension == filename){ extension.clear(); } //hidden file without extension
int weight = 0;
- QStringList mimes = LXDG::loadMimeFileGlobs2().filter(":*."+extension);
+ QStringList mimefull = LXDG::loadMimeFileGlobs2();
+ QStringList mimes;
+ if(!extension.isEmpty()){ mimes = mimefull.filter(":*."+extension); }
+ if(mimes.isEmpty()){ mimes = mimefull.filter(":"+filename.left(3)); } //look for the first 3 characters only (FIX WILDCARD DETECTION LATER)
+ mimes.sort();
+ QStringList matches;
for(int m=0; m<mimes.length(); m++){
QString mime = mimes[m].section(":",1,1,QString::SectionSkipEmpty);
+ if(mime.endsWith("/"+extension)){ matches.prepend(mime); } //exact match
+ else{ matches << mime; }
if(mimes[m].section(":",0,0,QString::SectionSkipEmpty).toInt() > weight ){
out = mime;
}
}
+ if(multiple){ out = matches.join("::::"); }
return out;
}
bgstack15