Merge lp:~nik90/ubuntu-clock-app/dialer-transition into lp:ubuntu-clock-app/saucy

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Michael Zanetti
Approved revision: 303
Merged at revision: 286
Proposed branch: lp:~nik90/ubuntu-clock-app/dialer-transition
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 1610 lines (+462/-855)
19 files modified
alarm/AddAlarmPage.qml (+14/-53)
alarm/AlarmFace.qml (+52/-0)
alarm/AlarmPage.qml (+4/-9)
alarm/AnalogAlarm.qml (+0/-72)
clock/AnalogClockFace.qml (+0/-72)
clock/ClockPage.qml (+21/-6)
common/AnalogClockHand.qml (+0/-50)
common/AnalogFaceBase.qml (+0/-149)
common/AnalogGlowEffect.qml (+1/-1)
common/AnalogTouchHand.qml (+0/-108)
common/ClockBase.qml (+94/-0)
common/ClockUtils.js (+11/-0)
stopwatch/AnalogStopwatch.qml (+0/-128)
stopwatch/StopwatchFace.qml (+91/-0)
stopwatch/StopwatchPage.qml (+25/-25)
tests/autopilot/ubuntu_clock_app/emulators.py (+10/-10)
timer/AnalogTimer.qml (+0/-121)
timer/TimerFace.qml (+99/-0)
timer/TimerPage.qml (+40/-51)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/dialer-transition
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Michael Zanetti (community) Approve
Ubuntu Clock Developers Pending
Review via email: mp+200740@code.launchpad.net

Commit message

Transitions the clock app to use the SDK Dialer widget

Description of the change

Transitions the clock app to use the SDK Dialer widget

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Pope 🍺🐧🐱 🦄 (popey) wrote :

Ran 12 tests in 257.827s
OK

Passed autopilot tests on nexus 4.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Noticed a small issue with the timer hand animation. I have a fix in mind. Will comment again when that is ready.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

18 + // The range of the analogue clock is 0-60 while the alarm hours should be between 00-23. Hence the factor 23/60
19 + alarmTime.setHours(Math.round(addAlarmFace.hours*23/60), Math.round(addAlarmFace.minutes), 0)

Could it make sense to create a function hoursToCirclePosition() instead of copy pasting this all over the place?

===

1079 + model: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]

model: 23
should be enough

===

803 + // Property to help with the naming of the clock hands for autopilot purposes
804 + property string objectBase: "Default"

I think it would be cleaner to drop this and change the autopilot tests to do a 2 step search. eg.

select_single(objectName="clockPage").select_single(objectName="hourHandAlarm")

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Timer animation glitch fixed. Ready for review!

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
297. By Nekhelesh Ramananthan

Simplified repeater stopwatch face model

298. By Nekhelesh Ramananthan

Removed objectBase and adjusted autopilot tests for it

299. By Nekhelesh Ramananthan

Tweaked timer text update duration to 250ms to match timerhand animation duration

300. By Nekhelesh Ramananthan

Added functions hourstoCirclePosition() and circlePositiontoHours() in add alarm page

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

>
> 1079 + model: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
> "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]
>
> model: 23
> should be enough
>

Fixed in rev 297

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> 18 + // The range of the analogue clock is 0-60 while the alarm hours
> should be between 00-23. Hence the factor 23/60
> 19 + alarmTime.setHours(Math.round(addAlarmFace.hours*23/60),
> Math.round(addAlarmFace.minutes), 0)
>
> Could it make sense to create a function hoursToCirclePosition() instead of
> copy pasting this all over the place?
>

Fixed in rev 300

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

>
> 803 + // Property to help with the naming of the clock hands for autopilot
> purposes
> 804 + property string objectBase: "Default"
>
> I think it would be cleaner to drop this and change the autopilot tests to do
> a 2 step search. eg.
>
> select_single(objectName="clockPage").select_single(objectName="hourHandAlarm"
> )

Fixed in rev 298

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Also reduced timer text update duration from 500 to 250ms in rev 299

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

88 + // The range of the analogue clock is 0-60 while the alarm hours should be between 00-23. Hence the factor 23/60

This comment can now go, no?

===

175 + onMinutesChanged: innerLabel.text = Utils.zeroleft(hours*23/60, 2) + ":" + Utils.zeroleft(minutes, 2)

Seems its also used in the Alarms stuff. Maybe it belongs into Utils?

301. By Nekhelesh Ramananthan

moved functions hourstocircleposition() and circlepositiontohours() to ClockUtils.js

302. By Nekhelesh Ramananthan

Fixed clock hand position

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> 88 + // The range of the analogue clock is 0-60 while the alarm hours
> should be between 00-23. Hence the factor 23/60
>
> This comment can now go, no?
>

Absolutely. I missed it before. Fixed in rev 301

>
> 175 + onMinutesChanged: innerLabel.text = Utils.zeroleft(hours*23/60, 2) +
> ":" + Utils.zeroleft(minutes, 2)
>
> Seems its also used in the Alarms stuff. Maybe it belongs into Utils?

I think for this commit, moving to Utils makes sense. However this might change in the near future since the alarms page should technically follow a similar behaviour to the clock page where the hours range is between 0-12 instead of 0-24. However that will come only after design approval.

Fixed in rev 301.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
303. By Nekhelesh Ramananthan

Missed one alarm statement

Revision history for this message
Michael Zanetti (mzanetti) wrote :

