Merge lp:~rpadovani/ubuntu-clock-app/1166264 into lp:ubuntu-clock-app/saucy

Proposed by Riccardo Padovani
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 141
Merged at revision: 138
Proposed branch: lp:~rpadovani/ubuntu-clock-app/1166264
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 87 lines (+29/-4)
2 files modified
timer/AnalogTimer.qml (+3/-2)
timer/TimerPage.qml (+26/-2)
To merge this branch: bzr merge lp:~rpadovani/ubuntu-clock-app/1166264
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nekhelesh Ramananthan Approve
Review via email: mp+174458@code.launchpad.net

Commit message

Added possibility to pause timer
Added reset button to timer
See #1166264

Description of the change

Added possibility to pause timer
Added reset button to timer
See #1166264

To post a comment you must log in.
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Nice work. There are some things which need fixing.

It is not required to copy ImageButton.qml from the stopwatch folder to the timer folder. In the timerpage.qml file where you used it, you can just add a statement "import ../stopwatch". This avoid code duplication. Ideally speaking the ImageButton.qml file needs to be moved to the common folder since it is now being used by both Timer and Stopwatch, but this can be addressed in another commit.

review: Needs Fixing
139. By Riccardo Padovani

Moved ImageButton.qml to common

140. By Riccardo Padovani

Bugfix for reset code. Centered reset button

141. By Riccardo Padovani

update reset function

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

Could you move the pauseTime = 0, to AnalogTimer.qml? There is a reset function in that file where you can append it by,

startTime = remTime = pauseTime = 0.

This would make them all be in one central place.

Proceeding to test bug fix in all scenarios. Otherwise it looks good.

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

lgtm! No regressions during my testing. Code style is clean.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== renamed file 'stopwatch/ImageButton.qml' => 'common/ImageButton.qml'
=== modified file 'timer/AnalogTimer.qml'
--- timer/AnalogTimer.qml 2013-07-09 20:26:23 +0000
+++ timer/AnalogTimer.qml 2013-07-12 17:11:34 +0000
@@ -33,6 +33,7 @@
33 property int minutes: 0;33 property int minutes: 0;
34 property int hours: 0;34 property int hours: 0;
35 property int totalTime: 0;35 property int totalTime: 0;
36 property int pauseTime: 0;
3637
37 // Property to activate/deactivate the timer38 // Property to activate/deactivate the timer
38 property bool timerOn: false;39 property bool timerOn: false;
@@ -41,7 +42,7 @@
41 // Timer function called by the main clock loop42 // Timer function called by the main clock loop
42 function onTimerUpdate () {43 function onTimerUpdate () {
43 if( timerOn ) {44 if( timerOn ) {
44 remTime = totalTime - Math.floor((new Date() - startTime)/ 1000);45 remTime = totalTime - Math.floor((new Date() - startTime)/ 1000) - pauseTime;
4546
46 if (remTime < 0) {47 if (remTime < 0) {
47 timerOn = false48 timerOn = false
@@ -66,7 +67,7 @@
66 // Function to disable timer and reset time67 // Function to disable timer and reset time
67 function reset() {68 function reset() {
68 timerOn = false;69 timerOn = false;
69 startTime = remTime = 0;70 startTime = remTime = pauseTime = 0;
70 hourHand.rotationValue = minuteHand.rotationValue = secondHand.rotationValue = 0;71 hourHand.rotationValue = minuteHand.rotationValue = secondHand.rotationValue = 0;
71 hours = minutes = seconds = totalTime = 0;72 hours = minutes = seconds = totalTime = 0;
72 hourHand.timerValue = minuteHand.timerValue = secondHand.timerValue = 0;73 hourHand.timerValue = minuteHand.timerValue = secondHand.timerValue = 0;
7374
=== modified file 'timer/TimerPage.qml'
--- timer/TimerPage.qml 2013-07-09 20:26:23 +0000
+++ timer/TimerPage.qml 2013-07-12 17:11:34 +0000
@@ -131,6 +131,7 @@
131131
132 states:[132 states:[
133 State { name: "STOP" },133 State { name: "STOP" },
134 State { name: "PAUSE"},
134 State {135 State {
135 name: "DONE"136 name: "DONE"
136 when: (totalTime == -1 && timerOn == false)137 when: (totalTime == -1 && timerOn == false)
@@ -157,19 +158,42 @@
157 break;158 break;
158159
159 case "STOP":160 case "STOP":
160 reset();161 timerOn = false;
161 analogTimer.state = "";162 analogTimer.pauseTime = analogTimer.totalTime - analogTimer.remTime + 1; // +1 is necessary to start immediately the timer when finish a pause
163 analogTimer.state = "PAUSE";
162 break;164 break;
163165
164 case "DONE":166 case "DONE":
165 reset();167 reset();
166 analogTimer.state = "";168 analogTimer.state = "";
167 break;169 break;
170
171 case "PAUSE":
172 analogTimer.startTime = new Date();
173 timerOn = true;
174 analogTimer.state = "STOP";
175 break;
168 }176 }
169 }177 }
170 }178 }
171 }179 }
172180
181 ImageButton {
182 id: resetButtonTimer
183 objectName: "resetButtonTimer"
184
185 anchors { top: analogTimer.bottom; topMargin: units.gu(4); horizontalCenter: analogTimer.horizontalCenter; leftMargin: units.gu(4) }
186 buttonImage: Qt.resolvedUrl("../images/reset_icon.png");
187 buttonLabel: i18n.tr("Reset");
188
189 activated: true
190
191 onClicked: {
192 reset();
193 analogTimer.state = "";
194 }
195 }
196
173 // Column element to hold the saved presets197 // Column element to hold the saved presets
174 Column {198 Column {
175 id: listPreset199 id: listPreset

Subscribers

People subscribed via source and target branches