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
=== modified file 'common/ClockUtils.js'
--- common/ClockUtils.js 2013-08-09 23:00:57 +0000
+++ common/ClockUtils.js 2013-09-12 17:50:28 +0000
@@ -29,13 +29,6 @@
29 console.debug(LOG_PREFIX + "[ERROR] " + message);29 console.debug(LOG_PREFIX + "[ERROR] " + message);
30}30}
3131
32function formatNow ( now ) {
33 var hours = now.getHours();
34 var minutes = now.getMinutes();
35 var seconds = now.getSeconds();
36 return hmsToString(hours, minutes, seconds)
37}
38
39function zeroleft ( n, z ) {32function zeroleft ( n, z ) {
40 var resstring = numberToLocaleString(n.toString());33 var resstring = numberToLocaleString(n.toString());
41 var numchart = z;34 var numchart = z;
@@ -50,27 +43,3 @@
50function numberToLocaleString( num ) {43function numberToLocaleString( num ) {
51 return Number(num).toLocaleString(Qt.locale(), "f", 0)44 return Number(num).toLocaleString(Qt.locale(), "f", 0)
52}45}
53
54// Function to convert time into a proper string format
55function hmsToString(hours, minutes, seconds)
56{
57 var timeString = zeroleft(hours, 2) + ":" + zeroleft(minutes, 2) + ":" + zeroleft(seconds, 2);
58 return timeString;
59}
60
61// Function to print timer label (format mm:ss and hh:mm:ss when hh > 0) at top
62function intervalToString(hours, minutes, seconds)
63{
64 var locale = Qt.locale();
65
66 if (hours > 0) {
67 return zeroleft(hours, 2) + ":" + zeroleft(minutes, 2) + ":" + zeroleft(seconds, 2);
68 } else {
69 return zeroleft(minutes, 2) + ":" + zeroleft(seconds, 2);
70 }
71}
72
73// Function to return total seconds.
74function totalSeconds(hours, minutes, seconds) {
75 return( (hours * 60 * 60) + (minutes * 60) + seconds );
76}
7746
=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
--- tests/autopilot/ubuntu_clock_app/emulators.py 2013-08-15 19:27:03 +0000
+++ tests/autopilot/ubuntu_clock_app/emulators.py 2013-09-12 17:50:28 +0000
@@ -60,9 +60,9 @@
60 """Returns the TextField where insert the name of the preset"""60 """Returns the TextField where insert the name of the preset"""
61 return self.select_single("TextField", objectName="namePreset")61 return self.select_single("TextField", objectName="namePreset")
6262
63 def get_timer_hour_hand(self):63 def get_timer_minute_hand(self):
64 """Returns the hour hand of clock in timer tab"""64 """Returns the hour hand of clock in timer tab"""
65 return self.select_single("AnalogTouchHand", objectName="hourHand")65 return self.select_single("AnalogTouchHand", objectName="minuteHand")
6666
67 def get_preset_label_text(self):67 def get_preset_label_text(self):
68 """Returns the label with the preset text"""68 """Returns the label with the preset text"""
6969
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-09-05 02:53:54 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-09-12 17:50:28 +0000
@@ -98,12 +98,20 @@
9898
99 self.drag_page_down_to_previous_state()99 self.drag_page_down_to_previous_state()
100100
101 # Set hour101 # Set minute
102 self.assertThat(self.main_view.get_timer_hour_hand, Eventually(Not(Is(None))))102 self.assertThat(self.main_view.get_timer_minute_hand, Eventually(Not(Is(None))))
103 hour = self.main_view.get_timer_hour_hand()103 minute = self.main_view.get_timer_minute_hand()
104 x, y, w, h = hour.globalRect104
105 timeout = 0
106 while label.focus == True and timeout < 10:
107 TimerLabel = self.main_view.get_label_timer()
108 self.pointing_device.click_object(TimerLabel)
109 sleep(1)
110 timeout += 1
111
112 x, y, w, h = minute.globalRect
105 tx = x + (w / 2)113 tx = x + (w / 2)
106 ty = y + (h / 2)114 ty = y + (h / 2.5)
107 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))115 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))
108116
109 self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None))))117 self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None))))
@@ -145,7 +153,7 @@
145153
146 # Check has been deleted154 # Check has been deleted
147 self.assertThat(self.main_view.get_num_of_presets,155 self.assertThat(self.main_view.get_num_of_presets,
148 Eventually(Equals(num_of_presets_old-1)))156 Eventually(Equals(num_of_presets_old-1)))
149157
150 def test_run_preset(self):158 def test_run_preset(self):
151 """Tests if a preset can runs"""159 """Tests if a preset can runs"""
@@ -175,4 +183,4 @@
175 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))183 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))
176 label_timer = self.main_view.get_label_timer()184 label_timer = self.main_view.get_label_timer()
177 self.pointing_device.click_object(label_timer)185 self.pointing_device.click_object(label_timer)
178 self.assertThat(label_timer.text, Eventually(NotEquals("23:00:00")))186 self.assertThat(label_timer.text, Eventually(NotEquals("21:00")))
179187
=== modified file 'timer/AnalogTimer.qml'
--- timer/AnalogTimer.qml 2013-09-05 17:00:26 +0000
+++ timer/AnalogTimer.qml 2013-09-12 17:50:28 +0000
@@ -29,8 +29,7 @@
2929
30 // Properties to store/set the time variables30 // Properties to store/set the time variables
31 property int seconds: 0;31 property int seconds: 0;
32 property int minutes: 0;32 property int minutes: 0;
33 property int hours: 0;
34 property int totalTime: 0;33 property int totalTime: 0;
35 property int pauseTime: 0;34 property int pauseTime: 0;
3635
@@ -57,11 +56,9 @@
57 function ssToTime(time) {56 function ssToTime(time) {
58 seconds = time % 6057 seconds = time % 60
59 time = Math.floor(time / 60)58 time = Math.floor(time / 60)
60 minutes = time % 6059 minutes = time % 60
61 hours = Math.floor(time / 60)
62 secondHand.rotationValue = seconds * 6;60 secondHand.rotationValue = seconds * 6;
63 minuteHand.rotationValue = minutes * 6;61 minuteHand.rotationValue = minutes * 6;
64 hourHand.rotationValue = hours * 6;
65 }62 }
6663
67 // Function to disable timer and reset time64 // Function to disable timer and reset time
@@ -72,7 +69,7 @@
72 repeat: false69 repeat: false
73 onTriggered: {70 onTriggered: {
74 inProgressFlag = true;71 inProgressFlag = true;
75 hourHand.rotationValue = minuteHand.rotationValue = secondHand.rotationValue = 0;72 minuteHand.rotationValue = secondHand.rotationValue = 0;
76 inProgressFlag = false;73 inProgressFlag = false;
77 }74 }
78 }75 }
@@ -82,8 +79,8 @@
82 timerOn = false;79 timerOn = false;
83 state = "";80 state = "";
84 startTime = remTime = pauseTime = 0;81 startTime = remTime = pauseTime = 0;
85 hours = minutes = seconds = totalTime = 0;82 minutes = seconds = totalTime = 0;
86 hourHand.timerValue = minuteHand.timerValue = secondHand.timerValue = 0;83 minuteHand.timerValue = secondHand.timerValue = 0;
87 }84 }
8885
89 Repeater {86 Repeater {
@@ -95,23 +92,10 @@
95 }92 }
96 }93 }
9794
98 // Hour hand with touch/mouse drag support
99 AnalogTouchHand {
100 id: hourHand
101 objectName: "hourHand"
102
103 onTimerValueChanged: hours = timerValue;
104
105 handHeight: units.gu(12.5); handWidth: units.gu(1);
106 z: minuteHand.z + 1;
107 animateFlag: inProgressFlag;
108 enabled: !inProgressFlag;
109 grabMargin: units.gu(3);
110 }
111
112 // Minute hand with touch/mouse drag support95 // Minute hand with touch/mouse drag support
113 AnalogTouchHand {96 AnalogTouchHand {
114 id: minuteHand97 id: minuteHand
98 objectName: "minuteHand"
11599
116 onTimerValueChanged: minutes = timerValue;100 onTimerValueChanged: minutes = timerValue;
117101
118102
=== modified file 'timer/TimerPage.qml'
--- timer/TimerPage.qml 2013-09-09 18:06:30 +0000
+++ timer/TimerPage.qml 2013-09-12 17:50:28 +0000
@@ -29,7 +29,6 @@
2929
30 flickable: null30 flickable: null
3131
32 property alias hours: analogTimer.hours;
33 property alias minutes: analogTimer.minutes;32 property alias minutes: analogTimer.minutes;
34 property alias seconds: analogTimer.seconds;33 property alias seconds: analogTimer.seconds;
35 property alias totalTime: analogTimer.totalTime;34 property alias totalTime: analogTimer.totalTime;
@@ -54,8 +53,8 @@
54 id: saveTimerAction53 id: saveTimerAction
55 iconSource: Qt.resolvedUrl("../images/select_icon.png")54 iconSource: Qt.resolvedUrl("../images/select_icon.png")
56 text: i18n.tr("Save")55 text: i18n.tr("Save")
57 onTriggered: {56 onTriggered: {
58 presetModel.appendPreset(tempNamePreset, namePreset.text, Utils.totalSeconds(hours, minutes, seconds), listTimerPreset.currentIndex)57 presetModel.appendPreset(tempNamePreset, namePreset.text, ((minutes * 60) + seconds), listTimerPreset.currentIndex)
59 namePreset.focus = false58 namePreset.focus = false
60 if (listTimerPreset.currentIndex == -1) {59 if (listTimerPreset.currentIndex == -1) {
61 reset()60 reset()
@@ -105,6 +104,12 @@
105 analogTimer.onTimerUpdate();104 analogTimer.onTimerUpdate();
106 }105 }
107106
107 // Function to print timer label (format mm:ss and hh:mm:ss when hh > 0) at top
108 function intervalToString(minutes, seconds)
109 {
110 return Utils.zeroleft(minutes, 2) + ":" + Utils.zeroleft(seconds, 2);
111 }
112
108 function reset() {113 function reset() {
109 analogTimer.reset();114 analogTimer.reset();
110 listTimerPreset.currentIndex = -1;115 listTimerPreset.currentIndex = -1;
@@ -112,21 +117,18 @@
112 tempNamePreset = "";117 tempNamePreset = "";
113 }118 }
114119
115 // Function to calculate and print the hours, minutes and seconds from the total time as a string120 // Function to calculate and print the minutes and seconds from the total time as a string
116 function getstringTimer(time) {121 function getstringTimer(time) {
117 var hours, minutes, seconds;122 var minutes, seconds;
118123
119 seconds = time % 60124 seconds = time % 60
120 time = Math.floor(time / 60)125 time = Math.floor(time / 60)
121 minutes = time % 60126 minutes = time % 60
122 hours = Math.floor(time / 60)127
123128 return Utils.zeroleft(minutes, 2) + ":" + Utils.zeroleft(seconds, 2);
124 return Utils.hmsToString(hours, minutes, seconds);129 }
125 }130
126131 Component.onCompleted: Utils.log("TimerPage loaded");
127 Component.onCompleted: {
128 Utils.log("TimerPage loaded");
129 }
130132
131 AnimationContainer {133 AnimationContainer {
132 id: timerAnimationContainer134 id: timerAnimationContainer
@@ -152,7 +154,7 @@
152 color: Theme.palette.normal.baseText154 color: Theme.palette.normal.baseText
153155
154 fontSize: "x-large"156 fontSize: "x-large"
155 text: labelTimer.text = Utils.intervalToString(hours, minutes, seconds);157 text: labelTimer.text = intervalToString(minutes, seconds);
156 }158 }
157 }159 }
158160
@@ -165,7 +167,7 @@
165167
166 interval: 500168 interval: 500
167 repeat: true169 repeat: true
168 onTriggered: labelTimer.text = Utils.intervalToString(hours, minutes, seconds);170 onTriggered: labelTimer.text = intervalToString(minutes, seconds);
169 }171 }
170172
171 AnalogGlowEffect {173 AnalogGlowEffect {
@@ -179,10 +181,9 @@
179 anchors { top: parent.top; topMargin: presetModel.count != 0 ? units.gu(9) : units.gu(12); horizontalCenter: parent.horizontalCenter }181 anchors { top: parent.top; topMargin: presetModel.count != 0 ? units.gu(9) : units.gu(12); horizontalCenter: parent.horizontalCenter }
180 inProgressFlag: (timerOn == true || analogTimer.state == "DONE") ? true : false;182 inProgressFlag: (timerOn == true || analogTimer.state == "DONE") ? true : false;
181 onSecondsChanged: if (timerOn == true) seconds_timer.restart()183 onSecondsChanged: if (timerOn == true) seconds_timer.restart()
182 else labelTimer.text = Utils.intervalToString(hours, minutes, seconds);184 else labelTimer.text = intervalToString(minutes, seconds);
183185
184 onMinutesChanged: labelTimer.text = Utils.intervalToString(hours, minutes, seconds);186 onMinutesChanged: labelTimer.text = intervalToString(minutes, seconds);
185 onHoursChanged: labelTimer.text = Utils.intervalToString(hours, minutes, seconds);
186187
187 states:[188 states:[
188 State { name: "STOP" },189 State { name: "STOP" },
@@ -203,8 +204,8 @@
203 switch (analogTimer.state) {204 switch (analogTimer.state) {
204205
205 case "":206 case "":
206 if ((seconds != 0 || hours != 0 || minutes != 0) || timerOn) {207 if ((seconds != 0 || minutes != 0) || timerOn) {
207 totalTime = Utils.totalSeconds(hours, minutes, seconds);208 totalTime = (minutes * 60) + seconds;
208 analogTimer.startTime = new Date();209 analogTimer.startTime = new Date();
209 timerOn = true;210 timerOn = true;
210 analogTimer.state = "STOP";211 analogTimer.state = "STOP";
@@ -280,7 +281,7 @@
280 anchors { top: analogTimer.bottom; topMargin: units.gu(7); horizontalCenter: analogTimer.horizontalCenter; leftMargin: units.gu(4) }281 anchors { top: analogTimer.bottom; topMargin: units.gu(7); horizontalCenter: analogTimer.horizontalCenter; leftMargin: units.gu(4) }
281 buttonImage: Qt.resolvedUrl("../images/reset_icon.svg");282 buttonImage: Qt.resolvedUrl("../images/reset_icon.svg");
282 buttonLabel: i18n.tr("Reset");283 buttonLabel: i18n.tr("Reset");
283 visible: timerOn || (hours != 0 || minutes != 0 || seconds != 0)? true : false;284 visible: timerOn || (minutes != 0 || seconds != 0)? true : false;
284 enabled: true285 enabled: true
285286
286 onClicked: {287 onClicked: {

Subscribers

People subscribed via source and target branches