summaryrefslogtreecommitdiff
path: root/gui/main.cpp
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-06-23 18:47:25 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-08-11 20:59:51 +0200
commit3e0764caa84a21a60f971ec3693429a9981c5921 (patch)
treee5f50c289536f15351bf325689e7037af6994554 /gui/main.cpp
parenteb97dc510c92a2fc1a340cccf4103068699947c4 (diff)
[feat] hide systray if -n option is passed
Diffstat (limited to 'gui/main.cpp')
-rw-r--r--gui/main.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/gui/main.cpp b/gui/main.cpp
index e5486df..8033dba 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -48,17 +48,40 @@ int main(int argc, char **argv) {
QApplication::setApplicationName(backend.getAppName());
QApplication::setApplicationVersion(backend.getVersion());
QApplication app(argc, argv);
-
+ app.setQuitOnLastWindowClosed(false);
QCommandLineParser parser;
- parser.setApplicationDescription(backend.getAppName() + ": a fast and secure VPN. Powered by Bitmask.");
+ parser.setApplicationDescription(
+ backend.getAppName() +
+ QApplication::translate(
+ "main", ": a fast and secure VPN. Powered by Bitmask."));
parser.addHelpOption();
parser.addVersionOption();
+ parser.addOptions({
+ {
+ {"n", "no-systray"},
+ QApplication::translate("main",
+ "Do not show the systray icon (useful "
+ "together with gnome shell "
+ "extension, or to control VPN by other means)."),
+ },
+ {
+ {"i", "install-helpers"},
+ QApplication::translate(
+ "main",
+ "Install helpers (linux only, requires sudo)."),
+ },
+ });
parser.process(app);
- const QStringList args = parser.positionalArguments();
+ bool hideSystray = parser.isSet("no-systray");
+ bool installHelpers = parser.isSet("install-helpers");
- if (args.at(0) == "install-helpers") {
+ if (hideSystray) {
+ qDebug() << "Not showing systray icon because --no-systray option is set.";
+ }
+
+ if (installHelpers) {
qDebug() << "Will try to install helpers with sudo";
InstallHelpers();
exit(0);
@@ -72,21 +95,19 @@ int main(int argc, char **argv) {
translator.load(QLocale(), QLatin1String("main"), QLatin1String("_"), QLatin1String(":/i18n"));
app.installTranslator(&translator);
- app.setQuitOnLastWindowClosed(false);
QQmlApplicationEngine engine;
QQmlContext *ctx = engine.rootContext();
QJsonModel *model = new QJsonModel;
- std::string json = R"({"appName": "unknown", "provider": "unknown"})";
- model->loadJson(QByteArray::fromStdString(json));
/* the backend handler has slots for calling back to Go when triggered by
signals in Qml. */
ctx->setContextProperty("backend", &backend);
- /* set the json model, load the qml */
+ /* we pass the json model and set some useful flags */
ctx->setContextProperty("jsonModel", model);
ctx->setContextProperty("debugQml", debugQml);
+ ctx->setContextProperty("systrayVisible", !hideSystray);
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));