21
21
import Ubuntu.Components 0.1
22
import Ubuntu.Components.Popups 0.1
23
import Ubuntu.Components.ListItems 0.1 as ListItem
24
23
import "../common/Constants.js" as Constants
24
import "../common/ClockUtils.js" as Utils
25
25
import "TimerScript.js" as TScript
28
anchors.margins: units.gu(2)
30
30
property bool timerOn: false
31
property real seconds: 0;
32
property real secondsAddTimer: 0;
32
property int seconds: 0;
33
property int minutes: 0;
34
property int hours: 0;
35
property int totalTime: 0;
36
property int timerValue: 0;
34
38
Component.onCompleted: {
35
TScript.log("TimerPage loaded");
39
Utils.log("TimerPage loaded");
42
// Timer function called by the main clock loop
38
43
function onTimerUpdate() {
39
44
if(timerOn == true) {
40
TScript.countDown(seconds)
44
anchors.margins: units.gu(2)
54
height: parent.height / 4
56
horizontalAlignment: Text.AlignHCenter
57
verticalAlignment: Text.AlignVCenter
60
if (text == "00:00:00") {
62
} else if (text != "00:00:00" && timerOn == false) {
64
} else if (text != "00:00:00" && timerOn == true) {
70
text: i18n.tr("00:00:00")
76
width: parent.width / 2
77
height: parent.height / 4
89
horizontalAlignment: Text.AlignHCenter
90
verticalAlignment: Text.AlignVCenter
91
anchors.centerIn: parent
93
color: Constants.ubuntuOrange
101
if (seconds > 0 && (buttonTimer.state != "STOP" && buttonTimer.state != "DONE")) {
103
labelTimer.text = TScript.setlabelTimer(seconds);
104
if(labelTimer.text != "00:00:00") {
105
buttonTimer.state = "START";
107
buttonTimer.state = "PRESETS";
119
width: parent.width / 2
120
height: parent.height / 4
46
timerHand.rotationAngle = seconds * 6;
50
// Timer label hh:mm:ss
53
spacing: units.gu(0.3)
124
left: buttonMinus.right
129
height: parent.height
137
horizontalAlignment: Text.AlignHCenter
138
verticalAlignment: Text.AlignVCenter
139
anchors.centerIn: parent
141
color: Constants.ubuntuOrange
149
if (buttonTimer.state != "STOP" && buttonTimer.state != "DONE") {
151
labelTimer.text = TScript.setlabelTimer(seconds);
152
if(labelTimer.text != "00:00:00") {
153
buttonTimer.state = "START";
155
buttonTimer.state = "PRESETS";
56
horizontalCenter: parent.horizontalCenter
58
topMargin: units.gu(6)
64
// flag boolean variable to determine if the timer hand adjusts the hours or not
65
property bool flag: false
67
color: Constants.normalGrey
77
/* FIXME: According to design the hour label should only be shown when the
78
minutes hand is moved beyond 59 minutes. The logic for this has not been
79
implemented yet in this code.
81
// TODO: Change this to false later. As of now the hour label is always shown.
89
timerHand.rotationAngle = hours * 6;
90
hourslabelTimer.color = Constants.ubuntuOrange;
91
hourslabelTimer.flag = true;
92
secondslabelTimer.color = Constants.normalGrey;
93
secondslabelTimer.flag = false;
94
minuteslabelTimer.color = Constants.normalGrey;
95
minuteslabelTimer.flag = false;
103
color: Constants.normalGrey
105
if (hourslabelTimer.visible) {
118
id: minuteslabelTimer
120
// flag boolean variable to determine if the timer hand adjusts the minutes or not
121
property bool flag: false
123
color: Constants.normalGrey
132
timerHand.rotationAngle = minutes * 6;
133
minuteslabelTimer.color = Constants.ubuntuOrange;
134
minuteslabelTimer.flag = true;
135
secondslabelTimer.color = Constants.normalGrey;
136
secondslabelTimer.flag = false;
137
hourslabelTimer.color = Constants.normalGrey;
138
hourslabelTimer.flag = false;
146
color: Constants.normalGrey
153
id: secondslabelTimer
155
// flag boolean variable to determine if the timer hand adjusts the minutes or not
156
property bool flag: false
158
color: Constants.normalGrey
167
timerHand.rotationAngle = seconds * 6;
168
secondslabelTimer.color = Constants.ubuntuOrange;
169
secondslabelTimer.flag = true;
170
minuteslabelTimer.color = Constants.normalGrey;
171
minuteslabelTimer.flag = false;
172
hourslabelTimer.color = Constants.normalGrey;
173
hourslabelTimer.flag = false;
165
182
id: clockOuterCircle
184
// Implements touch support
186
id: timerbackmousearea
188
property real truex: mouseX - clockOuterCircle.width/2
189
property real truey: clockOuterCircle.height/2 - mouseY
190
property real angle: Math.atan2(truex, truey)
191
property real strictangle: parseInt(angle * 180 / Math.PI)
192
property real modulo: strictangle % 6
194
/* Touch support to move timer hand should only be enabled when the timer is off,
195
and the user has clicked on any of the second, minute and hour label.
201
else if (secondslabelTimer.flag) {
204
else if (minuteslabelTimer.flag) {
207
else if (hourslabelTimer.flag) {
216
preventStealing: true // move only Timer hand and ensures that the sideway motion of pages do not interrupt moving the clock hand
217
onPositionChanged: if (buttonTimer.state != "STOP" && buttonTimer.state != "DONE") {
218
if (timerbackmousearea.angle < 0) {
219
timerHand.rotationAngle = strictangle - modulo + 360;
220
timerValue = parseInt(timerHand.rotationAngle/6);
222
if (secondslabelTimer.flag) {
223
secondslabelTimer.text = Utils.zeroleft(timerValue, 2);
224
seconds = timerValue;
227
if (minuteslabelTimer.flag) {
228
minuteslabelTimer.text = Utils.zeroleft(timerValue, 2);
229
minutes = timerValue;
232
if (hourslabelTimer.flag) {
233
hourslabelTimer.text = Utils.zeroleft(timerValue, 2);
237
if(secondslabelTimer.text != "00" || minuteslabelTimer.text != "00" || hourslabelTimer.text != "00") {
238
buttonTimer.state = "START";
240
buttonTimer.state = "PRESETS";
244
timerHand.rotationAngle = strictangle - modulo + 6;
245
timerValue = parseInt(timerHand.rotationAngle/6);
247
if (secondslabelTimer.flag) {
248
secondslabelTimer.text = Utils.zeroleft(timerValue, 2);
249
seconds = timerValue;
252
if (minuteslabelTimer.flag) {
253
minuteslabelTimer.text = Utils.zeroleft(timerValue, 2);
254
minutes = timerValue;
257
if (hourslabelTimer.flag) {
258
hourslabelTimer.text = Utils.zeroleft(timerValue, 2);
262
if(secondslabelTimer.text != "00" || minuteslabelTimer.text != "00" || hourslabelTimer.text != "00") {
263
buttonTimer.state = "START";
265
buttonTimer.state = "PRESETS";
168
model: ["1", "2", "4", "5", "7", "8", "10", "11"]
170
273
delegate: AnalogClockMarker {
174
277
color: Constants.pitchBlack
314
horizontalCenter: clockOuterCircle.horizontalCenter
315
bottom: clockOuterCircle.top
325
verticalCenter: clockOuterCircle.verticalCenter
326
left: clockOuterCircle.right
336
horizontalCenter: clockOuterCircle.horizontalCenter
337
top: clockOuterCircle.bottom
347
verticalCenter: clockOuterCircle.verticalCenter
348
right: clockOuterCircle.left
359
property string title: i18n.tr("Title")
360
property string popuptext: i18n.tr("Text")
362
anchors.centerIn: parent
370
anchors.centerIn: parent
372
color: Constants.brightWhite
373
border.color: Constants.ubuntuOrange
382
height: parent.height / 4
386
topMargin: units.gu(2)
388
horizontalAlignment: Text.AlignHCenter
390
color: Constants.ubuntuOrange
392
text: i18n.tr(myPopup.title)
402
horizontalCenter: parent.horizontalCenter
403
bottom: parent.bottom
404
bottomMargin: units.gu(2)
407
color: Constants.ubuntuOrange
408
text: i18n.tr(myPopup.popuptext)
411
myPopup.visible = false;
439
height: parent.height / 4
441
horizontalAlignment: Text.AlignHCenter
442
verticalAlignment: Text.AlignVCenter
445
if (text == "00:00:00") {
446
Constants.normalGrey;
447
} else if (text != "00:00:00" && timerOn == false) {
449
} else if (text != "00:00:00" && timerOn == true) {
450
Constants.pitchBlack;
455
text: i18n.tr("00:00:00")
459
id: buttonMinusAddTimer
461
width: parent.width / 2
462
height: parent.height / 4
466
height: parent.height
474
horizontalAlignment: Text.AlignHCenter
475
verticalAlignment: Text.AlignVCenter
476
anchors.centerIn: parent
478
color: Constants.ubuntuOrange
486
if (secondsAddTimer > 0) {
487
secondsAddTimer -= 60;
488
labelAddTimer.text = TScript.setlabelTimer(secondsAddTimer);
497
id: buttonPlusAddTimer
499
width: parent.width / 2
500
height: parent.height / 4
503
top: buttonMinusAddTimer.top
504
left: buttonMinusAddTimer.right
509
height: parent.height
517
horizontalAlignment: Text.AlignHCenter
518
verticalAlignment: Text.AlignVCenter
519
anchors.centerIn: parent
521
color: Constants.ubuntuOrange
529
secondsAddTimer += 60;
530
labelAddTimer.text = TScript.setlabelTimer(secondsAddTimer);
543
anchors.top: labelAddTimer.bottom
547
anchors.horizontalCenter: parent.horizontalCenter
554
placeholderText: i18n.tr("Timer's name")
562
color: Constants.ubuntuOrange
566
if (textTimerName.text != "" && secondsAddTimer > 0) {
567
storageTimer.setTimerValue(textTimerName.text +" ("+ TScript.setlabelTimer(secondsAddTimer) +")", secondsAddTimer);
570
PopupUtils.close(popupTimer)
571
PopupUtils.open(setupTimer, buttonTimer)
576
Button { //this button is just for test
582
color: Constants.ubuntuOrange
583
text: i18n.tr("View")
586
storageTimer.deleteTable("Timer");
593
anchors.top: textboxTimerName.bottom
595
text: i18n.tr("SavedTimer")
606
top: timerHeader.bottom
609
model: storageTimer.getTimerLabel()
613
delegate: ListItem.Standard {
617
seconds = storageTimer.getValue(text)
618
labelTimer.text = TScript.setlabelTimer(seconds)
619
buttonTimer.state = "START"
620
PopupUtils.close(popupTimer)
489
tools: ToolbarActions {
491
objectName: "add-preset"
493
iconSource: Qt.resolvedUrl("../images/add.png")
494
text: i18n.tr("Add Preset")
497
console.log("You clicked me")
498
addPresetCircleDone.visible = true
506
iconSource: Qt.resolvedUrl("../images/add.png")
507
text: i18n.tr("Edit")
510
console.log("You clicked me")
511
addPresetCircleDone.visible = false