aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-08 18:42:04 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-08 18:42:04 +0200
commit7caffad75f0e7f7f1b1ce4d9523a67680e9b39a2 (patch)
treee2b9f71f163a0af96c3510f2336dfacb3fecbb28 /src/main.cpp
parent8c9480f6fc1b73b2f9ca5c1463a8ee10a579712d (diff)
downloadkristall-7caffad75f0e7f7f1b1ce4d9523a67680e9b39a2.tar.gz
Fixes #2: Adds command line parsing.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fa22cc1..2f49049 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3,13 +3,32 @@
#include <QApplication>
#include <QUrl>
#include <QSettings>
+#include <QCommandLineParser>
+#include <QDebug>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QCommandLineParser cli_parser;
+ cli_parser.parse(app.arguments());
+
MainWindow w(&app);
- w.addEmptyTab(true, true);
+
+ auto urls = cli_parser.positionalArguments();
+ if(urls.size() > 0) {
+ for(auto url_str : urls) {
+ QUrl url { url_str };
+ if(url.isValid()) {
+ w.addNewTab(false, url);
+ } else {
+ qDebug() << "Invalid url: " << url_str;
+ }
+ }
+ }
+ else {
+ w.addEmptyTab(true, true);
+ }
w.show();
return app.exec();