summaryrefslogtreecommitdiff
path: root/gui/main.cpp
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-08-05 19:01:12 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-09-08 19:58:23 +0200
commitfb89df3ee609e9f3e63e0679b3635516603092b5 (patch)
treef84e171c965c46ec7fc675abbc07217774f26506 /gui/main.cpp
parent5dbb2dc4b587d825bcc58ca10c1b18d754f725e5 (diff)
[feat] load provider json in qml
Diffstat (limited to 'gui/main.cpp')
-rw-r--r--gui/main.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/gui/main.cpp b/gui/main.cpp
index e3b8530..8c7de4f 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -40,7 +40,6 @@ void signalHandler(int) {
int main(int argc, char **argv) {
signal(SIGINT, signalHandler);
- bool debugQml = getEnv("DEBUG_QML_DATA") == "yes";
Backend backend;
@@ -104,19 +103,27 @@ int main(int argc, char **argv) {
QTranslator translator;
translator.load(QLocale(), QLatin1String("main"), QLatin1String("_"), QLatin1String(":/i18n"));
app.installTranslator(&translator);
-
+
QQmlApplicationEngine engine;
QQmlContext *ctx = engine.rootContext();
QJsonModel *model = new QJsonModel;
+ /* load providers json */
+ QFile providerJson (":/providers.json");
+ providerJson.open(QIODevice::ReadOnly | QIODevice::Text);
+ QJsonModel *providers = new QJsonModel;
+ providers->loadJson(providerJson.readAll());
+
/* the backend handler has slots for calling back to Go when triggered by
signals in Qml. */
ctx->setContextProperty("backend", &backend);
- /* we pass the json model and set some useful flags */
+ /* set the json model, load providers.json */
ctx->setContextProperty("jsonModel", model);
- ctx->setContextProperty("debugQml", debugQml);
+ ctx->setContextProperty("providers", providers);
+
+ /* set some useful flags */
ctx->setContextProperty("systrayVisible", !hideSystray);
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
@@ -133,7 +140,6 @@ int main(int argc, char **argv) {
QGuiApplication::quit();
});
-
/* register statusChanged callback with CGO */
const char *stCh = "OnStatusChanged";
GoString statusChangedEvt = {stCh, (long int)strlen(stCh)};