summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2021-03-30 16:48:38 +0200
committerkali kaneko (leap communications) <kali@leap.se>2021-05-04 14:58:39 +0200
commitaae83bfac7005e303193acaef7b69497a0f323c0 (patch)
tree159231f04ddb9c59fe79dae048d64a06d3285765 /gui
parented529ab770ae4dc6dd79bbf819f8cf1b2dfb809b (diff)
Fetch the gateways from menshen
And use the fullness to display the status.
Diffstat (limited to 'gui')
-rw-r--r--gui/qml/main.qml30
1 files changed, 27 insertions, 3 deletions
diff --git a/gui/qml/main.qml b/gui/qml/main.qml
index a29c8d1..3978614 100644
--- a/gui/qml/main.qml
+++ b/gui/qml/main.qml
@@ -75,7 +75,7 @@ Window {
anchors.horizontalCenter: parent.horizontalCenter
Connections {
- onCheckedChanged: {
+ function onCheckedChanged() {
if (vpntoggle.checked == true && ctx.status == "off") {
backend.switchOn()
}
@@ -166,6 +166,30 @@ Window {
console.debug("Selected gateway:", currentText)
backend.useLocation(currentText.toString())
}
+
+ delegate: ItemDelegate {
+ // TODO: we could use icons
+ // https://doc.qt.io/qt-5/qml-qtquick-controls2-abstractbutton.html#icon-prop
+ background: Rectangle {
+ color: {
+ const fullness = ctx.locations[modelData]
+ if (fullness >= 0 && fullness < 0.4) {
+ "#83fc5a"
+ } else if (fullness >= 0.4 && fullness < 0.75) {
+ "#fcb149"
+ } else if (fullness >= 0.75) {
+ "#fc5a5d"
+ } else {
+ "#ffffff"
+ }
+ }
+ }
+ contentItem: Text {
+ text: modelData
+ font: gwSelector.font
+ color: "#000000"
+ }
+ }
}
} // end column
} // end item
@@ -174,10 +198,10 @@ Window {
Connections {
target: jsonModel
- onDataChanged: {
+ function onDataChanged() {
ctx = JSON.parse(jsonModel.getJson())
// TODO pass QML_DEBUG variable to be hyper-verbose
- //console.debug(jsonModel.getJson())
+ //console.debug(jsonModel.getJson())
gwSelector.model = Object.keys(ctx.locations)
if (ctx.donateDialog == 'true') {