summaryrefslogtreecommitdiff
path: root/gui/qml/VPNSwitch.qml
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-05-31 01:49:43 +0200
committerkali kaneko (leap communications) <kali@leap.se>2021-06-01 12:34:03 +0200
commit00be891d3b0cb401e642a5331aedcc399641b8ef (patch)
tree19303b892d9bcae3f30cf6dae68af7f7324c1481 /gui/qml/VPNSwitch.qml
parent1bd2637e3133d895d1e73931f8b3466a5761d9ef (diff)
[refactor] unclutter main qml
Diffstat (limited to 'gui/qml/VPNSwitch.qml')
-rw-r--r--gui/qml/VPNSwitch.qml64
1 files changed, 64 insertions, 0 deletions
diff --git a/gui/qml/VPNSwitch.qml b/gui/qml/VPNSwitch.qml
new file mode 100644
index 0000000..14b3734
--- /dev/null
+++ b/gui/qml/VPNSwitch.qml
@@ -0,0 +1,64 @@
+import QtQuick 2.9
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.4
+
+
+SwitchDelegate {
+
+ //id: vpntoggle
+
+ text: qsTr("")
+ checked: false
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ /*
+ Connections {
+ function onCheckedChanged() {
+ if (vpntoggle.checked == true
+ && ctx.status == "off") {
+ backend.switchOn()
+ }
+ if (vpntoggle.checked === false
+ && ctx.status == "on") {
+ backend.switchOff()
+ }
+ }
+ }
+ */
+
+ contentItem: Text {
+ rightPadding: vpntoggle.indicator.width + vpntoggle.spacing
+ text: vpntoggle.text
+ font: vpntoggle.font
+ opacity: enabled ? 1.0 : 0.5
+ color: vpntoggle.down ? "#17a81a" : "#21be2b"
+ elide: Text.ElideRight
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ indicator: Rectangle {
+ implicitWidth: 48
+ implicitHeight: 26
+ x: vpntoggle.width - width - vpntoggle.rightPadding
+ y: parent.height / 2 - height / 2
+ radius: 13
+ color: vpntoggle.checked ? "#17a81a" : "transparent"
+ border.color: vpntoggle.checked ? "#17a81a" : "#cccccc"
+
+ Rectangle {
+ x: vpntoggle.checked ? parent.width - width : 0
+ width: 26
+ height: 26
+ radius: 13
+ color: vpntoggle.down ? "#cccccc" : "#ffffff"
+ border.color: vpntoggle.checked ? (vpntoggle.down ? "#17a81a" : "#21be2b") : "#999999"
+ }
+ }
+
+ background: Rectangle {
+ implicitWidth: 100
+ implicitHeight: 40
+ visible: vpntoggle.down || vpntoggle.highlighted
+ color: vpntoggle.down ? "#17a81a" : "#eeeeee"
+ }
+} // end switchdelegate