This repository was archived by the owner on Jan 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
177 lines (160 loc) · 3.35 KB
/
main.qml
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
import QtQuick 2.0
//import QtQuick.Controls 1.2
Rectangle {
id: page
width: 320; height: 480
color: "#454545"
property var onColor: "#FF8C00"
property var onPressedColor: "#FF6900"
property var offColor: "#656565"
property var onTextColor: "#FFFFFF"
property var offTextColor: "black"
property var clockStart: 20000
Settings {
id: settings
visible: false
}
// TODO: create only one method called switchClocks
function startTwo() {
if (player2.running == false) {
player1.running = false
player1.cellColor = offColor
player1.textColor = offTextColor
player2.startTime = new Date().getTime()
player2.running = true
pause.visible= true
player2.cellColor = onColor
player2.textColor = onTextColor
}
}
function startOne() {
if (player1.running == false) {
player2.running = false
player2.cellColor = offColor
player2.textColor = offTextColor
player1.startTime = new Date().getTime()
player1.running = true
pause.visible = true
player1.cellColor = onColor
player1.textColor = onTextColor
}
}
function pauseClocks() {
player1.running = false
player2.running = false
pause.visible = false
player2.cellColor = offColor
player2.textColor = offTextColor
player1.cellColor = offColor
player1.textColor = offTextColor
}
function resetClocks() {
pauseClocks()
player1.timeLeft = clockStart
player2.timeLeft = clockStart
player1.cellText = player1.computeText(clockStart/1000)
player2.cellText = player2.computeText(clockStart/1000)
}
Time {
id: player1
cellColor: offColor
anchors {
top: page.top
left: page.left
right: page.right
leftMargin: 10
rightMargin: 10
topMargin: 10
}
rotation: 180
onReleased: startTwo()
onPressed: cellColor = onPressedColor
}
Time {
id: player2
cellColor: offColor
anchors {
bottom: page.bottom
left: page.left
right: page.right
leftMargin: 10
rightMargin: 10
bottomMargin: 10
}
onReleased: startOne()
onPressed: cellColor = onPressedColor
}
Rectangle {
id: pause
color: page.color
height: page.height/10
width: height
visible: false
anchors {
horizontalCenter: page.horizontalCenter
verticalCenter: page.verticalCenter
}
Rectangle {
id: leftBar
color: offColor
width: pause.width/3
height: pause.height
smooth: true
radius: 1
anchors.left: pause.left
anchors.leftMargin: pause.width/12
}
Rectangle {
id: rightBar
color: offColor
width: pause.width/3
height: pause.height
smooth: true
radius: 1
anchors.right: pause.right
anchors.rightMargin: pause.width/12
}
MouseArea {
anchors.fill: parent
onClicked: pauseClocks()
}
}
Reset {
id: reset
color: page.color
darkgrey: page.color
lightgrey: page.offColor
height: page.height/10
width: height
}
Rectangle {
id: settingsButton
color: "white"
signal clicked()
height: page.height/10
width: height
// TODO: remove at the end
smooth: true
radius: 2
Text {
text: "Sett."
font.pointSize: 11
anchors {
verticalCenter: settingsButton.verticalCenter
horizontalCenter: settingsButton.horizontalCenter
}
}
anchors {
verticalCenter: page.verticalCenter
leftMargin: player1.anchors.leftMargin
left: page.left
}
MouseArea {
anchors.fill: parent
onClicked: {
pauseClocks()
settings.visible = true
}
}
}
}