diff options
author | Weblate <noreply@weblate.org> | 2018-01-02 20:53:45 +0000 |
---|---|---|
committer | Weblate <noreply@weblate.org> | 2018-01-02 20:53:45 +0000 |
commit | 42e4f35c9a2ea2689b62ef8c5461b14a2b820e4f (patch) | |
tree | a92f81f73b37b7de76cc5238f1ec393ae5a18ecd /src-qt5/core/libLumina/LuminaThemes.cpp | |
parent | Translated using Weblate (Dutch) (diff) | |
parent | Updated project files for plugin system (diff) | |
download | lumina-42e4f35c9a2ea2689b62ef8c5461b14a2b820e4f.tar.gz lumina-42e4f35c9a2ea2689b62ef8c5461b14a2b820e4f.tar.bz2 lumina-42e4f35c9a2ea2689b62ef8c5461b14a2b820e4f.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/libLumina/LuminaThemes.cpp')
-rw-r--r-- | src-qt5/core/libLumina/LuminaThemes.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src-qt5/core/libLumina/LuminaThemes.cpp b/src-qt5/core/libLumina/LuminaThemes.cpp index 857e604b..03524941 100644 --- a/src-qt5/core/libLumina/LuminaThemes.cpp +++ b/src-qt5/core/libLumina/LuminaThemes.cpp @@ -34,6 +34,17 @@ QStringList LTHEME::availableSystemThemes(){ return list; } +QStringList LTHEME::availableSystemStyles(){ + //returns: [name::::path] for each item + QDir dir(LOS::LuminaShare()+"../lthemeengine/qss"); + QStringList list = dir.entryList(QStringList() <<"*.qss", QDir::Files, QDir::Name); + for(int i=0; i<list.length(); i++){ + //Format the output entry [<name>::::<fullpath>] + 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( QString(getenv("XDG_CONFIG_HOME"))+"/lthemeengine/desktop_qss"); QStringList list = dir.entryList(QStringList() <<"*.qss", QDir::Files, QDir::Name); @@ -44,6 +55,16 @@ QStringList LTHEME::availableLocalThemes(){ //returns: [name::::path] for each i return list; } +QStringList LTHEME::availableLocalStyles(){ //returns: [name::::path] for each item + QDir dir( QString(getenv("XDG_CONFIG_HOME"))+"/lthemeengine/qss"); + QStringList list = dir.entryList(QStringList() <<"*.qss", QDir::Files, QDir::Name); + for(int i=0; i<list.length(); i++){ + //Format the output entry [<name>::::<fullpath>] + 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()+"../lthemeengine/colors"); @@ -244,6 +265,23 @@ bool LTHEME::setCursorTheme(QString cursorname){ return LUtils::writeFile(QDir::homePath()+"/.icons/default/index.theme", info, true); } +bool LTHEME::setCurrentStyles(QStringList paths){ + //Verify that the paths are all absolute paths, otherwise scan/replace with absolute paths + QStringList avail = LTHEME::availableSystemStyles(); + for(int i=0; i<paths.length(); i++){ + paths[i] = paths[i].simplified(); + if(paths[i].startsWith("/")){ continue; } //already an absolute path + for(int j=0; j<avail.length(); j++){ + if(avail[j].startsWith(paths[i].section("/",-1).section(".qss",0,0)+"::::") ){ paths[i] = avail[j].section("::::",1,-1); break; } + } + } + //ordered by priority: lowest -> highest + QSettings engineset("lthemeengine","lthemeengine"); + engineset.setValue("Interface/stylesheets",paths); + engineset.sync(); + return true; +} + //Return the complete stylesheet for a given theme/colors QString LTHEME::assembleStyleSheet(QString themepath, QString colorpath, QString font, QString fontsize){ QString stylesheet = LUtils::readFile(themepath).join("\n"); @@ -340,10 +378,10 @@ void LTHEME::LoadCustomEnvSettings(){ setenv(info[i].section("=",0,0).toLocal8Bit(), info[i].section("=",1,100).simplified().toLocal8Bit(), 1); } } - + } -bool LTHEME::setCustomEnvSetting(QString var, QString val){ +bool LTHEME::setCustomEnvSetting(QString var, QString val){ //variable/value pair (use an empty val to clear it) QStringList info = LTHEME::CustomEnvSettings(true); //user only bool changed = false; |