lgtm

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'alarm/AddAlarmPage.qml'
2--- alarm/AddAlarmPage.qml 2013-12-29 20:53:56 +0000
3+++ alarm/AddAlarmPage.qml 2014-01-10 14:02:26 +0000
4@@ -62,8 +62,6 @@
5 if (status != Alarm.Ready)
6 return;
7 if ((operation > Alarm.NoOperation) && (operation < Alarm.Reseting)) {
8- reset();
9- resetPage()
10 pagestack.pop();
11 }
12 }
13@@ -72,7 +70,8 @@
14 // Function to save a new alarm
15 function saveNewAlarm() {
16 var alarmTime = new Date();
17- alarmTime.setHours(addAlarmFace.hours, addAlarmFace.minutes, 0)
18+
19+ alarmTime.setHours(Utils.hourstoCirclePosition(addAlarmFace.hours), Math.round(addAlarmFace.minutes), 0)
20
21 alarm.message = nameAlarm.text
22 alarm.date = alarmTime
23@@ -101,32 +100,25 @@
24 alarm.enabled = temp_alarm.enabled
25 alarm.date = temp_alarm.date
26
27- addAlarmFace.hours = Qt.formatTime(alarm.date, "hh")
28- addAlarmFace.hourHandRotation = addAlarmFace.hours * 15
29+ addAlarmFace.hours = Utils.circlePositiontoHours(Qt.formatTime(alarm.date, "hh"))
30 addAlarmFace.minutes = Qt.formatTime(alarm.date, "mm")
31- addAlarmFace.minuteHandRotation = addAlarmFace.minutes * 6
32 }
33
34 function updateAlarm() {
35 var temp_alarm = alarmModel.get(alarmIndex)
36
37 var alarmTime = new Date()
38- alarmTime.setHours(addAlarmFace.hours, addAlarmFace.minutes, 0)
39+
40+ alarmTime.setHours(Utils.hourstoCirclePosition(addAlarmFace.hours), Math.round(addAlarmFace.minutes), 0)
41
42 temp_alarm.message = nameAlarm.text
43 temp_alarm.type = alarm.type
44 temp_alarm.daysOfWeek = alarm.daysOfWeek
45 temp_alarm.date = alarmTime
46 temp_alarm.save()
47- resetPage()
48 pagestack.pop()
49 }
50
51- function resetPage() {
52- addAlarmFace.hours = addAlarmFace.minutes = 0;
53- addAlarmFace.hourHandRotation = addAlarmFace.minuteHandRotation = 0
54- }
55-
56 Timer {
57 id: errorTimer
58 interval: 1000
59@@ -149,58 +141,27 @@
60 spacing: units.gu(1)
61 anchors { left: parent.left; right: parent.right; top: parent.top; topMargin: units.gu(5)}
62
63- AnalogFaceBase {
64+ ClockBase {
65 id: addAlarmFace
66
67- property int hours: 0
68- property int minutes: 0
69- property alias hourHandRotation: hourHand.rotationValue
70- property alias minuteHandRotation: minuteHand.rotationValue
71+ draggable: true
72+ showSecondHand: false
73
74- onMinutesChanged: innerLabel.text = Utils.zeroleft(addAlarmFace.hours, 2) + ":" + Utils.zeroleft(addAlarmFace.minutes, 2);
75- onHoursChanged: innerLabel.text = Utils.zeroleft(addAlarmFace.hours, 2) + ":" + Utils.zeroleft(addAlarmFace.minutes, 2);
76+ onMinutesChanged: innerLabel.text = Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2);
77+ onHoursChanged: innerLabel.text = Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2);
78
79 innerLabel.objectName: "labelAlarm"
80- innerLabel.text: Utils.zeroleft(addAlarmFace.hours, 2) + ":" + Utils.zeroleft(addAlarmFace.minutes, 2)
81+ innerLabel.text: Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2)
82
83 anchors.horizontalCenter: parent.horizontalCenter
84
85- // Hour hand with touch/mouse drag support
86- AnalogTouchHand {
87- id: hourHand
88- objectName: "hourHand"
89-
90- onTimerValueChanged: addAlarmFace.hours = timerValue;
91-
92- perAngle: 15;
93- totalValue: 24;
94- handHeight: units.gu(12.5); handWidth: units.gu(1);
95- z: minuteHand.z + 1;
96- animateFlag: false;
97- enabled: true;
98- grabMargin: units.gu(3);
99- }
100-
101- // Minute hand with touch/mouse drag support
102- AnalogTouchHand {
103- id: minuteHand
104-
105- onTimerValueChanged: addAlarmFace.minutes = timerValue;
106-
107- handHeight: units.gu(14.5); handWidth: units.gu(0.5);
108- animateFlag: false;
109- enabled: true;
110- grabMargin: units.gu(0)
111- grabHeight: units.gu(7)
112- }
113-
114 Label {
115 id: errorLabel
116 visible: false
117- z: addAlarmFace.innerCircle.z + 1
118+ parent: addAlarmFace.centerItem
119 anchors {
120- centerIn: addAlarmFace.innerCircle
121- fill: addAlarmFace.innerCircle
122+ centerIn: parent
123+ fill: parent
124 margins: units.gu(2)
125 }
126 horizontalAlignment: Text.AlignHCenter
127
128=== added file 'alarm/AlarmFace.qml'
129--- alarm/AlarmFace.qml 1970-01-01 00:00:00 +0000
130+++ alarm/AlarmFace.qml 2014-01-10 14:02:26 +0000
131@@ -0,0 +1,52 @@
132+/*
133+ * Copyright (C) 2013 Canonical Ltd
134+ *
135+ * This program is free software: you can redistribute it and/or modify
136+ * it under the terms of the GNU General Public License version 3 as
137+ * published by the Free Software Foundation.
138+ *
139+ * This program is distributed in the hope that it will be useful,
140+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
141+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
142+ * GNU General Public License for more details.
143+ *
144+ * You should have received a copy of the GNU General Public License
145+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
146+ *
147+ * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
148+ */
149+
150+import QtQuick 2.0
151+import Ubuntu.Components 0.1
152+import "../common"
153+import "../common/ClockUtils.js" as Utils
154+
155+ClockBase {
156+ id: alarmFace
157+
158+ property alias showSetupMessage: setupMessage.visible
159+
160+ showSecondHand: false
161+
162+ onMinutesChanged: innerLabel.text = Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2)
163+ onHoursChanged: innerLabel.text = Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2)
164+
165+ innerLabel.visible: !setupMessage.visible
166+ innerLabel.text: Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2)
167+
168+ Label {
169+ id: setupMessage
170+ objectName: "labelAlarmSetup"
171+
172+ parent: alarmFace.centerItem
173+ width: parent.width; height: width;
174+ anchors.centerIn: parent
175+ horizontalAlignment: Text.AlignHCenter
176+ verticalAlignment: Text.AlignVCenter
177+ color: Theme.palette.normal.baseText
178+
179+ fontSize: "large"
180+ text: i18n.tr("Long press to setup an alarm")
181+ wrapMode: Text.WordWrap
182+ }
183+}
184
185=== modified file 'alarm/AlarmPage.qml'
186--- alarm/AlarmPage.qml 2013-10-26 19:26:49 +0000
187+++ alarm/AlarmPage.qml 2014-01-10 14:02:26 +0000
188@@ -69,7 +69,7 @@
189 nextAlarm = alarmModel.get(i)
190 }
191 nameAlarm.text = nextAlarm.message
192- alarmFace.hours = Qt.formatTime(nextAlarm.date, "hh")
193+ alarmFace.hours = Utils.circlePositiontoHours(Qt.formatTime(nextAlarm.date, "hh"))
194 alarmFace.minutes = Qt.formatTime(nextAlarm.date, "mm")
195 }
196 else {
197@@ -118,18 +118,13 @@
198 UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration }
199 }
200
201- AnalogAlarm {
202+ AlarmFace {
203 id: alarmFace
204
205 anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }
206 showSetupMessage: modelCount == 0 ? true : false
207-
208- MouseArea {
209- id: alarmMouseArea
210- anchors.fill: alarmFace.innerCircle
211- enabled: alarmFace.showSetupMessage
212- onPressAndHold: pagestack.push(Qt.resolvedUrl("AddAlarmPage.qml"), {"isNewAlarm": true})
213- }
214+ enableMouseArea: showSetupMessage
215+ onPressAndHold: pagestack.push(Qt.resolvedUrl("AddAlarmPage.qml"), {"isNewAlarm": true})
216 }
217
218 // Element to set the name of a saved preset.
219
220=== removed file 'alarm/AnalogAlarm.qml'
221--- alarm/AnalogAlarm.qml 2013-10-26 12:20:55 +0000
222+++ alarm/AnalogAlarm.qml 1970-01-01 00:00:00 +0000
223@@ -1,72 +0,0 @@
224-/*
225- * Copyright (C) 2013 Canonical Ltd
226- *
227- * This program is free software: you can redistribute it and/or modify
228- * it under the terms of the GNU General Public License version 3 as
229- * published by the Free Software Foundation.
230- *
231- * This program is distributed in the hope that it will be useful,
232- * but WITHOUT ANY WARRANTY; without even the implied warranty of
233- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
234- * GNU General Public License for more details.
235- *
236- * You should have received a copy of the GNU General Public License
237- * along with this program. If not, see <http://www.gnu.org/licenses/>.
238- *
239- * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
240- */
241-
242-import QtQuick 2.0
243-import Ubuntu.Components 0.1
244-import "../common"
245-import "../common/ClockUtils.js" as Utils
246-
247-// Component which draws the analog alarm face.
248-AnalogFaceBase {
249- id: alarmRoot
250-
251- property int hours: 0
252- property int minutes: 0
253- property alias showSetupMessage: setupMessage.visible;
254-
255- onMinutesChanged: innerLabel.text = Utils.zeroleft(hours, 2) + ":" + Utils.zeroleft(minutes, 2);
256- onHoursChanged: innerLabel.text = Utils.zeroleft(hours, 2) + ":" + Utils.zeroleft(minutes, 2)
257-
258- innerLabel.visible: !setupMessage.visible
259- innerLabel.text: Utils.zeroleft(alarmRoot.hours, 2) + ":" + Utils.zeroleft(alarmRoot.minutes, 2)
260-
261- Label {
262- id: setupMessage
263- objectName: "labelAlarmSetup"
264-
265- z: innerCircle.z + 1
266- width: innerCircle.width; height: width;
267- anchors.centerIn: alarmRoot
268- horizontalAlignment: Text.AlignHCenter
269- verticalAlignment: Text.AlignVCenter
270- color: Theme.palette.normal.baseText
271-
272- fontSize: "large"
273- text: i18n.tr("Long press \nto setup \nan alarm")
274- wrapMode: Text.WordWrap
275- }
276-
277- AnalogClockHand {
278- id: hourHand
279- objectName: "alarmHourHand"
280-
281- z: parent.z
282- handHeight: units.gu(12.5); handWidth: units.gu(1);
283- rotation: (alarmRoot.hours * 15) + (alarmRoot.minutes / 2);
284- }
285-
286- AnalogClockHand {
287- id: minuteHand
288- objectName: "alarmMinuteHand"
289-
290- z: parent.z + 1
291- handHeight: units.gu(14.5); handWidth: units.gu(0.5);
292- rotation: alarmRoot.minutes * 6;
293- }
294-
295-}
296
297=== removed file 'clock/AnalogClockFace.qml'
298--- clock/AnalogClockFace.qml 2013-10-26 12:20:55 +0000
299+++ clock/AnalogClockFace.qml 1970-01-01 00:00:00 +0000
300@@ -1,72 +0,0 @@
301-/*
302- * Copyright (C) 2013 Canonical Ltd
303- *
304- * This program is free software: you can redistribute it and/or modify
305- * it under the terms of the GNU General Public License version 3 as
306- * published by the Free Software Foundation.
307- *
308- * This program is distributed in the hope that it will be useful,
309- * but WITHOUT ANY WARRANTY; without even the implied warranty of
310- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
311- * GNU General Public License for more details.
312- *
313- * You should have received a copy of the GNU General Public License
314- * along with this program. If not, see <http://www.gnu.org/licenses/>.
315- *
316- * Authored by: Juha Ristolainen <juha.ristolainen@codemancers.fi>
317- * Nekhelesh Ramananthan <krnekhelesh@gmail.com>
318- * Nick Leppänen Larsson <frals@frals.se>
319- */
320-
321-import QtQuick 2.0
322-import Ubuntu.Components 0.1
323-import "../common"
324-
325-// Element which draws the clock face along with the hour, minute, second hand and the clock label
326-AnalogFaceBase {
327- id: clockRoot
328-
329- property var currDate: new Date;
330- property int hours: currDate.getHours()
331- property int minutes: currDate.getMinutes()
332- property int seconds: currDate.getUTCSeconds();
333-
334- signal clicked(var mouse)
335-
336- function timeChanged(now) {
337- hours = now.getHours()
338- minutes = now.getMinutes()
339- seconds = now.getUTCSeconds();
340- }
341-
342- AnalogClockHand {
343- id: hourHand
344-
345- z: parent.z
346- handHeight: units.gu(12.5); handWidth: units.gu(1);
347- rotation: (hours * 30) + (minutes / 2);
348- }
349-
350- AnalogClockHand {
351- id: minuteHand
352-
353- z: parent.z + 1
354- handHeight: units.gu(14.5); handWidth: units.gu(0.5);
355- rotation: minutes * 6;
356- }
357-
358- AnalogClockHand {
359- id: secondsHand
360-
361- z: parent.z - 1;
362- handHeight: units.gu(17); handWidth: units.gu(0.5)
363- rotation: seconds * 6;
364- }
365-
366- // Mouse area to reveal the clock sunrise/sunset on clicking the clock face
367- MouseArea {
368- anchors.fill: parent
369- z: parent.z + 1;
370- onClicked: clockRoot.clicked(mouse);
371- }
372-}
373
374=== modified file 'clock/ClockPage.qml'
375--- clock/ClockPage.qml 2013-11-07 16:35:51 +0000
376+++ clock/ClockPage.qml 2014-01-10 14:02:26 +0000
377@@ -26,7 +26,7 @@
378 import "../common"
379
380 Page {
381- id: clockPage;
382+ id: clockPage
383
384 // Property to hold the formatted time string to show on the screen
385 property string currentTimeFormatted
386@@ -113,13 +113,27 @@
387 contentWidth: parent.width
388 contentHeight: clockFace.height + clockFace.anchors.topMargin + savedWorldClock.height + savedWorldClock.anchors.topMargin + units.gu(3)
389
390- // Qml Element to draw the analogue clock face along with its hour, minute and second hands.
391- AnalogClockFace {
392+ // QML Element to draw the analogue clock face along with its hour, minute and second hands.
393+ ClockBase {
394 id: clockFace
395
396- anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }
397+ anchors {
398+ top: parent.top
399+ topMargin: units.gu(10)
400+ horizontalCenter: parent.horizontalCenter
401+ }
402+
403 innerLabel.text: currentTimeFormatted
404- innerLabel.objectName: "currentTimeLabel"
405+
406+ hours: new Date().getHours() * 5
407+ minutes: new Date().getMinutes()
408+ seconds: new Date().getUTCSeconds()
409+
410+ function timeChanged(now) {
411+ hours = now.getHours() * 5
412+ minutes = now.getMinutes()
413+ seconds = now.getUTCSeconds();
414+ }
415
416 onClicked: {
417 if (easterEggCircle.isReady == XmlListModel.Ready && worldModel.city !== "undefined")
418@@ -131,8 +145,9 @@
419
420 EasterEgg {
421 id: easterEggCircle
422+ parent: clockFace.centerItem
423 anchors.centerIn: parent
424- width: clockFace.innerCircle.width; height: width;
425+ width: clockFace.centerItem.width; height: width;
426 radius: width / 2;
427 }
428
429
430=== removed file 'common/AnalogClockHand.qml'
431--- common/AnalogClockHand.qml 2013-07-14 11:36:59 +0000
432+++ common/AnalogClockHand.qml 1970-01-01 00:00:00 +0000
433@@ -1,50 +0,0 @@
434-/*
435- * Copyright (C) 2013 Canonical Ltd
436- *
437- * This program is free software: you can redistribute it and/or modify
438- * it under the terms of the GNU General Public License version 3 as
439- * published by the Free Software Foundation.
440- *
441- * This program is distributed in the hope that it will be useful,
442- * but WITHOUT ANY WARRANTY; without even the implied warranty of
443- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
444- * GNU General Public License for more details.
445- *
446- * You should have received a copy of the GNU General Public License
447- * along with this program. If not, see <http://www.gnu.org/licenses/>.
448- *
449- * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
450- */
451-
452-import QtQuick 2.0
453-
454-// Qml component to draw the analog clock hand
455-Rectangle{
456- id: analogClockHandContainer
457-
458- property alias handHeight: analogClockHand.height
459- property alias handWidth: analogClockHand.width
460- property alias handRotationAnimation: analogClockHandRotation.enabled
461-
462- radius: width / 2
463- anchors.fill: parent
464- transformOrigin: Item.Center
465- color: "transparent";
466-
467- Rectangle {
468- id: analogClockHand
469-
470- x: (parent.width / 2) - (width / 2); y: (parent.height / 2) - height; z: 2;
471- width: units.gu(1); height: units.gu(14);
472- radius: units.gu(1)
473- color: Theme.palette.normal.baseText
474- antialiasing: true
475- }
476-
477- Behavior on rotation {
478- id: analogClockHandRotation
479- enabled: true;
480- RotationAnimation { direction: RotationAnimation.Shortest }
481- }
482-}
483-
484
485=== removed file 'common/AnalogFaceBase.qml'
486--- common/AnalogFaceBase.qml 2013-10-26 13:20:54 +0000
487+++ common/AnalogFaceBase.qml 1970-01-01 00:00:00 +0000
488@@ -1,149 +0,0 @@
489-/*
490- * Copyright (C) 2013 Canonical Ltd
491- *
492- * This program is free software: you can redistribute it and/or modify
493- * it under the terms of the GNU General Public License version 3 as
494- * published by the Free Software Foundation.
495- *
496- * This program is distributed in the hope that it will be useful,
497- * but WITHOUT ANY WARRANTY; without even the implied warranty of
498- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
499- * GNU General Public License for more details.
500- *
501- * You should have received a copy of the GNU General Public License
502- * along with this program. If not, see <http://www.gnu.org/licenses/>.
503- *
504- * Authored by: Juha Ristolainen <juha.ristolainen@codemancers.fi>
505- * Nick Leppänen Larsson <frals@frals.se>
506- */
507-
508-import QtQuick 2.0
509-import Ubuntu.Components 0.1
510-import QtGraphicalEffects 1.0
511-
512-// FIXME: Replace Rectangle with UbuntuShape when the new widget lands in the Ubuntu SDK.
513-Rectangle {
514- id: clockRoot
515-
516- property alias innerCircle: innerCircle
517- property alias innerLabel: currentTimeLabel
518- property real offset : units.gu(0.2)
519-
520- width: units.gu(32); height: units.gu(32)
521- radius: width / 2
522- antialiasing: true
523-
524- // Current time label
525- Label {
526- id: currentTimeLabel
527-
528- z: innerCircle.z + 1
529- width: innerCircle.width; height: width;
530- anchors.centerIn: parent
531- horizontalAlignment: Text.AlignHCenter
532- verticalAlignment: Text.AlignVCenter
533- color: Theme.palette.normal.baseText
534- font.pixelSize: units.dp(41)
535- }
536-
537- gradient: Gradient {
538- GradientStop { position: 0.0; color: "#512F48" }
539- GradientStop { position: 0.25; color: "#583048" }
540- GradientStop { position: 0.5; color: "#653449" }
541- GradientStop { position: 0.75; color: "#6D384A" }
542- GradientStop { position: 1.0; color: "#753B4A" }
543- }
544-
545- // Draws the outter shadow/highlight
546- Rectangle {
547- id: sourceOutter
548- anchors { fill: parent; margins: -offset }
549- radius: (width / 2)
550- antialiasing: true
551- gradient: Gradient {
552- GradientStop { position: 0.0; color: "black" }
553- GradientStop { position: 0.5; color: "transparent" }
554- GradientStop { position: 1.0; color: "white" }
555- }
556- }
557-
558- // Mask for outer 3D effect
559- Rectangle {
560- id: maskOutter
561- anchors.fill: sourceOutter
562- color: "transparent"
563- radius: (width / 2)
564- antialiasing: true
565- border { width: offset; color: "black" }
566- }
567-
568- // Outter effect
569- OpacityMask {
570- anchors.fill: sourceOutter
571- opacity: 0.65
572- source: ShaderEffectSource {
573- sourceItem: sourceOutter
574- hideSource: true
575- }
576- maskSource: ShaderEffectSource {
577- sourceItem: maskOutter
578- hideSource: true
579- }
580- }
581-
582- // FIXME: Replace this with UbuntuShape when the widget has landed in the SDK.
583- Rectangle {
584- id: innerCircle
585-
586- z: parent.z + 2
587- height: units.gu(19); width: units.gu(19)
588- radius: width / 2
589- anchors.centerIn: parent
590- antialiasing: true
591-
592- gradient: Gradient {
593- GradientStop { position: 0.0; color: "#7A4C68" }
594- GradientStop { position: 0.25; color: "#804563" }
595- GradientStop { position: 0.5; color: "#864660" }
596- GradientStop { position: 0.75; color: "#86465E" }
597- GradientStop { position: 1.0; color: "#964E66" }
598- }
599-
600- // Draws the inner highlight / shadow
601- Rectangle {
602- id: sourceInner;
603- anchors { fill: parent; margins: -offset }
604- radius: (width / 2)
605- antialiasing: true
606- gradient: Gradient {
607- GradientStop { position: 0.0; color: "white" }
608- GradientStop { position: 0.5; color: "transparent" }
609- GradientStop { position: 1.0; color: "black" }
610- }
611- }
612-
613- // Mask for inner 3D effect
614- Rectangle {
615- id: maskInner
616- color: "transparent"
617- anchors.fill: sourceInner
618- radius: (width / 2)
619- antialiasing: true
620- border { width: offset; color: "black" }
621- }
622-
623- // Inner effect
624- OpacityMask {
625- opacity: 0.65
626- anchors.fill: sourceInner
627- source: ShaderEffectSource {
628- sourceItem: sourceInner
629- hideSource: true
630- }
631- maskSource: ShaderEffectSource {
632- sourceItem: maskInner
633- hideSource: true
634- }
635- }
636- }
637-}
638
639=== modified file 'common/AnalogGlowEffect.qml'
640--- common/AnalogGlowEffect.qml 2013-08-09 22:11:05 +0000
641+++ common/AnalogGlowEffect.qml 2014-01-10 14:02:26 +0000
642@@ -29,6 +29,6 @@
643 glowRadius: 10
644 spread: 0.8
645 color: "orange"
646- cornerRadius: fillRectangle.radius
647+ cornerRadius: fillRectangle.size
648 z: fillRectangle - 1
649 }
650
651=== removed file 'common/AnalogTouchHand.qml'
652--- common/AnalogTouchHand.qml 2013-09-04 10:35:41 +0000
653+++ common/AnalogTouchHand.qml 1970-01-01 00:00:00 +0000
654@@ -1,108 +0,0 @@
655-/*
656- * Copyright (C) 2013 Canonical Ltd
657- *
658- * This program is free software: you can redistribute it and/or modify
659- * it under the terms of the GNU General Public License version 3 as
660- * published by the Free Software Foundation.
661- *
662- * This program is distributed in the hope that it will be useful,
663- * but WITHOUT ANY WARRANTY; without even the implied warranty of
664- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
665- * GNU General Public License for more details.
666- *
667- * You should have received a copy of the GNU General Public License
668- * along with this program. If not, see <http://www.gnu.org/licenses/>.
669- *
670- * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
671- */
672-
673-import QtQuick 2.0
674-import Ubuntu.Components 0.1
675-import "../common"
676-
677-// Qml item to enable touch input to the AnalogClockHand component
678-Item {
679- id: touchHand;
680-
681- z: parent.z;
682- width: parent.width; height: width;
683- anchors.centerIn: parent;
684-
685- property int totalValue: 60;
686- property int perAngle: 6;
687-
688- /*!
689- Enable/Disable rotation animation. Disable it while dragging the clock hand to avoid
690- receiving inaccurate input values.
691- */
692- property alias animateFlag: hand.handRotationAnimation
693-
694- /*!
695- Set if the dial should be rotated by the seconds, minutes or hours. This generally needs to be
696- multiplied by 6 to convert it into degrees per second/hour/minute.
697- */
698- property alias rotationValue: hand.rotation;
699-
700- // Set the touch/mouse grab area height and top margin
701- property alias grabHeight: grabArea.height;
702- property int grabMargin: units.gu(0);
703-
704- // Height and width of the clock hand
705- property alias handHeight: hand.handHeight;
706- property alias handWidth: hand.handWidth;
707-
708- // internal properties required for the functioning of the AnalogTouchHand
709- property int timerValue: 0
710- property real centerX : width / 2
711- property real centerY : height / 2
712-
713- // Clock hand which lies above the rotating dial. This is stationary w.r.t to the rotating dial.
714- AnalogClockHand {
715- id: hand
716-
717- handHeight: units.gu(0); handWidth: units.gu(0);
718-
719- /*!
720- Element to define the grab area of the clock hand. This allows us to define small clock hand
721- which are still easier to grab.
722- */
723- Rectangle {
724- id: grabArea
725- color: "transparent"
726- width: units.gu(5); height: width;
727- anchors { top: hand.top; topMargin: touchHand.grabMargin; horizontalCenter: hand.horizontalCenter }
728- }
729-
730- MouseArea{
731- anchors.fill: grabArea;
732- preventStealing: true;
733- enabled: true;
734- onPositionChanged: {
735- var point = mapToItem (touchHand, mouse.x, mouse.y);
736- var diffX = (point.x - touchHand.centerX);
737- var diffY = -1 * (point.y - touchHand.centerY);
738- var rad = Math.atan (diffY / diffX);
739- var deg = (rad * 180 / Math.PI);
740-
741- if (diffX > 0 && diffY > 0) {
742- hand.rotation = 90 - Math.abs (deg);
743- }
744- else if (diffX > 0 && diffY < 0) {
745- hand.rotation = 90 + Math.abs (deg);
746- }
747- else if (diffX < 0 && diffY > 0) {
748- hand.rotation = 270 + Math.abs (deg);
749- }
750- else if (diffX < 0 && diffY < 0) {
751- hand.rotation = 270 - Math.abs (deg);
752- }
753-
754- if (Math.round(hand.rotation/perAngle) === totalValue) {
755- touchHand.timerValue = 0
756- } else {
757- touchHand.timerValue = Math.round(hand.rotation/perAngle);
758- }
759- }
760- }
761- }
762-}
763
764=== added file 'common/ClockBase.qml'
765--- common/ClockBase.qml 1970-01-01 00:00:00 +0000
766+++ common/ClockBase.qml 2014-01-10 14:02:26 +0000
767@@ -0,0 +1,94 @@
768+/*
769+ * Copyright (C) 2013 Canonical Ltd
770+ *
771+ * This program is free software: you can redistribute it and/or modify
772+ * it under the terms of the GNU General Public License version 3 as
773+ * published by the Free Software Foundation.
774+ *
775+ * This program is distributed in the hope that it will be useful,
776+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
777+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
778+ * GNU General Public License for more details.
779+ *
780+ * You should have received a copy of the GNU General Public License
781+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
782+ *
783+ * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
784+ */
785+
786+import QtQuick 2.0
787+import Ubuntu.Components 0.1
788+import Ubuntu.Components.Pickers 0.1
789+
790+/*
791+ Basic component to draw the analogue clock with hour, minute and second hands.
792+ */
793+Dialer {
794+ id: clockRoot
795+
796+ // Properties to set the clock hands position
797+ property alias hours: _hourHand.value
798+ property alias minutes: _minuteHand.value
799+ property alias seconds: _secondHand.value
800+
801+ // Property to set the label shown in the inner circle
802+ property alias innerLabel: _currentTimeLabel
803+
804+ // Property to individually hide the hour and minute hand in timer and alarm
805+ property bool showHourHand: true
806+ property bool showSecondHand: true
807+
808+ // Property to enable/disable the mouse area of the inner circle.
809+ property bool enableMouseArea: true
810+
811+ // Property to set if the clock hands are adjustable by the user
812+ property bool draggable: false
813+
814+ signal clicked(var mouse)
815+ signal pressAndHold(var mouse)
816+
817+ minimumValue: 0
818+ maximumValue: 60
819+ size: units.gu(32)
820+
821+ DialerHand {
822+ id: _hourHand
823+ objectName: "hourHand"
824+ hand.draggable: draggable
825+ hand.visible: showHourHand
826+ }
827+
828+ DialerHand {
829+ id: _minuteHand
830+ objectName: "minuteHand"
831+ hand.draggable: draggable
832+ }
833+
834+ DialerHand {
835+ id: _secondHand
836+ objectName: "secondHand"
837+ hand.draggable: draggable
838+ hand.visible: showSecondHand
839+ }
840+
841+ centerContent: [
842+ Label {
843+ id: _currentTimeLabel
844+ objectName: "label"
845+ anchors.centerIn: parent
846+ horizontalAlignment: Text.AlignHCenter
847+ verticalAlignment: Text.AlignVCenter
848+ font.pixelSize: units.dp(41)
849+ }
850+ ]
851+
852+ // Mouse area to reveal the clock sunrise/sunset on clicking the clock face
853+ MouseArea {
854+ parent: clockRoot.centerItem
855+ anchors.fill: parent
856+ enabled: enableMouseArea
857+ z: parent.z + 1;
858+ onClicked: clockRoot.clicked(mouse);
859+ onPressAndHold: clockRoot.pressAndHold(mouse);
860+ }
861+}
862
863=== modified file 'common/ClockUtils.js'
864--- common/ClockUtils.js 2013-09-12 17:22:30 +0000
865+++ common/ClockUtils.js 2014-01-10 14:02:26 +0000
866@@ -43,3 +43,14 @@
867 function numberToLocaleString( num ) {
868 return Number(num).toLocaleString(Qt.locale(), "f", 0)
869 }
870+
871+// Function to convert hours to clock hand positions.
872+// The range of the analogue clock is 0-60 while the hours should be between 00-23. Hence the factor 23/60
873+function hourstoCirclePosition(hours) {
874+ return Math.round(hours * 23/60)
875+}
876+
877+// Function to convert clock hand positions to hours (24-hours)
878+function circlePositiontoHours(position) {
879+ return Math.round(position * 60/23)
880+}
881
882=== removed file 'stopwatch/AnalogStopwatch.qml'
883--- stopwatch/AnalogStopwatch.qml 2013-09-14 06:20:48 +0000
884+++ stopwatch/AnalogStopwatch.qml 1970-01-01 00:00:00 +0000
885@@ -1,128 +0,0 @@
886-/*
887- * Copyright (C) 2013 Canonical Ltd
888- *
889- * This program is free software: you can redistribute it and/or modify
890- * it under the terms of the GNU General Public License version 3 as
891- * published by the Free Software Foundation.
892- *
893- * This program is distributed in the hope that it will be useful,
894- * but WITHOUT ANY WARRANTY; without even the implied warranty of
895- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
896- * GNU General Public License for more details.
897- *
898- * You should have received a copy of the GNU General Public License
899- * along with this program. If not, see <http://www.gnu.org/licenses/>.
900- *
901- * Authored by: Alessandro Pozzi <signor.hyde@gmail.com>
902- * Nekhelesh Ramananthan <krnekhelesh@gmail.com>
903- */
904-
905-import QtQuick 2.0
906-import Ubuntu.Components 0.1
907-import "StopwatchSupport.js" as SScript
908-import "../common"
909-
910-// This component draws the stopwatch analog UI and defines different UI modes like normal and easteregg.
911-AnalogFaceBase {
912- id: analogStopwatch
913-
914- property var startTime: 0;
915- property var stopTime: 0;
916- property int delay : 0;
917- property bool flag: true;
918- property int totalTime: 0;
919-
920- property int hours: 0;
921- property int minutes: 0;
922- property int seconds: 0;
923- property int milliseconds: 0;
924- property int decimalgradient: 0;
925-
926- // Sets the location and visible (bool) values of the blip (small circle visible when the lap button is pressed)
927- property alias blipLocation: blipFist.location;
928- property alias blipVisible: blipFist.visible;
929-
930- // Retrieves the status of the stopwatch timer
931- property bool timerStatus: stopwatchUIUpdate.running
932-
933- function reset() {
934- decimalgradient = totalTime = milliseconds = seconds = minutes = hours = 0
935- SScript.deltaTime[0] = SScript.deltaTime[1] = SScript.deltaTime[2] = SScript.deltaTime[3] = 0
936- startTime = stopTime = delay = 0;
937- flag = true;
938- }
939-
940- function start() {
941- stopwatchUIUpdate.start()
942- }
943-
944- function stop() {
945- stopwatchUIUpdate.stop()
946- }
947-
948- // Timer which runs every 100 microseconds to update the time and also the trailing hand gradient.
949- Timer {
950- id: stopwatchUIUpdate
951-
952- interval: 100
953- repeat: true
954- onTriggered: {
955- totalTime = SScript.delta();
956- SScript.deltaTime = SScript.msToTime(totalTime)
957- hours = SScript.deltaTime[0];
958- minutes = SScript.deltaTime[1];
959- seconds = SScript.deltaTime[2];
960- milliseconds = SScript.deltaTime[3];
961- decimalgradient = minutes * 10;
962- }
963- }
964-
965- // This component draws the small orange circle that is visible everytime the lap button is pressed.
966- Blip {
967- id: blipFist
968- }
969-
970- // This component draws the trailing shadow of the second hand.
971- HandGradient {
972- id: gradientSecond
973- rotationAngle: minutes * 6
974- decimalGradient: decimalgradient
975- }
976-
977- Repeater {
978- id:stopwatchMarkers
979-
980- model: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]
981-
982- delegate: AnalogClockMarker {
983- number: modelData
984- total: 24;
985- size: 0.2
986- distance: 0.32
987- }
988- }
989-
990- AnalogClockHand {
991- id: hourHand
992-
993- z: parent.z
994- handHeight: units.gu(12.5); handWidth: units.gu(1);
995- rotation: hours * 15;
996- }
997-
998- AnalogClockHand {
999- id: minuteHand
1000-
1001- z: parent.z
1002- handHeight: units.gu(14.5); handWidth: units.gu(0.5);
1003- rotation: minutes * 6;
1004- }
1005-
1006- AnalogClockHand {
1007- id: secondHand
1008-
1009- z: parent.z - 1;
1010- handHeight: units.gu(17); handWidth: units.gu(0.5)
1011- rotation: seconds * 6;
1012- }
1013-}
1014
1015=== added file 'stopwatch/StopwatchFace.qml'
1016--- stopwatch/StopwatchFace.qml 1970-01-01 00:00:00 +0000
1017+++ stopwatch/StopwatchFace.qml 2014-01-10 14:02:26 +0000
1018@@ -0,0 +1,91 @@
1019+/*
1020+ * Copyright (C) 2013 Canonical Ltd
1021+ *
1022+ * This program is free software: you can redistribute it and/or modify
1023+ * it under the terms of the GNU General Public License version 3 as
1024+ * published by the Free Software Foundation.
1025+ *
1026+ * This program is distributed in the hope that it will be useful,
1027+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1028+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1029+ * GNU General Public License for more details.
1030+ *
1031+ * You should have received a copy of the GNU General Public License
1032+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1033+ *
1034+ * Authored by: Alessandro Pozzi <signor.hyde@gmail.com>
1035+ * Nekhelesh Ramananthan <krnekhelesh@gmail.com>
1036+ */
1037+
1038+import QtQuick 2.0
1039+import Ubuntu.Components 0.1
1040+import "StopwatchSupport.js" as SScript
1041+import "../common"
1042+
1043+ClockBase {
1044+ id: stopwatchFace
1045+
1046+ // Properties to store/set the time variables
1047+ property var startTime: 0
1048+ property var stopTime: 0
1049+ property int delay : 0
1050+ property bool flag: true
1051+ property int totalTime: 0
1052+ property int milliseconds: 0
1053+
1054+ // Sets the location and visible (bool) values of the blip (small circle visible when the lap button is pressed)
1055+ property alias blipLocation: blipFist.location
1056+ property alias blipVisible: blipFist.visible
1057+
1058+ // Retrieves the status of the stopwatch timer
1059+ property bool timerStatus: stopwatchUIUpdate.running
1060+
1061+ function reset() {
1062+ totalTime = milliseconds = seconds = minutes = hours = 0
1063+ SScript.deltaTime[0] = SScript.deltaTime[1] = SScript.deltaTime[2] = SScript.deltaTime[3] = 0
1064+ startTime = stopTime = delay = 0;
1065+ flag = true;
1066+ }
1067+
1068+ function start() {
1069+ stopwatchUIUpdate.start()
1070+ }
1071+
1072+ function stop() {
1073+ stopwatchUIUpdate.stop()
1074+ }
1075+
1076+ // Timer which runs every 100 microseconds to update the time and also the trailing hand gradient.
1077+ Timer {
1078+ id: stopwatchUIUpdate
1079+
1080+ interval: 100
1081+ repeat: true
1082+ onTriggered: {
1083+ totalTime = SScript.delta();
1084+ SScript.deltaTime = SScript.msToTime(totalTime)
1085+ hours = SScript.deltaTime[0];
1086+ minutes = SScript.deltaTime[1];
1087+ seconds = SScript.deltaTime[2];
1088+ milliseconds = SScript.deltaTime[3];
1089+ }
1090+ }
1091+
1092+ // This component draws the small white circle that is visible everytime the lap button is pressed.
1093+ Blip {
1094+ id: blipFist
1095+ }
1096+
1097+ Repeater {
1098+ id:stopwatchMarkers
1099+
1100+ model: 24
1101+
1102+ delegate: AnalogClockMarker {
1103+ number: modelData
1104+ total: 24;
1105+ size: 0.2
1106+ distance: 0.32
1107+ }
1108+ }
1109+}
1110
1111=== modified file 'stopwatch/StopwatchPage.qml'
1112--- stopwatch/StopwatchPage.qml 2013-11-05 13:12:48 +0000
1113+++ stopwatch/StopwatchPage.qml 2014-01-10 14:02:26 +0000
1114@@ -63,34 +63,34 @@
1115 contentHeight: analogStopwatch.height + analogStopwatch.anchors.topMargin + listLap.height + listLap.anchors.topMargin + units.gu(3)
1116
1117 // Component which draws the analog stopwatch face, controls the timer and calculates the time.
1118- AnalogStopwatch {
1119+ StopwatchFace {
1120 id: analogStopwatch
1121- objectName: "buttonStopwatch"
1122-
1123- anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }
1124-
1125- innerLabel.objectName: "labelStopwatch"
1126+ objectName: "stopwatchFace"
1127+
1128+ anchors {
1129+ top: parent.top
1130+ topMargin: units.gu(10)
1131+ horizontalCenter: parent.horizontalCenter
1132+ }
1133+
1134 innerLabel.text: SScript.timeToString(analogStopwatch.hours, analogStopwatch.minutes, analogStopwatch.seconds, analogStopwatch.milliseconds)
1135
1136- MouseArea {
1137- anchors.fill: analogStopwatch.innerCircle;
1138- onClicked: {
1139- if(analogStopwatch.timerStatus == false) {
1140- analogStopwatch.start()
1141- stopWatchLabelUpdate.start()
1142- if (analogStopwatch.flag) {
1143- analogStopwatch.startTime = new Date().getTime();
1144- analogStopwatch.flag = false;
1145- }
1146- else {
1147- analogStopwatch.delay = Math.abs(new Date().getTime() - analogStopwatch.stopTime);
1148- analogStopwatch.startTime = analogStopwatch.startTime + analogStopwatch.delay;
1149- }
1150- } else {
1151- analogStopwatch.stop()
1152- stopWatchLabelUpdate.stop()
1153- analogStopwatch.stopTime = new Date().getTime();
1154- }
1155+ onClicked: {
1156+ if(analogStopwatch.timerStatus == false) {
1157+ analogStopwatch.start()
1158+ stopWatchLabelUpdate.start()
1159+ if (analogStopwatch.flag) {
1160+ analogStopwatch.startTime = new Date().getTime();
1161+ analogStopwatch.flag = false;
1162+ }
1163+ else {
1164+ analogStopwatch.delay = Math.abs(new Date().getTime() - analogStopwatch.stopTime);
1165+ analogStopwatch.startTime = analogStopwatch.startTime + analogStopwatch.delay;
1166+ }
1167+ } else {
1168+ analogStopwatch.stop()
1169+ stopWatchLabelUpdate.stop()
1170+ analogStopwatch.stopTime = new Date().getTime();
1171 }
1172 }
1173 }
1174
1175=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
1176--- tests/autopilot/ubuntu_clock_app/emulators.py 2013-11-07 16:35:51 +0000
1177+++ tests/autopilot/ubuntu_clock_app/emulators.py 2014-01-10 14:02:26 +0000
1178@@ -66,7 +66,7 @@
1179
1180 def get_time_label(self):
1181 """Return the label with the timer countdown"""
1182- return self.wait_select_single("Label", objectName="currentTimeLabel")
1183+ return self.select_single("ClockPage").wait_select_single("Label", objectName="label")
1184
1185 # WORLD CLOCK Page Emulator Functions
1186 def get_world_cities_page(self):
1187@@ -108,7 +108,7 @@
1188
1189 def get_timer_minute_hand(self):
1190 """Returns the hour hand of clock in timer tab"""
1191- return self.wait_select_single("AnalogTouchHand", objectName="minuteHand")
1192+ return self.select_single("TimerPage").wait_select_single("DialerHand", objectName="minuteHand")
1193
1194 def get_preset_label_text(self):
1195 """Returns the label with the preset text"""
1196@@ -122,7 +122,7 @@
1197
1198 def get_label_timer(self):
1199 """Return the label with the timer countdown"""
1200- return self.wait_select_single("Label", objectName="labelTimer")
1201+ return self.select_single("TimerPage").wait_select_single("Label", objectName="label")
1202
1203 def get_first_preset_list_item(self):
1204 """Returns the first preset list item in the timer page."""
1205@@ -136,12 +136,12 @@
1206 # STOPWATCH Page Emulator Functions
1207 def get_stopwatch_label(self):
1208 """Returns the select for the stopwatch label"""
1209- return self.wait_select_single("Label", objectName="labelStopwatch")
1210+ return self.select_single("StopwatchPage").wait_select_single("Label", objectName="label")
1211
1212 def get_stopwatch_button(self):
1213 """Returns the select for the stopwatch button"""
1214- return self.wait_select_single("AnalogStopwatch",
1215- objectName="buttonStopwatch")
1216+ return self.wait_select_single("StopwatchFace",
1217+ objectName="stopwatchFace")
1218
1219 def get_lap_button(self):
1220 """Returns the select for the lap button"""
1221@@ -233,13 +233,13 @@
1222
1223 def get_alarm_minute_hand(self):
1224 """Returns the hour hand of clock in alarm tab"""
1225- return self.select_single("AnalogClockHand",
1226- objectName="alarmMinuteHand")
1227+ return self.select_single("AlarmPage").select_single("DialerHand",
1228+ objectName="minuteHand")
1229
1230 def get_alarm_hour_hand(self):
1231 """Returns the hour hand of clock in alarm tab"""
1232- return self.select_single("AnalogClockHand",
1233- objectName="alarmHourHand")
1234+ return self.select_single("AlarmPage").select_single("DialerHand",
1235+ objectName="hourHand")
1236
1237 def set_alarm_week(self, day, test_case):
1238 #TODO: add support for setting days of week
1239
1240=== removed file 'timer/AnalogTimer.qml'
1241--- timer/AnalogTimer.qml 2013-10-26 12:20:55 +0000
1242+++ timer/AnalogTimer.qml 1970-01-01 00:00:00 +0000
1243@@ -1,121 +0,0 @@
1244-/*
1245- * Copyright (C) 2013 Canonical Ltd
1246- *
1247- * This program is free software: you can redistribute it and/or modify
1248- * it under the terms of the GNU General Public License version 3 as
1249- * published by the Free Software Foundation.
1250- *
1251- * This program is distributed in the hope that it will be useful,
1252- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1253- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1254- * GNU General Public License for more details.
1255- *
1256- * You should have received a copy of the GNU General Public License
1257- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1258- *
1259- * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
1260- */
1261-
1262-import QtQuick 2.0
1263-import Ubuntu.Components 0.1
1264-import "../common"
1265-
1266-// Component which draws the analog timer face.
1267-AnalogFaceBase {
1268- id: clockOuterCircle
1269-
1270- property var startTime: 0;
1271- property var remTime: 0;
1272-
1273- // Properties to store/set the time variables
1274- property int seconds: 0;
1275- property int minutes: 0;
1276- property int totalTime: 0;
1277- property int pauseTime: 0;
1278-
1279- // Property to activate/deactivate the timer
1280- property bool timerOn: false;
1281- property bool inProgressFlag
1282-
1283- // Timer function called by the main clock loop
1284- function onTimerUpdate () {
1285- if( timerOn ) {
1286- inProgressFlag = true;
1287- remTime = totalTime - Math.floor((new Date() - startTime)/ 1000) - pauseTime;
1288-
1289- if (remTime < 0) {
1290- timerOn = false
1291- totalTime = -1;
1292- } else {
1293- ssToTime(remTime);
1294- }
1295- }
1296- }
1297-
1298- // Function to convert time (in seconds) to hh:mm:ss format
1299- function ssToTime(time) {
1300- seconds = time % 60
1301- time = Math.floor(time / 60)
1302- minutes = time % 60
1303- secondHand.rotationValue = seconds * 6;
1304- minuteHand.rotationValue = minutes * 6;
1305- }
1306-
1307- // Function to disable timer and reset time
1308- Timer {
1309- id: reset_timer
1310-
1311- interval: 200
1312- repeat: false
1313- onTriggered: {
1314- inProgressFlag = true;
1315- minuteHand.rotationValue = secondHand.rotationValue = 0;
1316- inProgressFlag = false;
1317- }
1318- }
1319-
1320- function reset() {
1321- reset_timer.start();
1322- timerOn = false;
1323- state = "";
1324- startTime = remTime = pauseTime = 0;
1325- minutes = seconds = totalTime = 0;
1326- minuteHand.timerValue = secondHand.timerValue = 0;
1327- }
1328-
1329- Repeater {
1330- model: 12
1331- delegate: AnalogClockMarker {
1332- number: index
1333- size: 0.5
1334- distance: 0.48
1335- }
1336- }
1337-
1338- // Minute hand with touch/mouse drag support
1339- AnalogTouchHand {
1340- id: minuteHand
1341- objectName: "minuteHand"
1342-
1343- onTimerValueChanged: minutes = timerValue;
1344-
1345- handHeight: units.gu(14.5); handWidth: units.gu(0.5);
1346- animateFlag: inProgressFlag;
1347- enabled: !inProgressFlag;
1348- grabMargin: units.gu(0)
1349- grabHeight: units.gu(7)
1350- }
1351-
1352- // Second hand with touch/mouse drag support
1353- AnalogTouchHand {
1354- id: secondHand
1355-
1356- onTimerValueChanged: seconds = timerValue;
1357-
1358- handHeight: units.gu(17); handWidth: units.gu(0.5);
1359- z: parent.z - 1;
1360- animateFlag: inProgressFlag;
1361- enabled: !inProgressFlag;
1362- grabMargin: -units.gu(2)
1363- }
1364-}
1365
1366=== added file 'timer/TimerFace.qml'
1367--- timer/TimerFace.qml 1970-01-01 00:00:00 +0000
1368+++ timer/TimerFace.qml 2014-01-10 14:02:26 +0000
1369@@ -0,0 +1,99 @@
1370+/*
1371+ * Copyright (C) 2013 Canonical Ltd
1372+ *
1373+ * This program is free software: you can redistribute it and/or modify
1374+ * it under the terms of the GNU General Public License version 3 as
1375+ * published by the Free Software Foundation.
1376+ *
1377+ * This program is distributed in the hope that it will be useful,
1378+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1379+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1380+ * GNU General Public License for more details.
1381+ *
1382+ * You should have received a copy of the GNU General Public License
1383+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1384+ *
1385+ * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
1386+ */
1387+
1388+import QtQuick 2.0
1389+import Ubuntu.Components 0.1
1390+import "../common"
1391+
1392+ClockBase {
1393+ id: timerFace
1394+
1395+ // Properties to store/set the time variables
1396+ property var startTime: 0;
1397+ property var remTime: 0;
1398+ property int totalTime: 0;
1399+ property int pauseTime: 0;
1400+
1401+ // Property to activate/deactivate the timer
1402+ property bool timerOn: false;
1403+ property bool inProgressFlag
1404+
1405+ // Property to expose the timer outer glow effect to outside objects
1406+ property alias glowEffect: _glowEffect
1407+
1408+ showHourHand: false
1409+ draggable: !inProgressFlag
1410+
1411+ // Timer function called by the main clock loop
1412+ function onTimerUpdate () {
1413+ if( timerOn ) {
1414+ inProgressFlag = true;
1415+ remTime = totalTime - Math.floor((new Date() - startTime)/ 1000) - pauseTime;
1416+
1417+ if (remTime < 0) {
1418+ timerOn = false
1419+ totalTime = -1;
1420+ } else {
1421+ ssToTime(remTime);
1422+ }
1423+ }
1424+ }
1425+
1426+ // Function to convert time (in seconds) to hh:mm:ss format
1427+ function ssToTime(time) {
1428+ seconds = time % 60
1429+ time = Math.floor(time / 60)
1430+ minutes = time % 60
1431+ }
1432+
1433+ // This timer to required to avoid rare occurences of the timer hand being stuck at the place where it was stopped
1434+ // when the reset button is pressed while the timer is running.
1435+ Timer {
1436+ id: reset_timer
1437+ interval: 200
1438+ repeat: false
1439+ onTriggered: {
1440+ inProgressFlag = true;
1441+ inProgressFlag = false;
1442+ }
1443+ }
1444+
1445+ function reset() {
1446+ reset_timer.start()
1447+ timerOn = false;
1448+ state = "";
1449+ startTime = remTime = pauseTime = 0;
1450+ minutes = seconds = totalTime = 0;
1451+ }
1452+
1453+ AnalogGlowEffect {
1454+ id: _glowEffect
1455+ z: parent.z - 1
1456+ visible: false;
1457+ fillRectangle: parent
1458+ }
1459+
1460+ Repeater {
1461+ model: 12
1462+ delegate: AnalogClockMarker {
1463+ number: index
1464+ size: 0.5
1465+ distance: 0.48
1466+ }
1467+ }
1468+}
1469
1470=== modified file 'timer/TimerPage.qml'
1471--- timer/TimerPage.qml 2013-11-26 15:36:37 +0000
1472+++ timer/TimerPage.qml 2014-01-10 14:02:26 +0000
1473@@ -58,7 +58,7 @@
1474 },
1475 State {
1476 name: "addPreset"
1477- PropertyChanges { target: timerMouseArea; enabled: false }
1478+ PropertyChanges { target: analogTimer; enableMouseArea: false }
1479 PropertyChanges { target: listPreset; visible: false }
1480 PropertyChanges { target: namePreset; visible: true }
1481 PropertyChanges { target: addPresetToolbarButton; visible: false }
1482@@ -84,7 +84,7 @@
1483 listPreset.listIndex = -1;
1484 namePreset.text = "";
1485 tempNamePreset = "";
1486- }
1487+ }
1488
1489 Component.onCompleted: {
1490 Utils.log("TimerPage loaded");
1491@@ -112,81 +112,70 @@
1492
1493 Behavior on contentY {
1494 UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration }
1495- }
1496+ }
1497
1498 // Main element which draws the timer face and manages time.
1499- AnalogTimer {
1500+ TimerFace {
1501 id: analogTimer
1502
1503- innerLabel.objectName: "labelTimer"
1504+ anchors {
1505+ top: parent.top
1506+ topMargin: units.gu(10)
1507+ horizontalCenter: parent.horizontalCenter
1508+ }
1509+
1510 innerLabel.text: intervalToString(minutes, seconds);
1511+
1512 Timer {
1513 id: seconds_timer
1514-
1515- interval: 500
1516+ interval: 250
1517 repeat: true
1518 onTriggered: analogTimer.innerLabel.text = intervalToString(minutes, seconds);
1519 }
1520
1521- AnalogGlowEffect {
1522- id: glowEffect
1523-
1524- z: parent.z - 1
1525- visible: false;
1526- fillRectangle: parent
1527- }
1528-
1529- anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }
1530- inProgressFlag: (timerOn == true || analogTimer.state == "DONE") ? true : false;
1531+ inProgressFlag: (timerOn === true || analogTimer.state === "DONE") ? true : false;
1532+ onMinutesChanged: innerLabel.text = intervalToString(minutes, seconds);
1533 onSecondsChanged: if (timerOn == true) seconds_timer.restart()
1534 else innerLabel.text = intervalToString(minutes, seconds);
1535-
1536- onMinutesChanged: innerLabel.text = intervalToString(minutes, seconds);
1537-
1538 states:[
1539 State { name: "STOP" },
1540 State { name: "PAUSE"},
1541 State {
1542 name: "DONE"
1543 when: (totalTime == -1 && timerOn == false)
1544- PropertyChanges { target: glowEffect; visible: true }
1545- PropertyChanges { target: glowEffect; color: "#03CB4A" }
1546+ PropertyChanges { target: analogTimer.glowEffect; visible: true }
1547+ PropertyChanges { target: analogTimer.glowEffect; color: "#03CB4A" }
1548 }
1549 ]
1550
1551- MouseArea {
1552- id: timerMouseArea
1553- anchors.fill: analogTimer.innerCircle
1554- enabled: true
1555- onClicked: {
1556- switch (analogTimer.state) {
1557-
1558- case "":
1559- if ((seconds != 0 || minutes != 0) || timerOn) {
1560- totalTime = (minutes * 60) + seconds;
1561- analogTimer.startTime = new Date();
1562- timerOn = true;
1563- analogTimer.state = "STOP";
1564- }
1565- break;
1566-
1567- case "STOP":
1568- timerOn = false;
1569- analogTimer.pauseTime = analogTimer.totalTime - analogTimer.remTime + 1; // +1 is necessary to start immediately the timer when finish a pause
1570- analogTimer.state = "PAUSE";
1571- break;
1572-
1573- case "DONE":
1574- reset();
1575- analogTimer.state = "";
1576- break;
1577-
1578- case "PAUSE":
1579+ onClicked: {
1580+ switch (analogTimer.state) {
1581+
1582+ case "":
1583+ if ((seconds != 0 || minutes != 0) || timerOn) {
1584+ totalTime = (Math.round(minutes) * 60) + seconds;
1585 analogTimer.startTime = new Date();
1586 timerOn = true;
1587 analogTimer.state = "STOP";
1588- break;
1589 }
1590+ break;
1591+
1592+ case "STOP":
1593+ timerOn = false;
1594+ analogTimer.pauseTime = analogTimer.totalTime - analogTimer.remTime + 1; // +1 is necessary to start immediately the timer when finish a pause
1595+ analogTimer.state = "PAUSE";
1596+ break;
1597+
1598+ case "DONE":
1599+ reset();
1600+ analogTimer.state = "";
1601+ break;
1602+
1603+ case "PAUSE":
1604+ analogTimer.startTime = new Date();
1605+ timerOn = true;
1606+ analogTimer.state = "STOP";
1607+ break;
1608 }
1609 }
1610 }

Subscribers

People subscribed via source and target branches