aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-01-11 13:21:19 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-01-11 13:21:19 +0100
commitd1c2d6694e9dac1ccb5567bd331b38ba5e46c78d (patch)
tree89fb35849ce644fff370056158b9e48e20ee6c65
parentAdded BUILDING and LICENSE (diff)
downloadsmolbote-d1c2d6694e9dac1ccb5567bd331b38ba5e46c78d.tar.xz
Added URL positional argument
-rw-r--r--src/main.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 94ad981..b45fad4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -14,13 +14,25 @@ int main(int argc, char *argv[])
parser.addHelpOption();
parser.addVersionOption();
+ parser.addPositionalArgument("URL", "URL to open");
+
QCommandLineOption configOption(QStringList() << "c" << "config", "Set configuration file.", "PATH", "config.ini");
parser.addOption(configOption);
parser.process(app);
Browser instance(parser.value(configOption));
- instance.addWindow(new MainWindow(instance.settings()));
+
+ if(parser.positionalArguments().length() > 0) {
+ QUrl url = QUrl::fromUserInput(parser.positionalArguments().at(0));
+ if(url.isValid()) {
+ instance.addWindow(new MainWindow(instance.settings(), url));
+ } else {
+ instance.addWindow(new MainWindow(instance.settings()));
+ }
+ } else {
+ instance.addWindow(new MainWindow(instance.settings()));
+ }
return app.exec();
}