summaryrefslogtreecommitdiff
path: root/gui/main.cpp
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-06-23 17:12:42 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-08-11 20:59:50 +0200
commiteb97dc510c92a2fc1a340cccf4103068699947c4 (patch)
treed9bc5ade18bb47d618ee4411183b99086e7a9f6f /gui/main.cpp
parentcf5ed56c943599c092a91933b45471c4c0e5d579 (diff)
[refactor] use qt argument parsing
Diffstat (limited to 'gui/main.cpp')
-rw-r--r--gui/main.cpp31
1 files changed, 20 insertions, 11 deletions
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 <csignal>
-#include <string>
-
#include <QApplication>
-#include <QSystemTrayIcon>
#include <QTimer>
#include <QTranslator>
-#include <QtQml>
-#include <QQmlApplicationEngine>
+#include <QCommandLineParser>
#include <QQuickWindow>
+#include <QSystemTrayIcon>
+#include <QtQml>
#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 */