summaryrefslogtreecommitdiff
path: root/gui
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
parentcf5ed56c943599c092a91933b45471c4c0e5d579 (diff)
[refactor] use qt argument parsing
Diffstat (limited to 'gui')
-rw-r--r--gui/backend.go10
-rw-r--r--gui/handlers.cpp10
-rw-r--r--gui/handlers.h2
-rw-r--r--gui/main.cpp31
4 files changed, 42 insertions, 11 deletions
diff --git a/gui/backend.go b/gui/backend.go
index 4a73cc2..faf682a 100644
--- a/gui/backend.go
+++ b/gui/backend.go
@@ -12,6 +12,16 @@ import (
"0xacab.org/leap/bitmask-vpn/pkg/backend"
)
+//export GetVersion
+func GetVersion() *C.char {
+ return (*C.char)(backend.GetVersion())
+}
+
+//export GetAppName
+func GetAppName() *C.char {
+ return (*C.char)(backend.GetAppName())
+}
+
//export SwitchOn
func SwitchOn() {
backend.SwitchOn()
diff --git a/gui/handlers.cpp b/gui/handlers.cpp
index 9ce268d..de54161 100644
--- a/gui/handlers.cpp
+++ b/gui/handlers.cpp
@@ -10,6 +10,16 @@ Backend::Backend(QObject *parent) : QObject(parent)
{
}
+QString Backend::getAppName()
+{
+ return QString(GetAppName());
+}
+
+QString Backend::getVersion()
+{
+ return QString(GetVersion());
+}
+
void Backend::switchOn()
{
SwitchOn();
diff --git a/gui/handlers.h b/gui/handlers.h
index 0dc4c1e..8f89279 100644
--- a/gui/handlers.h
+++ b/gui/handlers.h
@@ -30,6 +30,8 @@ signals:
void quitDone();
public slots:
+ QString getAppName();
+ QString getVersion();
void switchOn();
void switchOff();
void unblock();
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 */