SwitchGroupControl.qml 5.16 KB
Newer Older
Leander Schulten's avatar
Leander Schulten committed
1
2
3
4
5
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtGraphicalEffects 1.0
import custom.licht 1.0
6
import ".."
Leander Schulten's avatar
Leander Schulten committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

ControlItem{
    id:item
    blockWidth: 3
    blockHeight: 1
    pressed: controlData?controlData.activated:false
    onPressedChanged: {
        if(controlData.activated){
            play.opacity = 0;
        }else{
            play.opacity = 1;
        }
    }
    ControlItemBlock{
        Image {
            anchors.margins: 1
            anchors.fill:parent
            id: play
25
            source: "/icons/play.svg"
Leander Schulten's avatar
Leander Schulten committed
26
27
28
29
30
31
32
33
34
35
            Behavior on opacity {
                NumberAnimation{
                    duration: 100
                }
            }
        }
        Image {
            anchors.margins: 1
            anchors.fill:parent
            id: pause
36
            source: "/icons/pause.svg"
Leander Schulten's avatar
Leander Schulten committed
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
            opacity: 1-play.opacity
        }
        Rectangle{
            id:disabledRect
            color: "black"
            opacity: 0.3
            anchors.left: play.left
            anchors.right: play.right
            anchors.bottom: play.bottom
        }

        NumberAnimation {
            id: disabledRectAni
            target: disabledRect
            property: "height"
            easing.type: Easing.Linear
            from: play.height
            to: 0;
            onStarted: mouseArea.enabled = false;
            onStopped: mouseArea.enabled = true;
        }
        MouseArea{
            id:mouseArea
            anchors.fill:parent
            onClicked: {
                controlData.activated=!controlData.activated;
                if(controlData.activated){
                    disabledRectAni.duration = controlData.activateCooldown
                }else{
                    disabledRectAni.duration = controlData.deactivateCooldown
                }
                disabledRectAni.start()
            }

        }
    }

    ControlItemBlock{
        blockWidth: 2
        Label{
            elide: Text.ElideRight
            anchors.fill: parent
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            text: controlData?controlData.name:"null"
        }
    }

    popup: Popup{
        id:popup
        GridLayout{
            columns: 2
            Label{
                text:"Name  : "
                Layout.bottomMargin: 5
            }
            TextInputField{
                enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_GROUP_NAME);
                Layout.fillWidth: true
                text: controlData?controlData.name:"null"
                onTextChanged: if(controlData)controlData.name = text
            }

            Label{
                text:"Activate Cooldown"
            }
            TextInputField{
                Layout.fillWidth: true
                text: controlData?controlData.activateCooldown:100
                validator: IntValidator{
                    bottom:0
                    top:100000
                }
                onTextChanged: if(controlData)controlData.activateCooldown = text
                Text{
                    text:"ms"
                    x : parent.contentWidth
                    anchors.verticalCenter: parent.verticalCenter
                }
                enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_TIMEOUTS)
            }

            Label{
                text:"Deactivate Cooldown"
            }
            TextInputField{
                Layout.fillWidth: true
                text: controlData?controlData.deactivateCooldown:100
                validator: IntValidator{
                    bottom:0
                    top:100000
                }
                onTextChanged: if(controlData)controlData.deactivateCooldown = text
                Text{
                    text:"ms"
                    x : parent.contentWidth
                    anchors.verticalCenter: parent.verticalCenter
                }
                enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_TIMEOUTS)
            }


            Label{
                text:"Geräte : "
            }
            TextInputField{
                Layout.fillWidth: true
                id:search

                Text{
                    color: "grey"
                    anchors.baseline: parent.baseline
                    visible: parent.text.length===0
                    text: "search"
                }
            }

            ListView{
                enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_GROUP_DEVICES);
                Layout.columnSpan: 2
                width: 200
                height: 125
                clip:true
                model: controlData?controlData.groupModel:null
                delegate: CheckDelegate{
                    width: 200
                    text: itemData.name
                    visible: itemData.name.startsWith(search.text,Qt.CaseInsensitive)
Leander Schulten's avatar
Leander Schulten committed
165
                    height: itemData.name.startsWith(search.text,Qt.CaseInsensitive) ? implicitHeight : 0;
Leander Schulten's avatar
Leander Schulten committed
166
167
168
169
170
171
172
173
174
175
                    checked: use

                    onCheckedChanged: use = checked

                }
            }
        }
        closePolicy: Popup.CloseOnPressOutside
    }
}