diff options
author | Ken Moore <ken@pcbsd.org> | 2014-11-14 12:14:03 -0500 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2014-11-14 12:14:03 -0500 |
commit | f0e09f3d0fe234eb1748d7c6f94c6ddfc37fe6cc (patch) | |
tree | 1a58e7518a782df4a8ca78c6c4e56a185e02edb3 /libLumina | |
parent | Add detection/conversion of relative file paths to absolute file paths within... (diff) | |
download | lumina-f0e09f3d0fe234eb1748d7c6f94c6ddfc37fe6cc.tar.gz lumina-f0e09f3d0fe234eb1748d7c6f94c6ddfc37fe6cc.tar.bz2 lumina-f0e09f3d0fe234eb1748d7c6f94c6ddfc37fe6cc.zip |
Update the XDG categories that are supported, as well as the add a new "Wine" category for internal recognition/use (since the wine apps do not usually list a category in the *.desktop file).
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaUtils.cpp | 14 | ||||
-rw-r--r-- | libLumina/LuminaUtils.h | 4 | ||||
-rw-r--r-- | libLumina/LuminaXDG.cpp | 15 |
3 files changed, 29 insertions, 4 deletions
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 6f91082c..830cfc97 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -78,3 +78,17 @@ bool LUtils::isValidBinary(QString bin){ QFileInfo info(bin); return (info.exists() && info.isExecutable()); } + +QStringList LUtils::listSubDirectories(QString dir, bool recursive){ + //This is a recursive method for returning the full paths of all subdirectories (if recursive flag is enabled) + QDir maindir(dir); + QStringList out; + QStringList subs = maindir.entryList(QDir::NoDotAndDotDot | QDir::Dirs, QDir::Name); + for(int i=0; i<subs.length(); i++){ + out << maindir.absoluteFilePath(subs[i]); + if(recursive){ + out << LUtils::listSubDirectories(maindir.absoluteFilePath(subs[i]), recursive); + } + } + return out; +}
\ No newline at end of file diff --git a/libLumina/LuminaUtils.h b/libLumina/LuminaUtils.h index a9a107a5..44bec991 100644 --- a/libLumina/LuminaUtils.h +++ b/libLumina/LuminaUtils.h @@ -11,6 +11,7 @@ #include <QProcess> #include <QTextStream> #include <QFile> +#include <QDir> #include <QString> #include <QStringList> #include <QFile> @@ -30,6 +31,9 @@ public: //Check whether a file/path is a valid binary static bool isValidBinary(QString bin); //full path or name only + + //List all the sub-directories of a parent dir (recursive) + static QStringList listSubDirectories(QString dir, bool recursive = true); }; #endif diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp index c5ceadfd..e7678d1f 100644 --- a/libLumina/LuminaXDG.cpp +++ b/libLumina/LuminaXDG.cpp @@ -88,6 +88,10 @@ XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){ if(!DF.showInList.isEmpty()){ DF.name.append(" ("+DF.showInList.join(", ")+")"); } + //Quick fix for showing "wine" applications (which quite often don't list a category) + if(DF.catList.isEmpty() && filePath.contains("/wine/")){ + DF.catList << "Wine"; //Internal Lumina category only (not in XDG specs as of 11/14/14) + } //Return the structure ok=true; return DF; @@ -150,10 +154,11 @@ QStringList LXDG::systemApplicationDirs(){ out << appDirs[i]+"/applications"; //Also check any subdirs within this directory // (looking at you KDE - stick to the standards!!) - QDir dir(appDirs[i]+"/applications"); - QStringList subs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + out << LUtils::listSubDirectories(appDirs[i]+"/applications"); + //QDir dir(appDirs[i]+"/applications"); + //QStringList subs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); //qDebug() << "Adding subdirectories:" << appDirs[i]+"/applications/["+subs.join(", ")+"]"; - for(int s=0; s<subs.length(); s++){ out << dir.absoluteFilePath(subs[s]); } + //for(int s=0; s<subs.length(); s++){ out << dir.absoluteFilePath(subs[s]); } } } return out; @@ -185,7 +190,7 @@ QList<XDGDesktop> LXDG::systemDesktopFiles(bool showAll, bool showHidden){ QHash<QString,QList<XDGDesktop> > LXDG::sortDesktopCats(QList<XDGDesktop> apps){ //Sort the list of applications into their different categories (main categories only) //Create the category lists - QList<XDGDesktop> multimedia, dev, ed, game, graphics, network, office, science, settings, sys, utility, other; + QList<XDGDesktop> multimedia, dev, ed, game, graphics, network, office, science, settings, sys, utility, other, wine; //Sort the apps into the lists for(int i=0; i<apps.length(); i++){ if(apps[i].catList.contains("AudioVideo")){ multimedia << apps[i]; } @@ -199,6 +204,7 @@ QHash<QString,QList<XDGDesktop> > LXDG::sortDesktopCats(QList<XDGDesktop> apps){ else if(apps[i].catList.contains("Settings")){ settings << apps[i]; } else if(apps[i].catList.contains("System")){ sys << apps[i]; } else if(apps[i].catList.contains("Utility")){ utility << apps[i]; } + else if(apps[i].catList.contains("Wine")){ wine << apps[i]; } else{ other << apps[i]; } } //Now create the output hash @@ -214,6 +220,7 @@ QHash<QString,QList<XDGDesktop> > LXDG::sortDesktopCats(QList<XDGDesktop> apps){ if(!settings.isEmpty()){ out.insert("Settings", LXDG::sortDesktopNames(settings)); } if(!sys.isEmpty()){ out.insert("System", LXDG::sortDesktopNames(sys)); } if(!utility.isEmpty()){ out.insert("Utility", LXDG::sortDesktopNames(utility)); } + if(!wine.isEmpty()){ out.insert("Wine", LXDG::sortDesktopNames(wine)); } if(!other.isEmpty()){ out.insert("Unsorted", LXDG::sortDesktopNames(other)); } //return the resulting hash return out; |