//=========================================== // Lumina-DE source code // Copyright (c) 2014, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== #include "LuminaThemes.h" #include "LuminaUtils.h" #include "LuminaOS.h" #include #include QStringList LTHEME::availableSystemThemes(){ //returns: [name::::path] for each item QDir dir(LOS::LuminaShare()+"themes"); QStringList list = dir.entryList(QStringList() <<"*.qss.template", QDir::Files, QDir::Name); for(int i=0; i::::] list[i] = list[i].section(".qss.",0,0)+"::::"+dir.absoluteFilePath(list[i]); } return list; } QStringList LTHEME::availableLocalThemes(){ //returns: [name::::path] for each item QDir dir(QDir::homePath()+"/.lumina/themes"); QStringList list = dir.entryList(QStringList() <<"*.qss.template", QDir::Files, QDir::Name); for(int i=0; i::::] list[i] = list[i].section(".qss.",0,0)+"::::"+dir.absoluteFilePath(list[i]); } return list; } QStringList LTHEME::availableSystemColors(){ //returns: [name::::path] for each item //returns: [name::::path] for each item QDir dir(LOS::LuminaShare()+"colors"); QStringList list = dir.entryList(QStringList() <<"*.qss.colors", QDir::Files, QDir::Name); for(int i=0; i::::] list[i] = list[i].section(".qss.",0,0)+"::::"+dir.absoluteFilePath(list[i]); } return list; } QStringList LTHEME::availableLocalColors(){ //returns: [name::::path] for each item QDir dir(QDir::homePath()+"/.lumina/colors"); QStringList list = dir.entryList(QStringList() <<"*.qss.colors", QDir::Files, QDir::Name); for(int i=0; i::::] list[i] = list[i].section(".qss.",0,0)+"::::"+dir.absoluteFilePath(list[i]); } return list; } QStringList LTHEME::availableSystemIcons(){ //returns: [name] for each item QStringList paths; paths << QDir::homePath()+"/.icons"; QStringList xdd = QString(getenv("XDG_DATA_HOME")).split(":"); xdd << QString(getenv("XDG_DATA_DIRS")).split(":"); for(int i=0; isetStyleSheet( LTHEME::assembleStyleSheet(theme, colors) ); watcher = new QFileSystemWatcher(this); watcher->addPath( QDir::homePath()+"/.lumina/themesettings.cfg" ); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange()) ); } LuminaThemeEngine::~LuminaThemeEngine(){ } void LuminaThemeEngine::watcherChange(){ QStringList current = LTHEME::currentSettings(); if(theme!=current[0] || colors!=current[1]){ application->setStyleSheet( LTHEME::assembleStyleSheet(current[0], current[1]) ); } if(icons!=current[3]){ emit updateIcons(); } //Now save this for later checking theme = current[0]; colors=current[1]; icons=current[2]; }