Skip to content
Snippets Groups Projects
Unverified Commit fb89df3e authored by Kali Kaneko's avatar Kali Kaneko
Browse files

[feat] load provider json in qml

parent 5dbb2dc4
No related branches found
No related tags found
No related merge requests found
<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>
......@@ -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)};
......
[
{"name": "provider1", "url": "https://example.com"},
{"name": "provider2", "url": "https://foobar.com"}
]
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment