From 08fbc54ef9b30f5db1eea4ffbb4cbf6e3e52d99f Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 17 Nov 2014 18:53:12 -0500 Subject: 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. --- libLumina/LuminaXDG.cpp | 14 ++++++++++++-- libLumina/LuminaXDG.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'libLumina') 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 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 -- cgit