aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/LUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core/libLumina/LUtils.cpp')
-rw-r--r--src-qt5/core/libLumina/LUtils.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src-qt5/core/libLumina/LUtils.cpp b/src-qt5/core/libLumina/LUtils.cpp
index 78831231..fa0173dc 100644
--- a/src-qt5/core/libLumina/LUtils.cpp
+++ b/src-qt5/core/libLumina/LUtils.cpp
@@ -12,6 +12,8 @@
#include <QApplication>
#include <QtConcurrent>
+#include <unistd.h>
+
inline QStringList ProcessRun(QString cmd, QStringList args){
//Assemble outputs
QStringList out; out << "1" << ""; //error code, string output
@@ -127,6 +129,30 @@ bool LUtils::isValidBinary(QString& bin){
return good;
}
+QSettings* LUtils::openSettings(QString org, QString name, QObject *parent){
+ //Start with the base configuration directory
+ QString path = QString(getenv("XDG_CONFIG_HOME")).simplified();
+ if(path.isEmpty()){ path = QDir::homePath()+"/.config"; }
+ //Now add the organization directory
+ path = path+"/"+org;
+ QDir dir(path);
+ if(!dir.exists()){ dir.mkpath(path); }
+ //Now generate/check the name of the file
+ unsigned int user = getuid();
+ QString filepath = dir.absoluteFilePath(name+".conf");
+ if(user==0){
+ //special case - make sure we don't clobber the user-permissioned file
+ QString rootfilepath = dir.absoluteFilePath(name+"_root.conf");
+ if(!QFileInfo::exists(rootfilepath) && QFileInfo::exists(filepath)){
+ QFile::copy(filepath, rootfilepath); //make a copy of the user settings before they start to diverge
+ }
+ return (new QSettings(rootfilepath, QSettings::IniFormat, parent));
+ }else{
+ return (new QSettings(filepath, QSettings::IniFormat, parent));
+ }
+
+}
+
QStringList LUtils::systemApplicationDirs(){
//Returns a list of all the directories where *.desktop files can be found
QStringList appDirs = QString(getenv("XDG_DATA_HOME")).split(":");
bgstack15