Merge lp:~nik90/ubuntu-clock-app/remove-timer-hour into lp:ubuntu-clock-app/saucy

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Paolo Rotolo
Approved revision: 196
Merged at revision: 195
Proposed branch: lp:~nik90/ubuntu-clock-app/remove-timer-hour
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 296 lines (+47/-85)
5 files modified
common/ClockUtils.js (+0/-31)
tests/autopilot/ubuntu_clock_app/emulators.py (+2/-2)
tests/autopilot/ubuntu_clock_app/tests/test_timer.py (+15/-7)
timer/AnalogTimer.qml (+7/-23)
timer/TimerPage.qml (+23/-22)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/remove-timer-hour
Reviewer Review Type Date Requested Status
Paolo Rotolo (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+185328@code.launchpad.net

Commit message

Removed hour support from timer as requested by design.

Description of the change

This MP removed hour support from timer as requested by design. The autopilot tests have also been fixed due to the design change.

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
Paolo Rotolo (paolorotolo) wrote :

lgtm!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/ClockUtils.js'
2--- common/ClockUtils.js 2013-08-09 23:00:57 +0000
3+++ common/ClockUtils.js 2013-09-12 17:50:28 +0000
4@@ -29,13 +29,6 @@
5 console.debug(LOG_PREFIX + "[ERROR] " + message);
6 }
7
8-function formatNow ( now ) {
9- var hours = now.getHours();
10- var minutes = now.getMinutes();
11- var seconds = now.getSeconds();
12- return hmsToString(hours, minutes, seconds)
13-}
14-
15 function zeroleft ( n, z ) {
16 var resstring = numberToLocaleString(n.toString());
17 var numchart = z;
18@@ -50,27 +43,3 @@
19 function numberToLocaleString( num ) {
20 return Number(num).toLocaleString(Qt.locale(), "f", 0)
21 }
22-
23-// Function to convert time into a proper string format
24-function hmsToString(hours, minutes, seconds)
25-{
26- var timeString = zeroleft(hours, 2) + ":" + zeroleft(minutes, 2) + ":" + zeroleft(seconds, 2);
27- return timeString;
28-}
29-
30-// Function to print timer label (format mm:ss and hh:mm:ss when hh > 0) at top
31-function intervalToString(hours, minutes, seconds)
32-{
33- var locale = Qt.locale();
34-
35- if (hours > 0) {
36- return zeroleft(hours, 2) + ":" + zeroleft(minutes, 2) + ":" + zeroleft(seconds, 2);
37- } else {
38- return zeroleft(minutes, 2) + ":" + zeroleft(seconds, 2);
39- }
40-}
41-
42-// Function to return total seconds.
43-function totalSeconds(hours, minutes, seconds) {
44- return( (hours * 60 * 60) + (minutes * 60) + seconds );
45-}
46
47=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
48--- tests/autopilot/ubuntu_clock_app/emulators.py 2013-08-15 19:27:03 +0000
49+++ tests/autopilot/ubuntu_clock_app/emulators.py 2013-09-12 17:50:28 +0000
50@@ -60,9 +60,9 @@
51 """Returns the TextField where insert the name of the preset"""
52 return self.select_single("TextField", objectName="namePreset")
53
54- def get_timer_hour_hand(self):
55+ def get_timer_minute_hand(self):
56 """Returns the hour hand of clock in timer tab"""
57- return self.select_single("AnalogTouchHand", objectName="hourHand")
58+ return self.select_single("AnalogTouchHand", objectName="minuteHand")
59
60 def get_preset_label_text(self):
61 """Returns the label with the preset text"""
62
63=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
64--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-09-05 02:53:54 +0000
65+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-09-12 17:50:28 +0000
66@@ -98,12 +98,20 @@
67
68 self.drag_page_down_to_previous_state()
69
70- # Set hour
71- self.assertThat(self.main_view.get_timer_hour_hand, Eventually(Not(Is(None))))
72- hour = self.main_view.get_timer_hour_hand()
73- x, y, w, h = hour.globalRect
74+ # Set minute
75+ self.assertThat(self.main_view.get_timer_minute_hand, Eventually(Not(Is(None))))
76+ minute = self.main_view.get_timer_minute_hand()
77+
78+ timeout = 0
79+ while label.focus == True and timeout < 10:
80+ TimerLabel = self.main_view.get_label_timer()
81+ self.pointing_device.click_object(TimerLabel)
82+ sleep(1)
83+ timeout += 1
84+
85+ x, y, w, h = minute.globalRect
86 tx = x + (w / 2)
87- ty = y + (h / 2)
88+ ty = y + (h / 2.5)
89 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))
90
91 self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None))))
92@@ -145,7 +153,7 @@
93
94 # Check has been deleted
95 self.assertThat(self.main_view.get_num_of_presets,
96- Eventually(Equals(num_of_presets_old-1)))
97+ Eventually(Equals(num_of_presets_old-1)))
98
99 def test_run_preset(self):
100 """Tests if a preset can runs"""
101@@ -175,4 +183,4 @@
102 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))
103 label_timer = self.main_view.get_label_timer()
104 self.pointing_device.click_object(label_timer)
105- self.assertThat(label_timer.text, Eventually(NotEquals("23:00:00")))
106+ self.assertThat(label_timer.text, Eventually(NotEquals("21:00")))
107
108=== modified file 'timer/AnalogTimer.qml'
109--- timer/AnalogTimer.qml 2013-09-05 17:00:26 +0000
110+++ timer/AnalogTimer.qml 2013-09-12 17:50:28 +0000
111@@ -29,8 +29,7 @@
112
113 // Properties to store/set the time variables
114 property int seconds: 0;
115- property int minutes: 0;
116- property int hours: 0;
117+ property int minutes: 0;
118 property int totalTime: 0;
119 property int pauseTime: 0;
120
121@@ -57,11 +56,9 @@
122 function ssToTime(time) {
123 seconds = time % 60
124 time = Math.floor(time / 60)
125- minutes = time % 60
126- hours = Math.floor(time / 60)
127+ minutes = time % 60
128 secondHand.rotationValue = seconds * 6;
129- minuteHand.rotationValue = minutes * 6;
130- hourHand.rotationValue = hours * 6;
131+ minuteHand.rotationValue = minutes * 6;
132 }
133
134 // Function to disable timer and reset time
135@@ -72,7 +69,7 @@
136 repeat: false
137 onTriggered: {
138 inProgressFlag = true;
139- hourHand.rotationValue = minuteHand.rotationValue = secondHand.rotationValue = 0;
140+ minuteHand.rotationValue = secondHand.rotationValue = 0;
141 inProgressFlag = false;
142 }
143 }
144@@ -82,8 +79,8 @@
145 timerOn = false;
146 state = "";
147 startTime = remTime = pauseTime = 0;
148- hours = minutes = seconds = totalTime = 0;
149- hourHand.timerValue = minuteHand.timerValue = secondHand.timerValue = 0;
150+ minutes = seconds = totalTime = 0;
151+ minuteHand.timerValue = secondHand.timerValue = 0;
152 }
153
154 Repeater {
155@@ -95,23 +92,10 @@
156 }
157 }
158
159- // Hour hand with touch/mouse drag support
160- AnalogTouchHand {
161- id: hourHand
162- objectName: "hourHand"
163-
164- onTimerValueChanged: hours = timerValue;
165-
166- handHeight: units.gu(12.5); handWidth: units.gu(1);
167- z: minuteHand.z + 1;
168- animateFlag: inProgressFlag;
169- enabled: !inProgressFlag;
170- grabMargin: units.gu(3);
171- }
172-
173 // Minute hand with touch/mouse drag support
174 AnalogTouchHand {
175 id: minuteHand
176+ objectName: "minuteHand"
177
178 onTimerValueChanged: minutes = timerValue;
179
180
181=== modified file 'timer/TimerPage.qml'
182--- timer/TimerPage.qml 2013-09-09 18:06:30 +0000
183+++ timer/TimerPage.qml 2013-09-12 17:50:28 +0000
184@@ -29,7 +29,6 @@
185
186 flickable: null
187
188- property alias hours: analogTimer.hours;
189 property alias minutes: analogTimer.minutes;
190 property alias seconds: analogTimer.seconds;
191 property alias totalTime: analogTimer.totalTime;
192@@ -54,8 +53,8 @@
193 id: saveTimerAction
194 iconSource: Qt.resolvedUrl("../images/select_icon.png")
195 text: i18n.tr("Save")
196- onTriggered: {
197- presetModel.appendPreset(tempNamePreset, namePreset.text, Utils.totalSeconds(hours, minutes, seconds), listTimerPreset.currentIndex)
198+ onTriggered: {
199+ presetModel.appendPreset(tempNamePreset, namePreset.text, ((minutes * 60) + seconds), listTimerPreset.currentIndex)
200 namePreset.focus = false
201 if (listTimerPreset.currentIndex == -1) {
202 reset()
203@@ -105,6 +104,12 @@
204 analogTimer.onTimerUpdate();
205 }
206
207+ // Function to print timer label (format mm:ss and hh:mm:ss when hh > 0) at top
208+ function intervalToString(minutes, seconds)
209+ {
210+ return Utils.zeroleft(minutes, 2) + ":" + Utils.zeroleft(seconds, 2);
211+ }
212+
213 function reset() {
214 analogTimer.reset();
215 listTimerPreset.currentIndex = -1;
216@@ -112,21 +117,18 @@
217 tempNamePreset = "";
218 }
219
220- // Function to calculate and print the hours, minutes and seconds from the total time as a string
221+ // Function to calculate and print the minutes and seconds from the total time as a string
222 function getstringTimer(time) {
223- var hours, minutes, seconds;
224+ var minutes, seconds;
225
226 seconds = time % 60
227 time = Math.floor(time / 60)
228- minutes = time % 60
229- hours = Math.floor(time / 60)
230-
231- return Utils.hmsToString(hours, minutes, seconds);
232- }
233-
234- Component.onCompleted: {
235- Utils.log("TimerPage loaded");
236- }
237+ minutes = time % 60
238+
239+ return Utils.zeroleft(minutes, 2) + ":" + Utils.zeroleft(seconds, 2);
240+ }
241+
242+ Component.onCompleted: Utils.log("TimerPage loaded");
243
244 AnimationContainer {
245 id: timerAnimationContainer
246@@ -152,7 +154,7 @@
247 color: Theme.palette.normal.baseText
248
249 fontSize: "x-large"
250- text: labelTimer.text = Utils.intervalToString(hours, minutes, seconds);
251+ text: labelTimer.text = intervalToString(minutes, seconds);
252 }
253 }
254
255@@ -165,7 +167,7 @@
256
257 interval: 500
258 repeat: true
259- onTriggered: labelTimer.text = Utils.intervalToString(hours, minutes, seconds);
260+ onTriggered: labelTimer.text = intervalToString(minutes, seconds);
261 }
262
263 AnalogGlowEffect {
264@@ -179,10 +181,9 @@
265 anchors { top: parent.top; topMargin: presetModel.count != 0 ? units.gu(9) : units.gu(12); horizontalCenter: parent.horizontalCenter }
266 inProgressFlag: (timerOn == true || analogTimer.state == "DONE") ? true : false;
267 onSecondsChanged: if (timerOn == true) seconds_timer.restart()
268- else labelTimer.text = Utils.intervalToString(hours, minutes, seconds);
269+ else labelTimer.text = intervalToString(minutes, seconds);
270
271- onMinutesChanged: labelTimer.text = Utils.intervalToString(hours, minutes, seconds);
272- onHoursChanged: labelTimer.text = Utils.intervalToString(hours, minutes, seconds);
273+ onMinutesChanged: labelTimer.text = intervalToString(minutes, seconds);
274
275 states:[
276 State { name: "STOP" },
277@@ -203,8 +204,8 @@
278 switch (analogTimer.state) {
279
280 case "":
281- if ((seconds != 0 || hours != 0 || minutes != 0) || timerOn) {
282- totalTime = Utils.totalSeconds(hours, minutes, seconds);
283+ if ((seconds != 0 || minutes != 0) || timerOn) {
284+ totalTime = (minutes * 60) + seconds;
285 analogTimer.startTime = new Date();
286 timerOn = true;
287 analogTimer.state = "STOP";
288@@ -280,7 +281,7 @@
289 anchors { top: analogTimer.bottom; topMargin: units.gu(7); horizontalCenter: analogTimer.horizontalCenter; leftMargin: units.gu(4) }
290 buttonImage: Qt.resolvedUrl("../images/reset_icon.svg");
291 buttonLabel: i18n.tr("Reset");
292- visible: timerOn || (hours != 0 || minutes != 0 || seconds != 0)? true : false;
293+ visible: timerOn || (minutes != 0 || seconds != 0)? true : false;
294 enabled: true
295
296 onClicked: {

Subscribers

People subscribed via source and target branches