summaryrefslogtreecommitdiff
path: root/gui/qml/VPNSwitch.qml
blob: 14b37347f0a0bbaa475a8cbab60e9130366acddb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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