summaryrefslogtreecommitdiffstats
path: root/animators/test/Control.qml
blob: 5bd77882ccbb7cc56edb6a9206d9a4f606afcfb3 (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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import QtQuick 2.0

Rectangle {
    id: control

    property bool testing: false
    property bool running: false
    property bool paused: false
    property bool blocking: false

    onBlockingChanged: {
        blockerStopTimer.running = blocking
    }

    Timer {
        id: blockerStartTimer
        interval: 1500
        repeat: false
        running: true
        onTriggered: control.blocking = true
    }

    Timer {
        id: blockerStopTimer
        interval: 20000
        repeat: false
        running: false
        onTriggered: control.blocking = false
    }

    width: 320
    height: 65
    color: "#2e2e2e"

    Rectangle {
        width: parent.width
        height: 4
        gradient: Gradient {
                GradientStop { position: 1.0; color: "#2e2e2e" }
                GradientStop { position: 0.0; color: "black" }
            }
    }

    Row {
        x: 10
        y: 10
        spacing: 5
        Rectangle {
            width: 70
            height: 40
            color: "#3e3e3e"
            Text {
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                anchors.fill: parent
                text: "Back"
                color: "white"
                font.pixelSize: 14
                font.family: "Nokia Pure Text"
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        control.testing = !control.testing
                        control.running = false
                        control.paused = false
                        control.blocking = false
                        main.state = ""
                    }
                }
            }
        }

        Rectangle {
            id: pauseButton
            width: 70
            height: 40
            color: "#3e3e3e"
            Text {
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                anchors.fill: parent
                text: control.paused ? "Continue" : "Pause"
                color: "white"
                font.pixelSize: 14
                font.family: "Nokia Pure Text"
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        control.paused = !control.paused
                    }
                }
            }
            Text {
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.top: parent.bottom
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                text: "Paused"
                color: "red"
                font.pixelSize: 10
                visible: control.paused
            }
        }

        Rectangle {
            id: stopButton
            width: 70
            height: 40
            color: "#3e3e3e"
            Text {
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                anchors.fill: parent
                text: control.running ? "Stop" : "Start"
                color: "white"
                font.pixelSize: 14
                font.family: "Nokia Pure Text"
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        control.running = !control.running
                    }
                }
            }
            Text {
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.top: parent.bottom
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                text: "Running"
                color: "red"
                font.pixelSize: 10
                visible: control.running
            }
        }

        Rectangle {
            id: blockButton
            width: 70
            height: 40
            color: "#3e3e3e"
            Text {
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                anchors.fill: parent
                text: control.blocking ? "No block" : "Block"
                color: "white"
                font.pixelSize: 14
                font.family: "Nokia Pure Text"
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        control.blocking = !control.blocking
                    }
                }
            }
            Text {
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.top: parent.bottom
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                text: "Blocking"
                color: "red"
                font.pixelSize: 10
                visible: control.blocking
            }
        }
    }

    Timer {
        id: blockerTimer
        interval: 200
        repeat: true
        running: control.blocking
        onTriggered: blocker()
        function blocker() {
            var date = new Date();
            while (new Date().getTime() - date.getTime() < 100) {
                var x = 1 + 2;
            }
        }
    }
}