#include #include #include "lthemeengine.h" #ifndef LTHEMEENGINE_DATADIR #define LTHEMEENGINE_DATADIR "/usr/local/share" #endif #include QStringList lthemeengine::readFile(QString filepath){ QStringList out; QFile file(filepath); if(file.open(QIODevice::Text | QIODevice::ReadOnly)){ QTextStream in(&file); while(!in.atEnd()){ out << in.readLine(); } file.close(); } return out; } QString lthemeengine::configPath(){ return QDir::homePath() + "/.config/lthemeengine/"; } QString lthemeengine::configFile(){ return configPath() + "lthemeengine.conf"; } QStringList lthemeengine::iconPaths(){ QString xdgDataDirs = qgetenv("XDG_DATA_DIRS"); QString xdgDataHome = qgetenv("XDG_DATA_HOME"); QStringList paths; paths << QDir::homePath() + "/.icons/"; if(xdgDataDirs.isEmpty()){ paths << "/usr/share/icons"; paths << "/usr/local/share/icons"; } else{ foreach (QString p, xdgDataDirs.split(":")){ paths << QDir(p + "/icons/").absolutePath(); } } if(xdgDataHome.isEmpty()){ xdgDataHome = QDir::homePath() + "/.local/share"; } paths << "/usr/share/pixmaps"; paths << xdgDataHome + "/icons"; paths.removeDuplicates(); //remove invalid foreach (QString p, paths){ if(!QDir(p).exists()){ paths.removeAll(p); } } return paths; } QString lthemeengine::userStyleSheetPath(){ return configPath() + "qss/"; } QStringList lthemeengine::sharedStyleSheetPath(){ QStringList dirs; dirs << QString(getenv("XDG_CONFIG_HOME")); dirs << QString(getenv("XDG_CONFIG_DIRS")).split(":"); dirs << QString(getenv("XDG_DATA_DIRS")).split(":"); for(int i=0; i