aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-08-29 10:41:27 -0400
committerKen Moore <ken@ixsystems.com>2017-08-29 10:41:27 -0400
commit707f24e79d6be8d570d77727eb1cedf98c685b88 (patch)
tree9f3d636eff38c6fd9a350a1a1c4d6edae23206d2 /src-qt5/core/libLumina
parentSyncronize the icon theme option in lumina-config with lthemeengine. (diff)
downloadlumina-707f24e79d6be8d570d77727eb1cedf98c685b88.tar.gz
lumina-707f24e79d6be8d570d77727eb1cedf98c685b88.tar.bz2
lumina-707f24e79d6be8d570d77727eb1cedf98c685b88.zip
Cleanup the DesktopSettings class and add some more settings files to it.
Diffstat (limited to 'src-qt5/core/libLumina')
-rw-r--r--src-qt5/core/libLumina/DesktopSettings.cpp47
-rw-r--r--src-qt5/core/libLumina/DesktopSettings.h8
2 files changed, 42 insertions, 13 deletions
diff --git a/src-qt5/core/libLumina/DesktopSettings.cpp b/src-qt5/core/libLumina/DesktopSettings.cpp
index 8bda1ac5..b051a4e8 100644
--- a/src-qt5/core/libLumina/DesktopSettings.cpp
+++ b/src-qt5/core/libLumina/DesktopSettings.cpp
@@ -56,6 +56,12 @@ void DesktopSettings::stop(){
}
//Main Read/Write functions
+QList< DesktopSettings::File > DesktopSettings::writableFiles(){
+ QList< DesktopSettings::File > tmp;
+ if(runmode!=DesktopSettings::SystemFull){ tmp = filesForRunMode(runmode); }
+ return tmp;
+}
+
QVariant DesktopSettings::value(DesktopSettings::File file, QString variable, QVariant defaultvalue){
if(!files.contains(file)){ return defaultvalue; }
for(int i=0; i<files[file].length(); i++){
@@ -178,18 +184,19 @@ void DesktopSettings::locateFiles(){
systemdirs << QString(getenv("XDG_CONFIG_DIRS")).split(":") << QString(getenv("XDG_DATA_DIRS")).split(":");
//Load all the user-level files for this run mode
QList< DesktopSettings::File > tmp;
- if(runmode == DesktopSettings::UserFull){ tmp << DesktopSettings::Favorites << DesktopSettings::Environment << DesktopSettings::Session << DesktopSettings::Desktop << DesktopSettings::Keys << DesktopSettings::Theme; }
- else if(runmode == DesktopSettings::SystemInterface){ tmp << DesktopSettings::Favorites << DesktopSettings::Environment << DesktopSettings::Session << DesktopSettings::Desktop << DesktopSettings::Keys << DesktopSettings::Theme; }
- for(int i=0; i<tmp.length(); i++){
- QString path = userdir+rel_path(tmp[i]);
- touchFile(path);
- files.insert(tmp[i], QStringList() << path);
- settings.insert(path, new QSettings(path, QSettings::IniFormat, this) );
- watcher->addPath(path);
+ if(runmode!=DesktopSettings::SystemFull){
+ //Load the user-level files
+ tmp= filesForRunMode(runmode);
+ for(int i=0; i<tmp.length(); i++){
+ QString path = userdir+rel_path(tmp[i]);
+ touchFile(path);
+ files.insert(tmp[i], QStringList() << path);
+ settings.insert(path, new QSettings(path, QSettings::IniFormat, this) );
+ watcher->addPath(path);
+ }
}
//Now load all the system-level files
- tmp.clear();
- tmp << DesktopSettings::Favorites << DesktopSettings::Environment << DesktopSettings::Session << DesktopSettings::Desktop << DesktopSettings::Keys << DesktopSettings::Theme;
+ tmp = filesForRunMode(DesktopSettings::SystemFull);
for(int i=0; i<systemdirs.length(); i++){
if(systemdirs[i].endsWith("/xdg")){ systemdirs[i] = systemdirs[i].section("/",0,-2); }
if( !QFile::exists(systemdirs[i]+"/lumina-desktop") ){ continue; }
@@ -219,6 +226,17 @@ void DesktopSettings::touchFile(QString path){
}
}
+QList< DesktopSettings::File > DesktopSettings::filesForRunMode(RunMode mode){
+ // Note that the "System" file is always ignored here - that is specially loaded
+ QList< DesktopSettings::File > tmp;
+ if(mode == DesktopSettings::UserFull || mode == DesktopSettings::SystemFull){
+ tmp << DesktopSettings::Favorites << DesktopSettings::Environment << DesktopSettings::Session << DesktopSettings::Desktop << DesktopSettings::Panels << DesktopSettings::Plugins << DesktopSettings::Keys << DesktopSettings::ContextMenu << DesktopSettings::Animation << DesktopSettings::ScreenSaver;
+ }else if(runmode == DesktopSettings::SystemInterface){
+ tmp << DesktopSettings::Favorites << DesktopSettings::Environment << DesktopSettings::Session;
+ }
+ return tmp;
+}
+
QString DesktopSettings::rel_path(DesktopSettings::File file){
QString name;
switch(file){
@@ -236,10 +254,15 @@ QString DesktopSettings::rel_path(DesktopSettings::File file){
name="contextmenu"; break;
case DesktopSettings::Keys:
name="keys"; break;
- case DesktopSettings::Theme:
- name="theme"; break;
case DesktopSettings::Animation:
name="animations"; break;
+ case DesktopSettings::Panels:
+ name="panels"; break;
+ case DesktopSettings::Plugins:
+ name="plugins"; break;
+ case DesktopSettings::ScreenSaver:
+ name="screensaver"; break;
+
}
return FILEPREFIX+name+".conf";
}
diff --git a/src-qt5/core/libLumina/DesktopSettings.h b/src-qt5/core/libLumina/DesktopSettings.h
index dcb10bb6..9bff6bc9 100644
--- a/src-qt5/core/libLumina/DesktopSettings.h
+++ b/src-qt5/core/libLumina/DesktopSettings.h
@@ -25,7 +25,8 @@
class DesktopSettings : public QObject{
Q_OBJECT
public:
- enum File{ System, Favorites, Environment, Session, Desktop, ContextMenu, Keys, Theme, Animation };
+ enum File{ System, Favorites, Environment, Session, Desktop, Panels, Plugins, ContextMenu, Keys, Animation, ScreenSaver};
+ //Changes to this enum need to be added to the "filesForRunMode()" and "rel_path()" functions as well
DesktopSettings(QObject *parent = 0);
~DesktopSettings();
@@ -37,6 +38,7 @@ public:
void stop();
//Main Read/Write functions
+ QList< DesktopSettings::File > writableFiles(); //return the list of all writable files
QVariant value(DesktopSettings::File, QString variable, QVariant defaultvalue);
bool setValue(DesktopSettings::File, QString variable, QVariant value);
QStringList keys(DesktopSettings::File); //return a list of all variables which are available in this file
@@ -51,9 +53,13 @@ private:
QHash< DesktopSettings::File, QStringList > files; //location hash for where files are actually located on disk
QHash< QString, QSettings*> settings; //location hash for the settings files themselves
+ //Functions
void parseSystemSettings(); //run at start - determine the RunMode for this user/session
void locateFiles(); //run at start - finds the locations of the various files (based on RunMode)
void touchFile(QString path); //used to create an empty file so it can be watched for changes later
+
+ //The two functions which define the public "File" enumeration (both need updates when the enum changes)
+ QList< DesktopSettings::File > filesForRunMode(RunMode mode);
QString rel_path(DesktopSettings::File); //return the relative file path (starting with "/")
private slots:
bgstack15