summaryrefslogtreecommitdiffhomepage
path: root/options/group.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-16 17:39:15 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-16 17:54:12 +0200
commitaf8d6f769c26d4d260d6fc430165b51aebbd0733 (patch)
tree2129d44b18bc919b339d7bfd9de9da6b3c921669 /options/group.cpp
parenta781170550b4354e0f5551e0b20560d84e4108ce (diff)
gui/main-window: exit program when config not writable
Note, it opens the config in read-write mode to check if it's writable. This might present a race condition when config is saved. However, we're expecting all config saving to be done in the user interface thread. Add a check for it however.
Diffstat (limited to 'options/group.cpp')
-rw-r--r--options/group.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/options/group.cpp b/options/group.cpp
index 94e111aa..a17f185c 100644
--- a/options/group.cpp
+++ b/options/group.cpp
@@ -2,6 +2,7 @@
#include "defs.hpp"
#include <QStandardPaths>
#include <QDir>
+
#include <QDebug>
namespace options {
@@ -48,7 +49,7 @@ void group::put(const QString &s, const QVariant &d)
bool group::contains(const QString &s) const
{
- return kvs.count(s) != 0;
+ return kvs.find(s) != kvs.cend();
}
QString group::ini_directory()
@@ -64,7 +65,10 @@ QString group::ini_directory()
QString group::ini_filename()
{
QSettings settings(OPENTRACK_ORG);
- return settings.value(OPENTRACK_CONFIG_FILENAME_KEY, OPENTRACK_DEFAULT_CONFIG).toString();
+ const QString ret = settings.value(OPENTRACK_CONFIG_FILENAME_KEY, OPENTRACK_DEFAULT_CONFIG).toString();
+ if (ret.size() == 0)
+ return OPENTRACK_DEFAULT_CONFIG;
+ return ret;
}
QString group::ini_pathname()
@@ -75,6 +79,11 @@ QString group::ini_pathname()
return dir + "/" + ini_filename();
}
+QString group::ini_combine(const QString& filename)
+{
+ return ini_directory() + QStringLiteral("/") + filename;
+}
+
QStringList group::ini_list()
{
const auto dirname = ini_directory();