From eb97dc510c92a2fc1a340cccf4103068699947c4 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Tue, 23 Jun 2020 17:12:42 +0200 Subject: [refactor] use qt argument parsing --- gui/main.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'gui/main.cpp') diff --git a/gui/main.cpp b/gui/main.cpp index 73d55cc..e5486df 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -1,13 +1,11 @@ #include -#include - #include -#include #include #include -#include -#include +#include #include +#include +#include #include "handlers.h" #include "qjsonmodel.h" @@ -42,18 +40,30 @@ void signalHandler(int) { int main(int argc, char **argv) { signal(SIGINT, signalHandler); - bool debugQml = getEnv("DEBUG_QML_DATA") == "yes"; - if (argc > 1 && strcmp(argv[1], "install-helpers") == 0) { + Backend backend; + + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setApplicationName(backend.getAppName()); + QApplication::setApplicationVersion(backend.getVersion()); + QApplication app(argc, argv); + + + QCommandLineParser parser; + parser.setApplicationDescription(backend.getAppName() + ": a fast and secure VPN. Powered by Bitmask."); + parser.addHelpOption(); + parser.addVersionOption(); + parser.process(app); + + const QStringList args = parser.positionalArguments(); + + if (args.at(0) == "install-helpers") { qDebug() << "Will try to install helpers with sudo"; InstallHelpers(); exit(0); } - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication app(argc, argv); - if (!QSystemTrayIcon::isSystemTrayAvailable()) { qDebug() << "No systray icon available. Things might not work for now, sorry..."; } @@ -72,7 +82,6 @@ int main(int argc, char **argv) { /* the backend handler has slots for calling back to Go when triggered by signals in Qml. */ - Backend backend; ctx->setContextProperty("backend", &backend); /* set the json model, load the qml */ -- cgit v1.2.3