aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-03-03 18:37:56 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2024-03-03 18:37:56 +0100
commit2355550bafe44207e7465d0454cb0af0a55dfd8f (patch)
tree1781f09d3a226895aff90f348496d66d611a6d5a
parentf15087cac5ef46ad45350aac2b66f85bd7dd5967 (diff)
change `--hidden` flag to `--open-at-startup`
-rw-r--r--README.md2
-rw-r--r--src/main.cpp17
2 files changed, 10 insertions, 9 deletions
diff --git a/README.md b/README.md
index 486360b..a8253a1 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ This project helps you to create web-apps which you can dock into the systray.
## Usage
```sh
-webtray <url> [--hidden]
+webtray <url> [--open-at-startup]
```
If you use `--hidden` it will start in the systray.
diff --git a/src/main.cpp b/src/main.cpp
index 56c20eb..246d0ad 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,3 +1,4 @@
+#include <QtCore/QTimer>
#include <QtGui/QCloseEvent>
#include <QtWebEngineCore/QWebEngineNotification>
#include <QtWebEngineCore/QWebEnginePage>
@@ -27,19 +28,19 @@ int
main(int argc, char **argv)
{
QApplication app(argc, argv);
- bool start_hidden = false;
+ bool start_hidden = true;
QUrl url;
for (auto argument : app.arguments()) {
- if (argument == "--hidden") {
- start_hidden = true;
+ if (argument == "--open-at-startup") {
+ start_hidden = false;
} else {
url = argument;
}
}
if (url.url().toStdString() == argv[0]) {
- std::cerr << "webtray <url> [--hidden]\n";
+ std::cerr << "webtray <url> [--open-at-startup]\n";
return -1;
}
@@ -158,10 +159,10 @@ main(int argc, char **argv)
});
main_window.setCentralWidget(&view);
- if (!start_hidden) {
- main_window.show();
- } else {
- tray.show();
+ main_window.show();
+ if (start_hidden) {
+ main_window.hide();
}
+ app.setQuitOnLastWindowClosed(false);
return app.exec();
}