diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/main.cpp | 17 |
2 files changed, 10 insertions, 9 deletions
@@ -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(); } |