summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/gui.qrc8
-rw-r--r--gui/main.cpp16
-rw-r--r--gui/providers/providers.json4
-rw-r--r--gui/qml/main.qml3
4 files changed, 23 insertions, 8 deletions
diff --git a/gui/gui.qrc b/gui/gui.qrc
index 6bc3d8d..112a1ce 100644
--- a/gui/gui.qrc
+++ b/gui/gui.qrc
@@ -1,11 +1,12 @@
<RCC>
<qresource prefix="/">
+
<file>qml/main.qml</file>
<file>qml/AboutDialog.qml</file>
<file>qml/DonateDialog.qml</file>
<file>qml/LoginDialog.qml</file>
<file>qml/LoginOKDialog.qml</file>
-
+
<file>assets/icon/png/black/vpn_off.png</file>
<file>assets/icon/png/black/vpn_on.png</file>
<file>assets/icon/png/black/vpn_wait_0.png</file>
@@ -19,7 +20,8 @@
<file>assets/icon/png/white/vpn_wait_1.png</file>
<file>assets/icon/png/white/vpn_wait_2.png</file>
<file>assets/icon/png/white/vpn_wait_3.png</file>
- </qresource>
-</RCC>
+ <file alias="providers.json">providers/providers.json</file>
+ </qresource>
+</RCC>
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)};
diff --git a/gui/providers/providers.json b/gui/providers/providers.json
new file mode 100644
index 0000000..7ba0ef9
--- /dev/null
+++ b/gui/providers/providers.json
@@ -0,0 +1,4 @@
+[
+ {"name": "provider1", "url": "https://example.com"},
+ {"name": "provider2", "url": "https://foobar.com"}
+]
diff --git a/gui/qml/main.qml b/gui/qml/main.qml
index 9f8bea3..da6b9ee 100644
--- a/gui/qml/main.qml
+++ b/gui/qml/main.qml
@@ -56,6 +56,9 @@ ApplicationWindow {
Loaders as a placeholder for all the many dialogs, or to load
a nice splash screen etc... */
+ console.debug("Pre-seeded providers:");
+ console.debug(providers.getJson());
+
app.visible = true;
show();
hide();