diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-01-11 13:21:19 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-01-11 13:21:19 +0100 |
commit | d1c2d6694e9dac1ccb5567bd331b38ba5e46c78d (patch) | |
tree | 89fb35849ce644fff370056158b9e48e20ee6c65 | |
parent | Added BUILDING and LICENSE (diff) | |
download | smolbote-d1c2d6694e9dac1ccb5567bd331b38ba5e46c78d.tar.xz |
Added URL positional argument
-rw-r--r-- | src/main.cpp | 14 |
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();
}
|