diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-04-22 16:10:18 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-04-22 16:10:18 +0200 |
commit | e1f240f490324f8c6f4d8132630ad85756f6d191 (patch) | |
tree | d0b9cb561d34a361297a72823a897cbb235cbae9 /src/main.cpp | |
parent | Add tile and cascade actions to Window menu (diff) | |
download | smolbote-e1f240f490324f8c6f4d8132630ad85756f6d191.tar.xz |
Merge CommandLine functionality into Configuration
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/main.cpp b/src/main.cpp index 52df7ac..bfe4ecd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,7 +7,6 @@ */ #include "browser.h" -#include "commandline.h" #include "mainwindow/mainwindow.h" #include "version.h" #include "webengine/webprofile.h" @@ -18,36 +17,31 @@ int main(int argc, char **argv) { Browser app(argc, argv); - CommandLine parser; - parser.parseCommandLine(app); - // create and load configuration std::shared_ptr<Configuration> config = std::make_shared<Configuration>(); - config->read(parser.value(parser.configOption)); - - if(!parser.unknownOptionNames().isEmpty()) { - qDebug("config->parse: %s", config->parse(argc, argv) ? "true" : "false"); + if(!config->parseCommandLine(argc, argv)) { + qWarning("Check --help for usage."); + return -1; + } + if(!config->parseConfigFile(config->value<std::string>("config").value())) { + qWarning("Error parsing config file."); } app.setConfiguration(config); // set up socket - bool isSingleInstance = app.bindLocalSocket(parser.value(parser.socketOption)); + bool isSingleInstance = app.bindLocalSocket(QString::fromStdString(config->value<std::string>("socket").value())); #ifdef QT_DEBUG - qDebug("bindLocalSocket(%s) = %s", qUtf8Printable(parser.value(parser.socketOption)), isSingleInstance ? "true" : "false"); + qDebug("bindLocalSocket(%s) = %s", qUtf8Printable(QString::fromStdString(config->value<std::string>("socket").value())), isSingleInstance ? "true" : "false"); #endif // if we are the only instance, set up the browser if(isSingleInstance) { - if(parser.isSet(parser.profileOption)) - app.setup(parser.value(parser.profileOption)); - else - app.setup(QString::fromStdString(config->value<std::string>("profile.default").value())); - + app.setup(QString::fromStdString(config->value<std::string>("profile.default").value())); QObject::connect(&app, &Browser::messageAvailable, &app, &Browser::createSession); } - app.sendMessage(parser.value(parser.profileOption), parser.isSet(parser.newWindowOption), parser.positionalArguments()); + app.sendMessage("", false, config->positionalArguments()); if(isSingleInstance) return app.exec(); |