aboutsummaryrefslogtreecommitdiff
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
parent8c9480f6fc1b73b2f9ca5c1463a8ee10a579712d (diff)
downloadkristall-7caffad75f0e7f7f1b1ce4d9523a67680e9b39a2.tar.gz
Fixes #2: Adds command line parsing.
-rw-r--r--Changelog.txt1
-rw-r--r--README.md4
-rw-r--r--src/main.cpp21
3 files changed, 22 insertions, 4 deletions
diff --git a/Changelog.txt b/Changelog.txt
index 7a5e242..c0f6f00 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -12,6 +12,7 @@ Kristall Changelog
- Added support for video/* and audio/* via QMediaPlayer
- Added support for file:// scheme
- Added status bar with loading time, file size and mime type
+- Added support for command line arguments
== 0.1
- Initial release \ No newline at end of file
diff --git a/README.md b/README.md
index b7ad7e5..e1017f8 100644
--- a/README.md
+++ b/README.md
@@ -105,8 +105,6 @@ Just use QtCreator to build `./src/kristall.pro`. Default settings should be fin
- [ ] Improve gophermap rendering with icons for media types
- [ ] Support more media types (include uudecode and hexbin decoder)
- [ ] Improve UX
- - [ ] Add command line options to open URLs directly
- - [ ] Add support for `file://` media type
- [ ] Rightclick with "open in new tab" and "open in this tab"
- [ ] For history
- [ ] For favourites
@@ -120,7 +118,7 @@ Just use QtCreator to build `./src/kristall.pro`. Default settings should be fin
- [ ] `*bold*`
- [ ] `_underline_`
- [ ] Option: "Display text/* as plain text"
-
+ - [ ] Option: Gopher Map with text marker instead of icons
## Bugs
> <styan> xq: When using torsocks(1) on kristall QNetworkInterface complains loudly about not being permitted to create an IPv6 socket..
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();