Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
bitmask-vpn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Merlin
bitmask-vpn
Commits
fb89df3e
Unverified
Commit
fb89df3e
authored
4 years ago
by
Kali Kaneko
Browse files
Options
Downloads
Patches
Plain Diff
[feat] load provider json in qml
parent
5dbb2dc4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
gui/gui.qrc
+5
-3
5 additions, 3 deletions
gui/gui.qrc
gui/main.cpp
+11
-5
11 additions, 5 deletions
gui/main.cpp
gui/providers/providers.json
+4
-0
4 additions, 0 deletions
gui/providers/providers.json
gui/qml/main.qml
+3
-0
3 additions, 0 deletions
gui/qml/main.qml
with
23 additions
and
8 deletions
gui/gui.qrc
+
5
−
3
View file @
fb89df3e
<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>
This diff is collapsed.
Click to expand it.
gui/main.cpp
+
11
−
5
View file @
fb89df3e
...
...
@@ -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
)};
...
...
This diff is collapsed.
Click to expand it.
gui/providers/providers.json
0 → 100644
+
4
−
0
View file @
fb89df3e
[
{
"name"
:
"provider1"
,
"url"
:
"https://example.com"
},
{
"name"
:
"provider2"
,
"url"
:
"https://foobar.com"
}
]
This diff is collapsed.
Click to expand it.
gui/qml/main.qml
+
3
−
0
View file @
fb89df3e
...
...
@@ -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
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment