aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/configuration/configuration.cpp17
-rw-r--r--lib/configuration/configuration.h2
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/configuration/configuration.cpp b/lib/configuration/configuration.cpp
index c114155..c9bae90 100644
--- a/lib/configuration/configuration.cpp
+++ b/lib/configuration/configuration.cpp
@@ -81,14 +81,25 @@ Configuration::Configuration()
// store the defaults into the vm
{
- const char* argv[0];
+ const char *argv[0];
po::store(po::parse_command_line(0, argv, desc), vm);
}
-
}
Configuration::~Configuration() = default;
+QString Configuration::defaultUserConfigLocation()
+{
+ // try to locate an existing config
+ QString path = QStandardPaths::locate(QStandardPaths::ConfigLocation, "smolbote/smolbote.cfg");
+
+ // it's possible there is no config, so set the path properly
+ if(path.isEmpty())
+ path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/smolbote/smolbote.cfg";
+
+ return path;
+}
+
bool Configuration::read(const QString &path)
{
std::ifstream f(path.toStdString(), std::ifstream::in);
@@ -100,7 +111,7 @@ bool Configuration::parse(int argc, const char **argv)
{
try {
po::store(po::parse_command_line(argc, argv, desc), vm);
- } catch (const po::error &e) {
+ } catch(const po::error &e) {
return false;
}
diff --git a/lib/configuration/configuration.h b/lib/configuration/configuration.h
index 4d58a90..c8fcdff 100644
--- a/lib/configuration/configuration.h
+++ b/lib/configuration/configuration.h
@@ -22,6 +22,8 @@ public:
explicit Configuration();
~Configuration();
+ static QString defaultUserConfigLocation();
+
bool read(const QString &path);
bool parse(int argc, const char **argv);