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
=== modified file 'alarm/AddAlarmPage.qml'
--- alarm/AddAlarmPage.qml 2013-12-29 20:53:56 +0000
+++ alarm/AddAlarmPage.qml 2014-01-10 14:02:26 +0000
@@ -62,8 +62,6 @@
62 if (status != Alarm.Ready)62 if (status != Alarm.Ready)
63 return;63 return;
64 if ((operation > Alarm.NoOperation) && (operation < Alarm.Reseting)) {64 if ((operation > Alarm.NoOperation) && (operation < Alarm.Reseting)) {
65 reset();
66 resetPage()
67 pagestack.pop();65 pagestack.pop();
68 }66 }
69 }67 }
@@ -72,7 +70,8 @@
72 // Function to save a new alarm70 // Function to save a new alarm
73 function saveNewAlarm() {71 function saveNewAlarm() {
74 var alarmTime = new Date();72 var alarmTime = new Date();
75 alarmTime.setHours(addAlarmFace.hours, addAlarmFace.minutes, 0)73
74 alarmTime.setHours(Utils.hourstoCirclePosition(addAlarmFace.hours), Math.round(addAlarmFace.minutes), 0)
7675
77 alarm.message = nameAlarm.text76 alarm.message = nameAlarm.text
78 alarm.date = alarmTime77 alarm.date = alarmTime
@@ -101,32 +100,25 @@
101 alarm.enabled = temp_alarm.enabled100 alarm.enabled = temp_alarm.enabled
102 alarm.date = temp_alarm.date101 alarm.date = temp_alarm.date
103102
104 addAlarmFace.hours = Qt.formatTime(alarm.date, "hh")103 addAlarmFace.hours = Utils.circlePositiontoHours(Qt.formatTime(alarm.date, "hh"))
105 addAlarmFace.hourHandRotation = addAlarmFace.hours * 15
106 addAlarmFace.minutes = Qt.formatTime(alarm.date, "mm")104 addAlarmFace.minutes = Qt.formatTime(alarm.date, "mm")
107 addAlarmFace.minuteHandRotation = addAlarmFace.minutes * 6
108 }105 }
109106
110 function updateAlarm() {107 function updateAlarm() {
111 var temp_alarm = alarmModel.get(alarmIndex)108 var temp_alarm = alarmModel.get(alarmIndex)
112109
113 var alarmTime = new Date()110 var alarmTime = new Date()
114 alarmTime.setHours(addAlarmFace.hours, addAlarmFace.minutes, 0)111
112 alarmTime.setHours(Utils.hourstoCirclePosition(addAlarmFace.hours), Math.round(addAlarmFace.minutes), 0)
115113
116 temp_alarm.message = nameAlarm.text114 temp_alarm.message = nameAlarm.text
117 temp_alarm.type = alarm.type115 temp_alarm.type = alarm.type
118 temp_alarm.daysOfWeek = alarm.daysOfWeek116 temp_alarm.daysOfWeek = alarm.daysOfWeek
119 temp_alarm.date = alarmTime117 temp_alarm.date = alarmTime
120 temp_alarm.save()118 temp_alarm.save()
121 resetPage()
122 pagestack.pop()119 pagestack.pop()
123 }120 }
124121
125 function resetPage() {
126 addAlarmFace.hours = addAlarmFace.minutes = 0;
127 addAlarmFace.hourHandRotation = addAlarmFace.minuteHandRotation = 0
128 }
129
130 Timer {122 Timer {
131 id: errorTimer123 id: errorTimer
132 interval: 1000124 interval: 1000
@@ -149,58 +141,27 @@
149 spacing: units.gu(1)141 spacing: units.gu(1)
150 anchors { left: parent.left; right: parent.right; top: parent.top; topMargin: units.gu(5)}142 anchors { left: parent.left; right: parent.right; top: parent.top; topMargin: units.gu(5)}
151143
152 AnalogFaceBase {144 ClockBase {
153 id: addAlarmFace145 id: addAlarmFace
154146
155 property int hours: 0147 draggable: true
156 property int minutes: 0148 showSecondHand: false
157 property alias hourHandRotation: hourHand.rotationValue
158 property alias minuteHandRotation: minuteHand.rotationValue
159149
160 onMinutesChanged: innerLabel.text = Utils.zeroleft(addAlarmFace.hours, 2) + ":" + Utils.zeroleft(addAlarmFace.minutes, 2);150 onMinutesChanged: innerLabel.text = Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2);
161 onHoursChanged: innerLabel.text = Utils.zeroleft(addAlarmFace.hours, 2) + ":" + Utils.zeroleft(addAlarmFace.minutes, 2);151 onHoursChanged: innerLabel.text = Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2);
162152
163 innerLabel.objectName: "labelAlarm"153 innerLabel.objectName: "labelAlarm"
164 innerLabel.text: Utils.zeroleft(addAlarmFace.hours, 2) + ":" + Utils.zeroleft(addAlarmFace.minutes, 2)154 innerLabel.text: Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2)
165155
166 anchors.horizontalCenter: parent.horizontalCenter156 anchors.horizontalCenter: parent.horizontalCenter
167157
168 // Hour hand with touch/mouse drag support
169 AnalogTouchHand {
170 id: hourHand
171 objectName: "hourHand"
172
173 onTimerValueChanged: addAlarmFace.hours = timerValue;
174
175 perAngle: 15;
176 totalValue: 24;
177 handHeight: units.gu(12.5); handWidth: units.gu(1);
178 z: minuteHand.z + 1;
179 animateFlag: false;
180 enabled: true;
181 grabMargin: units.gu(3);
182 }
183
184 // Minute hand with touch/mouse drag support
185 AnalogTouchHand {
186 id: minuteHand
187
188 onTimerValueChanged: addAlarmFace.minutes = timerValue;
189
190 handHeight: units.gu(14.5); handWidth: units.gu(0.5);
191 animateFlag: false;
192 enabled: true;
193 grabMargin: units.gu(0)
194 grabHeight: units.gu(7)
195 }
196
197 Label {158 Label {
198 id: errorLabel159 id: errorLabel
199 visible: false160 visible: false
200 z: addAlarmFace.innerCircle.z + 1161 parent: addAlarmFace.centerItem
201 anchors {162 anchors {
202 centerIn: addAlarmFace.innerCircle163 centerIn: parent
203 fill: addAlarmFace.innerCircle164 fill: parent
204 margins: units.gu(2)165 margins: units.gu(2)
205 }166 }
206 horizontalAlignment: Text.AlignHCenter167 horizontalAlignment: Text.AlignHCenter
207168
=== added file 'alarm/AlarmFace.qml'
--- alarm/AlarmFace.qml 1970-01-01 00:00:00 +0000
+++ alarm/AlarmFace.qml 2014-01-10 14:02:26 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21import "../common"
22import "../common/ClockUtils.js" as Utils
23
24ClockBase {
25 id: alarmFace
26
27 property alias showSetupMessage: setupMessage.visible
28
29 showSecondHand: false
30
31 onMinutesChanged: innerLabel.text = Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2)
32 onHoursChanged: innerLabel.text = Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2)
33
34 innerLabel.visible: !setupMessage.visible
35 innerLabel.text: Utils.zeroleft(Utils.hourstoCirclePosition(hours), 2) + ":" + Utils.zeroleft(minutes, 2)
36
37 Label {
38 id: setupMessage
39 objectName: "labelAlarmSetup"
40
41 parent: alarmFace.centerItem
42 width: parent.width; height: width;
43 anchors.centerIn: parent
44 horizontalAlignment: Text.AlignHCenter
45 verticalAlignment: Text.AlignVCenter
46 color: Theme.palette.normal.baseText
47
48 fontSize: "large"
49 text: i18n.tr("Long press to setup an alarm")
50 wrapMode: Text.WordWrap
51 }
52}
053
=== modified file 'alarm/AlarmPage.qml'
--- alarm/AlarmPage.qml 2013-10-26 19:26:49 +0000
+++ alarm/AlarmPage.qml 2014-01-10 14:02:26 +0000
@@ -69,7 +69,7 @@
69 nextAlarm = alarmModel.get(i)69 nextAlarm = alarmModel.get(i)
70 }70 }
71 nameAlarm.text = nextAlarm.message71 nameAlarm.text = nextAlarm.message
72 alarmFace.hours = Qt.formatTime(nextAlarm.date, "hh")72 alarmFace.hours = Utils.circlePositiontoHours(Qt.formatTime(nextAlarm.date, "hh"))
73 alarmFace.minutes = Qt.formatTime(nextAlarm.date, "mm")73 alarmFace.minutes = Qt.formatTime(nextAlarm.date, "mm")
74 }74 }
75 else {75 else {
@@ -118,18 +118,13 @@
118 UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration }118 UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration }
119 }119 }
120120
121 AnalogAlarm {121 AlarmFace {
122 id: alarmFace122 id: alarmFace
123123
124 anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }124 anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }
125 showSetupMessage: modelCount == 0 ? true : false125 showSetupMessage: modelCount == 0 ? true : false
126126 enableMouseArea: showSetupMessage
127 MouseArea {127 onPressAndHold: pagestack.push(Qt.resolvedUrl("AddAlarmPage.qml"), {"isNewAlarm": true})
128 id: alarmMouseArea
129 anchors.fill: alarmFace.innerCircle
130 enabled: alarmFace.showSetupMessage
131 onPressAndHold: pagestack.push(Qt.resolvedUrl("AddAlarmPage.qml"), {"isNewAlarm": true})
132 }
133 }128 }
134129
135 // Element to set the name of a saved preset.130 // Element to set the name of a saved preset.
136131
=== removed file 'alarm/AnalogAlarm.qml'
--- alarm/AnalogAlarm.qml 2013-10-26 12:20:55 +0000
+++ alarm/AnalogAlarm.qml 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21import "../common"
22import "../common/ClockUtils.js" as Utils
23
24// Component which draws the analog alarm face.
25AnalogFaceBase {
26 id: alarmRoot
27
28 property int hours: 0
29 property int minutes: 0
30 property alias showSetupMessage: setupMessage.visible;
31
32 onMinutesChanged: innerLabel.text = Utils.zeroleft(hours, 2) + ":" + Utils.zeroleft(minutes, 2);
33 onHoursChanged: innerLabel.text = Utils.zeroleft(hours, 2) + ":" + Utils.zeroleft(minutes, 2)
34
35 innerLabel.visible: !setupMessage.visible
36 innerLabel.text: Utils.zeroleft(alarmRoot.hours, 2) + ":" + Utils.zeroleft(alarmRoot.minutes, 2)
37
38 Label {
39 id: setupMessage
40 objectName: "labelAlarmSetup"
41
42 z: innerCircle.z + 1
43 width: innerCircle.width; height: width;
44 anchors.centerIn: alarmRoot
45 horizontalAlignment: Text.AlignHCenter
46 verticalAlignment: Text.AlignVCenter
47 color: Theme.palette.normal.baseText
48
49 fontSize: "large"
50 text: i18n.tr("Long press \nto setup \nan alarm")
51 wrapMode: Text.WordWrap
52 }
53
54 AnalogClockHand {
55 id: hourHand
56 objectName: "alarmHourHand"
57
58 z: parent.z
59 handHeight: units.gu(12.5); handWidth: units.gu(1);
60 rotation: (alarmRoot.hours * 15) + (alarmRoot.minutes / 2);
61 }
62
63 AnalogClockHand {
64 id: minuteHand
65 objectName: "alarmMinuteHand"
66
67 z: parent.z + 1
68 handHeight: units.gu(14.5); handWidth: units.gu(0.5);
69 rotation: alarmRoot.minutes * 6;
70 }
71
72}
730
=== removed file 'clock/AnalogClockFace.qml'
--- clock/AnalogClockFace.qml 2013-10-26 12:20:55 +0000
+++ clock/AnalogClockFace.qml 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Juha Ristolainen <juha.ristolainen@codemancers.fi>
17 * Nekhelesh Ramananthan <krnekhelesh@gmail.com>
18 * Nick LeppΓ€nen Larsson <frals@frals.se>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import "../common"
24
25// Element which draws the clock face along with the hour, minute, second hand and the clock label
26AnalogFaceBase {
27 id: clockRoot
28
29 property var currDate: new Date;
30 property int hours: currDate.getHours()
31 property int minutes: currDate.getMinutes()
32 property int seconds: currDate.getUTCSeconds();
33
34 signal clicked(var mouse)
35
36 function timeChanged(now) {
37 hours = now.getHours()
38 minutes = now.getMinutes()
39 seconds = now.getUTCSeconds();
40 }
41
42 AnalogClockHand {
43 id: hourHand
44
45 z: parent.z
46 handHeight: units.gu(12.5); handWidth: units.gu(1);
47 rotation: (hours * 30) + (minutes / 2);
48 }
49
50 AnalogClockHand {
51 id: minuteHand
52
53 z: parent.z + 1
54 handHeight: units.gu(14.5); handWidth: units.gu(0.5);
55 rotation: minutes * 6;
56 }
57
58 AnalogClockHand {
59 id: secondsHand
60
61 z: parent.z - 1;
62 handHeight: units.gu(17); handWidth: units.gu(0.5)
63 rotation: seconds * 6;
64 }
65
66 // Mouse area to reveal the clock sunrise/sunset on clicking the clock face
67 MouseArea {
68 anchors.fill: parent
69 z: parent.z + 1;
70 onClicked: clockRoot.clicked(mouse);
71 }
72}
730
=== modified file 'clock/ClockPage.qml'
--- clock/ClockPage.qml 2013-11-07 16:35:51 +0000
+++ clock/ClockPage.qml 2014-01-10 14:02:26 +0000
@@ -26,7 +26,7 @@
26import "../common"26import "../common"
2727
28Page {28Page {
29 id: clockPage;29 id: clockPage
3030
31 // Property to hold the formatted time string to show on the screen31 // Property to hold the formatted time string to show on the screen
32 property string currentTimeFormatted32 property string currentTimeFormatted
@@ -113,13 +113,27 @@
113 contentWidth: parent.width113 contentWidth: parent.width
114 contentHeight: clockFace.height + clockFace.anchors.topMargin + savedWorldClock.height + savedWorldClock.anchors.topMargin + units.gu(3)114 contentHeight: clockFace.height + clockFace.anchors.topMargin + savedWorldClock.height + savedWorldClock.anchors.topMargin + units.gu(3)
115115
116 // Qml Element to draw the analogue clock face along with its hour, minute and second hands.116 // QML Element to draw the analogue clock face along with its hour, minute and second hands.
117 AnalogClockFace {117 ClockBase {
118 id: clockFace118 id: clockFace
119119
120 anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }120 anchors {
121 top: parent.top
122 topMargin: units.gu(10)
123 horizontalCenter: parent.horizontalCenter
124 }
125
121 innerLabel.text: currentTimeFormatted126 innerLabel.text: currentTimeFormatted
122 innerLabel.objectName: "currentTimeLabel"127
128 hours: new Date().getHours() * 5
129 minutes: new Date().getMinutes()
130 seconds: new Date().getUTCSeconds()
131
132 function timeChanged(now) {
133 hours = now.getHours() * 5
134 minutes = now.getMinutes()
135 seconds = now.getUTCSeconds();
136 }
123137
124 onClicked: {138 onClicked: {
125 if (easterEggCircle.isReady == XmlListModel.Ready && worldModel.city !== "undefined")139 if (easterEggCircle.isReady == XmlListModel.Ready && worldModel.city !== "undefined")
@@ -131,8 +145,9 @@
131145
132 EasterEgg {146 EasterEgg {
133 id: easterEggCircle147 id: easterEggCircle
148 parent: clockFace.centerItem
134 anchors.centerIn: parent149 anchors.centerIn: parent
135 width: clockFace.innerCircle.width; height: width;150 width: clockFace.centerItem.width; height: width;
136 radius: width / 2;151 radius: width / 2;
137 }152 }
138153
139154
=== removed file 'common/AnalogClockHand.qml'
--- common/AnalogClockHand.qml 2013-07-14 11:36:59 +0000
+++ common/AnalogClockHand.qml 1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20
21// Qml component to draw the analog clock hand
22Rectangle{
23 id: analogClockHandContainer
24
25 property alias handHeight: analogClockHand.height
26 property alias handWidth: analogClockHand.width
27 property alias handRotationAnimation: analogClockHandRotation.enabled
28
29 radius: width / 2
30 anchors.fill: parent
31 transformOrigin: Item.Center
32 color: "transparent";
33
34 Rectangle {
35 id: analogClockHand
36
37 x: (parent.width / 2) - (width / 2); y: (parent.height / 2) - height; z: 2;
38 width: units.gu(1); height: units.gu(14);
39 radius: units.gu(1)
40 color: Theme.palette.normal.baseText
41 antialiasing: true
42 }
43
44 Behavior on rotation {
45 id: analogClockHandRotation
46 enabled: true;
47 RotationAnimation { direction: RotationAnimation.Shortest }
48 }
49}
50
510
=== removed file 'common/AnalogFaceBase.qml'
--- common/AnalogFaceBase.qml 2013-10-26 13:20:54 +0000
+++ common/AnalogFaceBase.qml 1970-01-01 00:00:00 +0000
@@ -1,149 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Juha Ristolainen <juha.ristolainen@codemancers.fi>
17 * Nick LeppΓ€nen Larsson <frals@frals.se>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import QtGraphicalEffects 1.0
23
24// FIXME: Replace Rectangle with UbuntuShape when the new widget lands in the Ubuntu SDK.
25Rectangle {
26 id: clockRoot
27
28 property alias innerCircle: innerCircle
29 property alias innerLabel: currentTimeLabel
30 property real offset : units.gu(0.2)
31
32 width: units.gu(32); height: units.gu(32)
33 radius: width / 2
34 antialiasing: true
35
36 // Current time label
37 Label {
38 id: currentTimeLabel
39
40 z: innerCircle.z + 1
41 width: innerCircle.width; height: width;
42 anchors.centerIn: parent
43 horizontalAlignment: Text.AlignHCenter
44 verticalAlignment: Text.AlignVCenter
45 color: Theme.palette.normal.baseText
46 font.pixelSize: units.dp(41)
47 }
48
49 gradient: Gradient {
50 GradientStop { position: 0.0; color: "#512F48" }
51 GradientStop { position: 0.25; color: "#583048" }
52 GradientStop { position: 0.5; color: "#653449" }
53 GradientStop { position: 0.75; color: "#6D384A" }
54 GradientStop { position: 1.0; color: "#753B4A" }
55 }
56
57 // Draws the outter shadow/highlight
58 Rectangle {
59 id: sourceOutter
60 anchors { fill: parent; margins: -offset }
61 radius: (width / 2)
62 antialiasing: true
63 gradient: Gradient {
64 GradientStop { position: 0.0; color: "black" }
65 GradientStop { position: 0.5; color: "transparent" }
66 GradientStop { position: 1.0; color: "white" }
67 }
68 }
69
70 // Mask for outer 3D effect
71 Rectangle {
72 id: maskOutter
73 anchors.fill: sourceOutter
74 color: "transparent"
75 radius: (width / 2)
76 antialiasing: true
77 border { width: offset; color: "black" }
78 }
79
80 // Outter effect
81 OpacityMask {
82 anchors.fill: sourceOutter
83 opacity: 0.65
84 source: ShaderEffectSource {
85 sourceItem: sourceOutter
86 hideSource: true
87 }
88 maskSource: ShaderEffectSource {
89 sourceItem: maskOutter
90 hideSource: true
91 }
92 }
93
94 // FIXME: Replace this with UbuntuShape when the widget has landed in the SDK.
95 Rectangle {
96 id: innerCircle
97
98 z: parent.z + 2
99 height: units.gu(19); width: units.gu(19)
100 radius: width / 2
101 anchors.centerIn: parent
102 antialiasing: true
103
104 gradient: Gradient {
105 GradientStop { position: 0.0; color: "#7A4C68" }
106 GradientStop { position: 0.25; color: "#804563" }
107 GradientStop { position: 0.5; color: "#864660" }
108 GradientStop { position: 0.75; color: "#86465E" }
109 GradientStop { position: 1.0; color: "#964E66" }
110 }
111
112 // Draws the inner highlight / shadow
113 Rectangle {
114 id: sourceInner;
115 anchors { fill: parent; margins: -offset }
116 radius: (width / 2)
117 antialiasing: true
118 gradient: Gradient {
119 GradientStop { position: 0.0; color: "white" }
120 GradientStop { position: 0.5; color: "transparent" }
121 GradientStop { position: 1.0; color: "black" }
122 }
123 }
124
125 // Mask for inner 3D effect
126 Rectangle {
127 id: maskInner
128 color: "transparent"
129 anchors.fill: sourceInner
130 radius: (width / 2)
131 antialiasing: true
132 border { width: offset; color: "black" }
133 }
134
135 // Inner effect
136 OpacityMask {
137 opacity: 0.65
138 anchors.fill: sourceInner
139 source: ShaderEffectSource {
140 sourceItem: sourceInner
141 hideSource: true
142 }
143 maskSource: ShaderEffectSource {
144 sourceItem: maskInner
145 hideSource: true
146 }
147 }
148 }
149}
1500
=== modified file 'common/AnalogGlowEffect.qml'
--- common/AnalogGlowEffect.qml 2013-08-09 22:11:05 +0000
+++ common/AnalogGlowEffect.qml 2014-01-10 14:02:26 +0000
@@ -29,6 +29,6 @@
29 glowRadius: 1029 glowRadius: 10
30 spread: 0.830 spread: 0.8
31 color: "orange"31 color: "orange"
32 cornerRadius: fillRectangle.radius32 cornerRadius: fillRectangle.size
33 z: fillRectangle - 133 z: fillRectangle - 1
34}34}
3535
=== removed file 'common/AnalogTouchHand.qml'
--- common/AnalogTouchHand.qml 2013-09-04 10:35:41 +0000
+++ common/AnalogTouchHand.qml 1970-01-01 00:00:00 +0000
@@ -1,108 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21import "../common"
22
23// Qml item to enable touch input to the AnalogClockHand component
24Item {
25 id: touchHand;
26
27 z: parent.z;
28 width: parent.width; height: width;
29 anchors.centerIn: parent;
30
31 property int totalValue: 60;
32 property int perAngle: 6;
33
34 /*!
35 Enable/Disable rotation animation. Disable it while dragging the clock hand to avoid
36 receiving inaccurate input values.
37 */
38 property alias animateFlag: hand.handRotationAnimation
39
40 /*!
41 Set if the dial should be rotated by the seconds, minutes or hours. This generally needs to be
42 multiplied by 6 to convert it into degrees per second/hour/minute.
43 */
44 property alias rotationValue: hand.rotation;
45
46 // Set the touch/mouse grab area height and top margin
47 property alias grabHeight: grabArea.height;
48 property int grabMargin: units.gu(0);
49
50 // Height and width of the clock hand
51 property alias handHeight: hand.handHeight;
52 property alias handWidth: hand.handWidth;
53
54 // internal properties required for the functioning of the AnalogTouchHand
55 property int timerValue: 0
56 property real centerX : width / 2
57 property real centerY : height / 2
58
59 // Clock hand which lies above the rotating dial. This is stationary w.r.t to the rotating dial.
60 AnalogClockHand {
61 id: hand
62
63 handHeight: units.gu(0); handWidth: units.gu(0);
64
65 /*!
66 Element to define the grab area of the clock hand. This allows us to define small clock hand
67 which are still easier to grab.
68 */
69 Rectangle {
70 id: grabArea
71 color: "transparent"
72 width: units.gu(5); height: width;
73 anchors { top: hand.top; topMargin: touchHand.grabMargin; horizontalCenter: hand.horizontalCenter }
74 }
75
76 MouseArea{
77 anchors.fill: grabArea;
78 preventStealing: true;
79 enabled: true;
80 onPositionChanged: {
81 var point = mapToItem (touchHand, mouse.x, mouse.y);
82 var diffX = (point.x - touchHand.centerX);
83 var diffY = -1 * (point.y - touchHand.centerY);
84 var rad = Math.atan (diffY / diffX);
85 var deg = (rad * 180 / Math.PI);
86
87 if (diffX > 0 && diffY > 0) {
88 hand.rotation = 90 - Math.abs (deg);
89 }
90 else if (diffX > 0 && diffY < 0) {
91 hand.rotation = 90 + Math.abs (deg);
92 }
93 else if (diffX < 0 && diffY > 0) {
94 hand.rotation = 270 + Math.abs (deg);
95 }
96 else if (diffX < 0 && diffY < 0) {
97 hand.rotation = 270 - Math.abs (deg);
98 }
99
100 if (Math.round(hand.rotation/perAngle) === totalValue) {
101 touchHand.timerValue = 0
102 } else {
103 touchHand.timerValue = Math.round(hand.rotation/perAngle);
104 }
105 }
106 }
107 }
108}
1090
=== added file 'common/ClockBase.qml'
--- common/ClockBase.qml 1970-01-01 00:00:00 +0000
+++ common/ClockBase.qml 2014-01-10 14:02:26 +0000
@@ -0,0 +1,94 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21import Ubuntu.Components.Pickers 0.1
22
23/*
24 Basic component to draw the analogue clock with hour, minute and second hands.
25 */
26Dialer {
27 id: clockRoot
28
29 // Properties to set the clock hands position
30 property alias hours: _hourHand.value
31 property alias minutes: _minuteHand.value
32 property alias seconds: _secondHand.value
33
34 // Property to set the label shown in the inner circle
35 property alias innerLabel: _currentTimeLabel
36
37 // Property to individually hide the hour and minute hand in timer and alarm
38 property bool showHourHand: true
39 property bool showSecondHand: true
40
41 // Property to enable/disable the mouse area of the inner circle.
42 property bool enableMouseArea: true
43
44 // Property to set if the clock hands are adjustable by the user
45 property bool draggable: false
46
47 signal clicked(var mouse)
48 signal pressAndHold(var mouse)
49
50 minimumValue: 0
51 maximumValue: 60
52 size: units.gu(32)
53
54 DialerHand {
55 id: _hourHand
56 objectName: "hourHand"
57 hand.draggable: draggable
58 hand.visible: showHourHand
59 }
60
61 DialerHand {
62 id: _minuteHand
63 objectName: "minuteHand"
64 hand.draggable: draggable
65 }
66
67 DialerHand {
68 id: _secondHand
69 objectName: "secondHand"
70 hand.draggable: draggable
71 hand.visible: showSecondHand
72 }
73
74 centerContent: [
75 Label {
76 id: _currentTimeLabel
77 objectName: "label"
78 anchors.centerIn: parent
79 horizontalAlignment: Text.AlignHCenter
80 verticalAlignment: Text.AlignVCenter
81 font.pixelSize: units.dp(41)
82 }
83 ]
84
85 // Mouse area to reveal the clock sunrise/sunset on clicking the clock face
86 MouseArea {
87 parent: clockRoot.centerItem
88 anchors.fill: parent
89 enabled: enableMouseArea
90 z: parent.z + 1;
91 onClicked: clockRoot.clicked(mouse);
92 onPressAndHold: clockRoot.pressAndHold(mouse);
93 }
94}
095
=== modified file 'common/ClockUtils.js'
--- common/ClockUtils.js 2013-09-12 17:22:30 +0000
+++ common/ClockUtils.js 2014-01-10 14:02:26 +0000
@@ -43,3 +43,14 @@
43function numberToLocaleString( num ) {43function numberToLocaleString( num ) {
44 return Number(num).toLocaleString(Qt.locale(), "f", 0)44 return Number(num).toLocaleString(Qt.locale(), "f", 0)
45}45}
46
47// Function to convert hours to clock hand positions.
48// The range of the analogue clock is 0-60 while the hours should be between 00-23. Hence the factor 23/60
49function hourstoCirclePosition(hours) {
50 return Math.round(hours * 23/60)
51}
52
53// Function to convert clock hand positions to hours (24-hours)
54function circlePositiontoHours(position) {
55 return Math.round(position * 60/23)
56}
4657
=== removed file 'stopwatch/AnalogStopwatch.qml'
--- stopwatch/AnalogStopwatch.qml 2013-09-14 06:20:48 +0000
+++ stopwatch/AnalogStopwatch.qml 1970-01-01 00:00:00 +0000
@@ -1,128 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alessandro Pozzi <signor.hyde@gmail.com>
17 * Nekhelesh Ramananthan <krnekhelesh@gmail.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import "StopwatchSupport.js" as SScript
23import "../common"
24
25// This component draws the stopwatch analog UI and defines different UI modes like normal and easteregg.
26AnalogFaceBase {
27 id: analogStopwatch
28
29 property var startTime: 0;
30 property var stopTime: 0;
31 property int delay : 0;
32 property bool flag: true;
33 property int totalTime: 0;
34
35 property int hours: 0;
36 property int minutes: 0;
37 property int seconds: 0;
38 property int milliseconds: 0;
39 property int decimalgradient: 0;
40
41 // Sets the location and visible (bool) values of the blip (small circle visible when the lap button is pressed)
42 property alias blipLocation: blipFist.location;
43 property alias blipVisible: blipFist.visible;
44
45 // Retrieves the status of the stopwatch timer
46 property bool timerStatus: stopwatchUIUpdate.running
47
48 function reset() {
49 decimalgradient = totalTime = milliseconds = seconds = minutes = hours = 0
50 SScript.deltaTime[0] = SScript.deltaTime[1] = SScript.deltaTime[2] = SScript.deltaTime[3] = 0
51 startTime = stopTime = delay = 0;
52 flag = true;
53 }
54
55 function start() {
56 stopwatchUIUpdate.start()
57 }
58
59 function stop() {
60 stopwatchUIUpdate.stop()
61 }
62
63 // Timer which runs every 100 microseconds to update the time and also the trailing hand gradient.
64 Timer {
65 id: stopwatchUIUpdate
66
67 interval: 100
68 repeat: true
69 onTriggered: {
70 totalTime = SScript.delta();
71 SScript.deltaTime = SScript.msToTime(totalTime)
72 hours = SScript.deltaTime[0];
73 minutes = SScript.deltaTime[1];
74 seconds = SScript.deltaTime[2];
75 milliseconds = SScript.deltaTime[3];
76 decimalgradient = minutes * 10;
77 }
78 }
79
80 // This component draws the small orange circle that is visible everytime the lap button is pressed.
81 Blip {
82 id: blipFist
83 }
84
85 // This component draws the trailing shadow of the second hand.
86 HandGradient {
87 id: gradientSecond
88 rotationAngle: minutes * 6
89 decimalGradient: decimalgradient
90 }
91
92 Repeater {
93 id:stopwatchMarkers
94
95 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"]
96
97 delegate: AnalogClockMarker {
98 number: modelData
99 total: 24;
100 size: 0.2
101 distance: 0.32
102 }
103 }
104
105 AnalogClockHand {
106 id: hourHand
107
108 z: parent.z
109 handHeight: units.gu(12.5); handWidth: units.gu(1);
110 rotation: hours * 15;
111 }
112
113 AnalogClockHand {
114 id: minuteHand
115
116 z: parent.z
117 handHeight: units.gu(14.5); handWidth: units.gu(0.5);
118 rotation: minutes * 6;
119 }
120
121 AnalogClockHand {
122 id: secondHand
123
124 z: parent.z - 1;
125 handHeight: units.gu(17); handWidth: units.gu(0.5)
126 rotation: seconds * 6;
127 }
128}
1290
=== added file 'stopwatch/StopwatchFace.qml'
--- stopwatch/StopwatchFace.qml 1970-01-01 00:00:00 +0000
+++ stopwatch/StopwatchFace.qml 2014-01-10 14:02:26 +0000
@@ -0,0 +1,91 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alessandro Pozzi <signor.hyde@gmail.com>
17 * Nekhelesh Ramananthan <krnekhelesh@gmail.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import "StopwatchSupport.js" as SScript
23import "../common"
24
25ClockBase {
26 id: stopwatchFace
27
28 // Properties to store/set the time variables
29 property var startTime: 0
30 property var stopTime: 0
31 property int delay : 0
32 property bool flag: true
33 property int totalTime: 0
34 property int milliseconds: 0
35
36 // Sets the location and visible (bool) values of the blip (small circle visible when the lap button is pressed)
37 property alias blipLocation: blipFist.location
38 property alias blipVisible: blipFist.visible
39
40 // Retrieves the status of the stopwatch timer
41 property bool timerStatus: stopwatchUIUpdate.running
42
43 function reset() {
44 totalTime = milliseconds = seconds = minutes = hours = 0
45 SScript.deltaTime[0] = SScript.deltaTime[1] = SScript.deltaTime[2] = SScript.deltaTime[3] = 0
46 startTime = stopTime = delay = 0;
47 flag = true;
48 }
49
50 function start() {
51 stopwatchUIUpdate.start()
52 }
53
54 function stop() {
55 stopwatchUIUpdate.stop()
56 }
57
58 // Timer which runs every 100 microseconds to update the time and also the trailing hand gradient.
59 Timer {
60 id: stopwatchUIUpdate
61
62 interval: 100
63 repeat: true
64 onTriggered: {
65 totalTime = SScript.delta();
66 SScript.deltaTime = SScript.msToTime(totalTime)
67 hours = SScript.deltaTime[0];
68 minutes = SScript.deltaTime[1];
69 seconds = SScript.deltaTime[2];
70 milliseconds = SScript.deltaTime[3];
71 }
72 }
73
74 // This component draws the small white circle that is visible everytime the lap button is pressed.
75 Blip {
76 id: blipFist
77 }
78
79 Repeater {
80 id:stopwatchMarkers
81
82 model: 24
83
84 delegate: AnalogClockMarker {
85 number: modelData
86 total: 24;
87 size: 0.2
88 distance: 0.32
89 }
90 }
91}
092
=== modified file 'stopwatch/StopwatchPage.qml'
--- stopwatch/StopwatchPage.qml 2013-11-05 13:12:48 +0000
+++ stopwatch/StopwatchPage.qml 2014-01-10 14:02:26 +0000
@@ -63,34 +63,34 @@
63 contentHeight: analogStopwatch.height + analogStopwatch.anchors.topMargin + listLap.height + listLap.anchors.topMargin + units.gu(3)63 contentHeight: analogStopwatch.height + analogStopwatch.anchors.topMargin + listLap.height + listLap.anchors.topMargin + units.gu(3)
6464
65 // Component which draws the analog stopwatch face, controls the timer and calculates the time.65 // Component which draws the analog stopwatch face, controls the timer and calculates the time.
66 AnalogStopwatch {66 StopwatchFace {
67 id: analogStopwatch67 id: analogStopwatch
68 objectName: "buttonStopwatch"68 objectName: "stopwatchFace"
6969
70 anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }70 anchors {
7171 top: parent.top
72 innerLabel.objectName: "labelStopwatch"72 topMargin: units.gu(10)
73 horizontalCenter: parent.horizontalCenter
74 }
75
73 innerLabel.text: SScript.timeToString(analogStopwatch.hours, analogStopwatch.minutes, analogStopwatch.seconds, analogStopwatch.milliseconds)76 innerLabel.text: SScript.timeToString(analogStopwatch.hours, analogStopwatch.minutes, analogStopwatch.seconds, analogStopwatch.milliseconds)
7477
75 MouseArea {78 onClicked: {
76 anchors.fill: analogStopwatch.innerCircle;79 if(analogStopwatch.timerStatus == false) {
77 onClicked: {80 analogStopwatch.start()
78 if(analogStopwatch.timerStatus == false) {81 stopWatchLabelUpdate.start()
79 analogStopwatch.start()82 if (analogStopwatch.flag) {
80 stopWatchLabelUpdate.start()83 analogStopwatch.startTime = new Date().getTime();
81 if (analogStopwatch.flag) {84 analogStopwatch.flag = false;
82 analogStopwatch.startTime = new Date().getTime();85 }
83 analogStopwatch.flag = false;86 else {
84 }87 analogStopwatch.delay = Math.abs(new Date().getTime() - analogStopwatch.stopTime);
85 else {88 analogStopwatch.startTime = analogStopwatch.startTime + analogStopwatch.delay;
86 analogStopwatch.delay = Math.abs(new Date().getTime() - analogStopwatch.stopTime);89 }
87 analogStopwatch.startTime = analogStopwatch.startTime + analogStopwatch.delay;90 } else {
88 }91 analogStopwatch.stop()
89 } else {92 stopWatchLabelUpdate.stop()
90 analogStopwatch.stop()93 analogStopwatch.stopTime = new Date().getTime();
91 stopWatchLabelUpdate.stop()
92 analogStopwatch.stopTime = new Date().getTime();
93 }
94 }94 }
95 }95 }
96 }96 }
9797
=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
--- tests/autopilot/ubuntu_clock_app/emulators.py 2013-11-07 16:35:51 +0000
+++ tests/autopilot/ubuntu_clock_app/emulators.py 2014-01-10 14:02:26 +0000
@@ -66,7 +66,7 @@
6666
67 def get_time_label(self):67 def get_time_label(self):
68 """Return the label with the timer countdown"""68 """Return the label with the timer countdown"""
69 return self.wait_select_single("Label", objectName="currentTimeLabel")69 return self.select_single("ClockPage").wait_select_single("Label", objectName="label")
7070
71 # WORLD CLOCK Page Emulator Functions71 # WORLD CLOCK Page Emulator Functions
72 def get_world_cities_page(self):72 def get_world_cities_page(self):
@@ -108,7 +108,7 @@
108108
109 def get_timer_minute_hand(self):109 def get_timer_minute_hand(self):
110 """Returns the hour hand of clock in timer tab"""110 """Returns the hour hand of clock in timer tab"""
111 return self.wait_select_single("AnalogTouchHand", objectName="minuteHand")111 return self.select_single("TimerPage").wait_select_single("DialerHand", objectName="minuteHand")
112112
113 def get_preset_label_text(self):113 def get_preset_label_text(self):
114 """Returns the label with the preset text"""114 """Returns the label with the preset text"""
@@ -122,7 +122,7 @@
122122
123 def get_label_timer(self):123 def get_label_timer(self):
124 """Return the label with the timer countdown"""124 """Return the label with the timer countdown"""
125 return self.wait_select_single("Label", objectName="labelTimer")125 return self.select_single("TimerPage").wait_select_single("Label", objectName="label")
126126
127 def get_first_preset_list_item(self):127 def get_first_preset_list_item(self):
128 """Returns the first preset list item in the timer page."""128 """Returns the first preset list item in the timer page."""
@@ -136,12 +136,12 @@
136 # STOPWATCH Page Emulator Functions136 # STOPWATCH Page Emulator Functions
137 def get_stopwatch_label(self):137 def get_stopwatch_label(self):
138 """Returns the select for the stopwatch label"""138 """Returns the select for the stopwatch label"""
139 return self.wait_select_single("Label", objectName="labelStopwatch")139 return self.select_single("StopwatchPage").wait_select_single("Label", objectName="label")
140140
141 def get_stopwatch_button(self):141 def get_stopwatch_button(self):
142 """Returns the select for the stopwatch button"""142 """Returns the select for the stopwatch button"""
143 return self.wait_select_single("AnalogStopwatch",143 return self.wait_select_single("StopwatchFace",
144 objectName="buttonStopwatch")144 objectName="stopwatchFace")
145145
146 def get_lap_button(self):146 def get_lap_button(self):
147 """Returns the select for the lap button"""147 """Returns the select for the lap button"""
@@ -233,13 +233,13 @@
233233
234 def get_alarm_minute_hand(self):234 def get_alarm_minute_hand(self):
235 """Returns the hour hand of clock in alarm tab"""235 """Returns the hour hand of clock in alarm tab"""
236 return self.select_single("AnalogClockHand",236 return self.select_single("AlarmPage").select_single("DialerHand",
237 objectName="alarmMinuteHand")237 objectName="minuteHand")
238238
239 def get_alarm_hour_hand(self):239 def get_alarm_hour_hand(self):
240 """Returns the hour hand of clock in alarm tab"""240 """Returns the hour hand of clock in alarm tab"""
241 return self.select_single("AnalogClockHand",241 return self.select_single("AlarmPage").select_single("DialerHand",
242 objectName="alarmHourHand")242 objectName="hourHand")
243243
244 def set_alarm_week(self, day, test_case):244 def set_alarm_week(self, day, test_case):
245 #TODO: add support for setting days of week245 #TODO: add support for setting days of week
246246
=== removed file 'timer/AnalogTimer.qml'
--- timer/AnalogTimer.qml 2013-10-26 12:20:55 +0000
+++ timer/AnalogTimer.qml 1970-01-01 00:00:00 +0000
@@ -1,121 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21import "../common"
22
23// Component which draws the analog timer face.
24AnalogFaceBase {
25 id: clockOuterCircle
26
27 property var startTime: 0;
28 property var remTime: 0;
29
30 // Properties to store/set the time variables
31 property int seconds: 0;
32 property int minutes: 0;
33 property int totalTime: 0;
34 property int pauseTime: 0;
35
36 // Property to activate/deactivate the timer
37 property bool timerOn: false;
38 property bool inProgressFlag
39
40 // Timer function called by the main clock loop
41 function onTimerUpdate () {
42 if( timerOn ) {
43 inProgressFlag = true;
44 remTime = totalTime - Math.floor((new Date() - startTime)/ 1000) - pauseTime;
45
46 if (remTime < 0) {
47 timerOn = false
48 totalTime = -1;
49 } else {
50 ssToTime(remTime);
51 }
52 }
53 }
54
55 // Function to convert time (in seconds) to hh:mm:ss format
56 function ssToTime(time) {
57 seconds = time % 60
58 time = Math.floor(time / 60)
59 minutes = time % 60
60 secondHand.rotationValue = seconds * 6;
61 minuteHand.rotationValue = minutes * 6;
62 }
63
64 // Function to disable timer and reset time
65 Timer {
66 id: reset_timer
67
68 interval: 200
69 repeat: false
70 onTriggered: {
71 inProgressFlag = true;
72 minuteHand.rotationValue = secondHand.rotationValue = 0;
73 inProgressFlag = false;
74 }
75 }
76
77 function reset() {
78 reset_timer.start();
79 timerOn = false;
80 state = "";
81 startTime = remTime = pauseTime = 0;
82 minutes = seconds = totalTime = 0;
83 minuteHand.timerValue = secondHand.timerValue = 0;
84 }
85
86 Repeater {
87 model: 12
88 delegate: AnalogClockMarker {
89 number: index
90 size: 0.5
91 distance: 0.48
92 }
93 }
94
95 // Minute hand with touch/mouse drag support
96 AnalogTouchHand {
97 id: minuteHand
98 objectName: "minuteHand"
99
100 onTimerValueChanged: minutes = timerValue;
101
102 handHeight: units.gu(14.5); handWidth: units.gu(0.5);
103 animateFlag: inProgressFlag;
104 enabled: !inProgressFlag;
105 grabMargin: units.gu(0)
106 grabHeight: units.gu(7)
107 }
108
109 // Second hand with touch/mouse drag support
110 AnalogTouchHand {
111 id: secondHand
112
113 onTimerValueChanged: seconds = timerValue;
114
115 handHeight: units.gu(17); handWidth: units.gu(0.5);
116 z: parent.z - 1;
117 animateFlag: inProgressFlag;
118 enabled: !inProgressFlag;
119 grabMargin: -units.gu(2)
120 }
121}
1220
=== added file 'timer/TimerFace.qml'
--- timer/TimerFace.qml 1970-01-01 00:00:00 +0000
+++ timer/TimerFace.qml 2014-01-10 14:02:26 +0000
@@ -0,0 +1,99 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21import "../common"
22
23ClockBase {
24 id: timerFace
25
26 // Properties to store/set the time variables
27 property var startTime: 0;
28 property var remTime: 0;
29 property int totalTime: 0;
30 property int pauseTime: 0;
31
32 // Property to activate/deactivate the timer
33 property bool timerOn: false;
34 property bool inProgressFlag
35
36 // Property to expose the timer outer glow effect to outside objects
37 property alias glowEffect: _glowEffect
38
39 showHourHand: false
40 draggable: !inProgressFlag
41
42 // Timer function called by the main clock loop
43 function onTimerUpdate () {
44 if( timerOn ) {
45 inProgressFlag = true;
46 remTime = totalTime - Math.floor((new Date() - startTime)/ 1000) - pauseTime;
47
48 if (remTime < 0) {
49 timerOn = false
50 totalTime = -1;
51 } else {
52 ssToTime(remTime);
53 }
54 }
55 }
56
57 // Function to convert time (in seconds) to hh:mm:ss format
58 function ssToTime(time) {
59 seconds = time % 60
60 time = Math.floor(time / 60)
61 minutes = time % 60
62 }
63
64 // This timer to required to avoid rare occurences of the timer hand being stuck at the place where it was stopped
65 // when the reset button is pressed while the timer is running.
66 Timer {
67 id: reset_timer
68 interval: 200
69 repeat: false
70 onTriggered: {
71 inProgressFlag = true;
72 inProgressFlag = false;
73 }
74 }
75
76 function reset() {
77 reset_timer.start()
78 timerOn = false;
79 state = "";
80 startTime = remTime = pauseTime = 0;
81 minutes = seconds = totalTime = 0;
82 }
83
84 AnalogGlowEffect {
85 id: _glowEffect
86 z: parent.z - 1
87 visible: false;
88 fillRectangle: parent
89 }
90
91 Repeater {
92 model: 12
93 delegate: AnalogClockMarker {
94 number: index
95 size: 0.5
96 distance: 0.48
97 }
98 }
99}
0100
=== modified file 'timer/TimerPage.qml'
--- timer/TimerPage.qml 2013-11-26 15:36:37 +0000
+++ timer/TimerPage.qml 2014-01-10 14:02:26 +0000
@@ -58,7 +58,7 @@
58 },58 },
59 State {59 State {
60 name: "addPreset"60 name: "addPreset"
61 PropertyChanges { target: timerMouseArea; enabled: false }61 PropertyChanges { target: analogTimer; enableMouseArea: false }
62 PropertyChanges { target: listPreset; visible: false }62 PropertyChanges { target: listPreset; visible: false }
63 PropertyChanges { target: namePreset; visible: true }63 PropertyChanges { target: namePreset; visible: true }
64 PropertyChanges { target: addPresetToolbarButton; visible: false }64 PropertyChanges { target: addPresetToolbarButton; visible: false }
@@ -84,7 +84,7 @@
84 listPreset.listIndex = -1;84 listPreset.listIndex = -1;
85 namePreset.text = "";85 namePreset.text = "";
86 tempNamePreset = "";86 tempNamePreset = "";
87 } 87 }
8888
89 Component.onCompleted: {89 Component.onCompleted: {
90 Utils.log("TimerPage loaded");90 Utils.log("TimerPage loaded");
@@ -112,81 +112,70 @@
112112
113 Behavior on contentY {113 Behavior on contentY {
114 UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration }114 UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration }
115 } 115 }
116116
117 // Main element which draws the timer face and manages time.117 // Main element which draws the timer face and manages time.
118 AnalogTimer {118 TimerFace {
119 id: analogTimer119 id: analogTimer
120120
121 innerLabel.objectName: "labelTimer"121 anchors {
122 top: parent.top
123 topMargin: units.gu(10)
124 horizontalCenter: parent.horizontalCenter
125 }
126
122 innerLabel.text: intervalToString(minutes, seconds);127 innerLabel.text: intervalToString(minutes, seconds);
128
123 Timer {129 Timer {
124 id: seconds_timer130 id: seconds_timer
125131 interval: 250
126 interval: 500
127 repeat: true132 repeat: true
128 onTriggered: analogTimer.innerLabel.text = intervalToString(minutes, seconds);133 onTriggered: analogTimer.innerLabel.text = intervalToString(minutes, seconds);
129 }134 }
130135
131 AnalogGlowEffect {136 inProgressFlag: (timerOn === true || analogTimer.state === "DONE") ? true : false;
132 id: glowEffect137 onMinutesChanged: innerLabel.text = intervalToString(minutes, seconds);
133
134 z: parent.z - 1
135 visible: false;
136 fillRectangle: parent
137 }
138
139 anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }
140 inProgressFlag: (timerOn == true || analogTimer.state == "DONE") ? true : false;
141 onSecondsChanged: if (timerOn == true) seconds_timer.restart()138 onSecondsChanged: if (timerOn == true) seconds_timer.restart()
142 else innerLabel.text = intervalToString(minutes, seconds);139 else innerLabel.text = intervalToString(minutes, seconds);
143
144 onMinutesChanged: innerLabel.text = intervalToString(minutes, seconds);
145
146 states:[140 states:[
147 State { name: "STOP" },141 State { name: "STOP" },
148 State { name: "PAUSE"},142 State { name: "PAUSE"},
149 State {143 State {
150 name: "DONE"144 name: "DONE"
151 when: (totalTime == -1 && timerOn == false)145 when: (totalTime == -1 && timerOn == false)
152 PropertyChanges { target: glowEffect; visible: true }146 PropertyChanges { target: analogTimer.glowEffect; visible: true }
153 PropertyChanges { target: glowEffect; color: "#03CB4A" }147 PropertyChanges { target: analogTimer.glowEffect; color: "#03CB4A" }
154 }148 }
155 ]149 ]
156150
157 MouseArea {151 onClicked: {
158 id: timerMouseArea152 switch (analogTimer.state) {
159 anchors.fill: analogTimer.innerCircle153
160 enabled: true154 case "":
161 onClicked: {155 if ((seconds != 0 || minutes != 0) || timerOn) {
162 switch (analogTimer.state) {156 totalTime = (Math.round(minutes) * 60) + seconds;
163
164 case "":
165 if ((seconds != 0 || minutes != 0) || timerOn) {
166 totalTime = (minutes * 60) + seconds;
167 analogTimer.startTime = new Date();
168 timerOn = true;
169 analogTimer.state = "STOP";
170 }
171 break;
172
173 case "STOP":
174 timerOn = false;
175 analogTimer.pauseTime = analogTimer.totalTime - analogTimer.remTime + 1; // +1 is necessary to start immediately the timer when finish a pause
176 analogTimer.state = "PAUSE";
177 break;
178
179 case "DONE":
180 reset();
181 analogTimer.state = "";
182 break;
183
184 case "PAUSE":
185 analogTimer.startTime = new Date();157 analogTimer.startTime = new Date();
186 timerOn = true;158 timerOn = true;
187 analogTimer.state = "STOP";159 analogTimer.state = "STOP";
188 break;
189 }160 }
161 break;
162
163 case "STOP":
164 timerOn = false;
165 analogTimer.pauseTime = analogTimer.totalTime - analogTimer.remTime + 1; // +1 is necessary to start immediately the timer when finish a pause
166 analogTimer.state = "PAUSE";
167 break;
168
169 case "DONE":
170 reset();
171 analogTimer.state = "";
172 break;
173
174 case "PAUSE":
175 analogTimer.startTime = new Date();
176 timerOn = true;
177 analogTimer.state = "STOP";
178 break;
190 }179 }
191 }180 }
192 }181 }

Subscribers

People subscribed via source and target branches