summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/QtSettingsProvider.cpp13
-rw-r--r--Swift/QtUI/QtSettingsProvider.h4
2 files changed, 17 insertions, 0 deletions
diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp
index b563af1..a5642d7 100644
--- a/Swift/QtUI/QtSettingsProvider.cpp
+++ b/Swift/QtUI/QtSettingsProvider.cpp
@@ -7,6 +7,7 @@
#include "QtSettingsProvider.h"
#include <QStringList>
+#include <QFile>
namespace Swift {
@@ -24,6 +25,7 @@ std::string QtSettingsProvider::getStringSetting(const std::string &settingPath)
void QtSettingsProvider::storeString(const std::string &settingPath, const std::string &settingValue) {
settings_.setValue(settingPath.c_str(), settingValue.c_str());
+ updatePermissions();
}
bool QtSettingsProvider::getBoolSetting(const std::string &settingPath, bool defaultValue) {
@@ -33,6 +35,7 @@ bool QtSettingsProvider::getBoolSetting(const std::string &settingPath, bool def
void QtSettingsProvider::storeBool(const std::string &settingPath, bool settingValue) {
settings_.setValue(settingPath.c_str(), settingValue);
+ updatePermissions();
}
int QtSettingsProvider::getIntSetting(const std::string &settingPath, int defaultValue) {
@@ -42,6 +45,7 @@ int QtSettingsProvider::getIntSetting(const std::string &settingPath, int defaul
void QtSettingsProvider::storeInt(const std::string &settingPath, int settingValue) {
settings_.setValue(settingPath.c_str(), settingValue);
+ updatePermissions();
}
std::vector<std::string> QtSettingsProvider::getAvailableProfiles() {
@@ -57,6 +61,7 @@ void QtSettingsProvider::createProfile(const std::string& profile) {
QStringList stringList = settings_.value("profileList").toStringList();
stringList.append(profile.c_str());
settings_.setValue("profileList", stringList);
+ updatePermissions();
}
void QtSettingsProvider::removeProfile(const std::string& profile) {
@@ -69,11 +74,19 @@ void QtSettingsProvider::removeProfile(const std::string& profile) {
QStringList stringList = settings_.value("profileList").toStringList();
stringList.removeAll(profile.c_str());
settings_.setValue("profileList", stringList);
+ updatePermissions();
}
QSettings* QtSettingsProvider::getQSettings() {
return &settings_;
}
+void QtSettingsProvider::updatePermissions() {
+ QFile file(settings_.fileName());
+ if (file.exists()) {
+ file.setPermissions(QFile::ReadOwner|QFile::WriteOwner);
+ }
+}
+
}
diff --git a/Swift/QtUI/QtSettingsProvider.h b/Swift/QtUI/QtSettingsProvider.h
index ca05fe1..8eeb854 100644
--- a/Swift/QtUI/QtSettingsProvider.h
+++ b/Swift/QtUI/QtSettingsProvider.h
@@ -27,6 +27,10 @@ class QtSettingsProvider : public SettingsProvider {
virtual void createProfile(const std::string& profile);
virtual void removeProfile(const std::string& profile);
QSettings* getQSettings();
+
+ private:
+ void updatePermissions();
+
private:
QSettings settings_;
};