From 0adeaf9c2822848604cbba58d70102d5304a57e5 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Tue, 14 Jun 2022 21:21:11 +0800 Subject: [PATCH] fix: improve the cli support --- GPClient/main.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/GPClient/main.cpp b/GPClient/main.cpp index f3f1269..9970681 100644 --- a/GPClient/main.cpp +++ b/GPClient/main.cpp @@ -57,11 +57,6 @@ int main(int argc, char *argv[]) : static_cast(new VpnDbus(nullptr)); // Contact GPService daemon via dbus GPClient w(nullptr, vpn); - parser.isSet("start-minimized") ? w.showMinimized() : w.show(); - if (parser.isSet("reset")) { - w.reset(); - } - if (positional.size() > 0) { w.portal(positional.at(0)); } @@ -81,11 +76,20 @@ int main(int argc, char *argv[]) sigwatch.watchForSignal(SIGHUP); QObject::connect(&sigwatch, &UnixSignalWatcher::unixSignal, &w, &GPClient::quit); + if (parser.isSet("json")) { + QObject::connect(static_cast(vpn), &VpnJson::connected, &w, &GPClient::quit); + } + + if (parser.isSet("reset")) { + w.reset(); + } + if (parser.isSet("now")) { w.doConnect(); - } - if (parser.isSet("json")) { - QObject::connect(static_cast(vpn), &VpnJson::connected, &w, &GPClient::quit); + } else if (parser.isSet("start-minimized")) { + w.showMinimized(); + } else { + w.show(); } return app.exec();