diff options
-rw-r--r-- | libLumina/LuminaUtils.cpp | 14 | ||||
-rw-r--r-- | libLumina/LuminaUtils.h | 4 | ||||
-rw-r--r-- | libLumina/LuminaXDG.cpp | 15 | ||||
-rw-r--r-- | lumina-desktop/AppMenu.cpp | 1 |
4 files changed, 30 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; diff --git a/lumina-desktop/AppMenu.cpp b/lumina-desktop/AppMenu.cpp index 590cf35b..074bd9f1 100644 --- a/lumina-desktop/AppMenu.cpp +++ b/lumina-desktop/AppMenu.cpp @@ -68,6 +68,7 @@ void AppMenu::updateAppList(){ else if(cats[i] == "Settings"){ name = tr("Settings"); icon = "preferences-system"; } else if(cats[i] == "System"){ name = tr("System"); icon = "applications-system"; } else if(cats[i] == "Utility"){ name = tr("Utility"); icon = "applications-utilities"; } + else if(cats[i] == "Wine"){ name = tr("Wine"); icon = "wine"; } else{ name = tr("Unsorted"); icon = "applications-other"; } QMenu *menu = new QMenu(name, this); |