aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-01-17 13:32:13 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-01-17 13:32:13 +0100
commitd592ee191e8aedc84c670e6d818fcf97c0bd7a92 (patch)
treeb2bd8413332cd1567b9ae954835a7a4c930de730 /src/main.cpp
parentFixed build scripts for use with the mercurial repository (diff)
downloadsmolbote-d592ee191e8aedc84c670e6d818fcf97c0bd7a92.tar.xz
Configuration creates missing items based on defaults
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp35
1 files changed, 10 insertions, 25 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fb80b7e..0452fdd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -36,35 +36,18 @@ void bootstrapUserConfig(const std::string &path, Configuration &config)
// set firstRun to false so we don't re-init on every run
config.setValue<bool>("browser.firstRun", false);
- // The .path's need to be overriden because ~ doesn't translate to home
- const QString &home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
-
- // filter.path
- std::string filterPath = config.value<std::string>("filter.path").value();
- config.setValue<std::string>("filter.path", patchHome(filterPath, home.toStdString()));
-
- // profile.path
- std::string profilePath = config.value<std::string>("profile.path").value();
- config.setValue<std::string>("profile.path", patchHome(profilePath, home.toStdString()));
-
- // bookmarks.path
- std::string bookmarksPath = config.value<std::string>("bookmarks.path").value();
- config.setValue<std::string>("bookmarks.path", patchHome(bookmarksPath, home.toStdString()));
-
- // downloads.path
- std::string downloadsPath = config.value<std::string>("downloads.path").value();
- config.setValue<std::string>("downloads.path", patchHome(downloadsPath, home.toStdString()));
+ config.resetValue("filter.path");
+ config.resetValue("profile.path");
+ config.resetValue("bookmarks.path");
+ config.resetValue("downloads.path");
+ config.resetValue("plugins.path");
}
int main(int argc, char *argv[])
{
// Create application object
Browser instance(argc, argv);
-#ifdef SMOLBOTE_VERSION
instance.setApplicationVersion(SMOLBOTE_VERSION);
-#else
- instance.setApplicationVersion("1.0.0");
-#endif
#ifdef QT_DEBUG
QElapsedTimer timer;
@@ -122,8 +105,10 @@ int main(int argc, char *argv[])
return 0;
}
- std::shared_ptr<Configuration> config = std::make_shared<Configuration>();
- config->readUserConfiguration(parser.value(configOption).toStdString());
+ std::shared_ptr<Configuration> config = std::make_shared<Configuration>(
+ parser.value(configOption).toStdString(),
+ QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString());
+ config->read();
config->parseDefaultConfiguration(readConfig(parser.value(defaultConfigOption)));
// check if first run
@@ -151,7 +136,7 @@ int main(int argc, char *argv[])
// patch paths
bootstrapUserConfig(path.toStdString(), *config);
- std::cout << "Generating config to: " << qUtf8Printable(path) << (config->writeUserConfiguration(path.toStdString()) ? " ok" : " failed") << std::endl;
+ std::cout << "Writing configuration: " << (config->writeIfNeeded(path.toStdString()) ? "ok" : "failed") << std::endl;
// exit if this is the only thing we needed to do
if(parser.isSet(generateUserConfigOption)) {