aboutsummaryrefslogtreecommitdiff
path: root/libLumina
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
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')
-rw-r--r--libLumina/LuminaXDG.cpp14
-rw-r--r--libLumina/LuminaXDG.h2
2 files changed, 13 insertions, 3 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;
}
diff --git a/libLumina/LuminaXDG.h b/libLumina/LuminaXDG.h
index 079ccd3a..ec994820 100644
--- a/libLumina/LuminaXDG.h
+++ b/libLumina/LuminaXDG.h
@@ -82,7 +82,7 @@ public:
//Find the mime-type icon for a particular file extension
static QIcon findMimeIcon(QString extension);
//Find the mime-type of a particular file extension
- static QString findAppMimeForFile(QString extension);
+ static QString findAppMimeForFile(QString filename, bool multiple = false);
//Find the file extension for a particular mime-type
static QStringList findFilesForMime(QString mime);
// Simplification function for finding all info regarding current mime defaults
bgstack15