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
1=== renamed file 'stopwatch/ImageButton.qml' => 'common/ImageButton.qml'
2=== modified file 'timer/AnalogTimer.qml'
3--- timer/AnalogTimer.qml 2013-07-09 20:26:23 +0000
4+++ timer/AnalogTimer.qml 2013-07-12 17:11:34 +0000
5@@ -33,6 +33,7 @@
6 property int minutes: 0;
7 property int hours: 0;
8 property int totalTime: 0;
9+ property int pauseTime: 0;
10
11 // Property to activate/deactivate the timer
12 property bool timerOn: false;
13@@ -41,7 +42,7 @@
14 // Timer function called by the main clock loop
15 function onTimerUpdate () {
16 if( timerOn ) {
17- remTime = totalTime - Math.floor((new Date() - startTime)/ 1000);
18+ remTime = totalTime - Math.floor((new Date() - startTime)/ 1000) - pauseTime;
19
20 if (remTime < 0) {
21 timerOn = false
22@@ -66,7 +67,7 @@
23 // Function to disable timer and reset time
24 function reset() {
25 timerOn = false;
26- startTime = remTime = 0;
27+ startTime = remTime = pauseTime = 0;
28 hourHand.rotationValue = minuteHand.rotationValue = secondHand.rotationValue = 0;
29 hours = minutes = seconds = totalTime = 0;
30 hourHand.timerValue = minuteHand.timerValue = secondHand.timerValue = 0;
31
32=== modified file 'timer/TimerPage.qml'
33--- timer/TimerPage.qml 2013-07-09 20:26:23 +0000
34+++ timer/TimerPage.qml 2013-07-12 17:11:34 +0000
35@@ -131,6 +131,7 @@
36
37 states:[
38 State { name: "STOP" },
39+ State { name: "PAUSE"},
40 State {
41 name: "DONE"
42 when: (totalTime == -1 && timerOn == false)
43@@ -157,19 +158,42 @@
44 break;
45
46 case "STOP":
47- reset();
48- analogTimer.state = "";
49+ timerOn = false;
50+ analogTimer.pauseTime = analogTimer.totalTime - analogTimer.remTime + 1; // +1 is necessary to start immediately the timer when finish a pause
51+ analogTimer.state = "PAUSE";
52 break;
53
54 case "DONE":
55 reset();
56 analogTimer.state = "";
57 break;
58+
59+ case "PAUSE":
60+ analogTimer.startTime = new Date();
61+ timerOn = true;
62+ analogTimer.state = "STOP";
63+ break;
64 }
65 }
66 }
67 }
68
69+ ImageButton {
70+ id: resetButtonTimer
71+ objectName: "resetButtonTimer"
72+
73+ anchors { top: analogTimer.bottom; topMargin: units.gu(4); horizontalCenter: analogTimer.horizontalCenter; leftMargin: units.gu(4) }
74+ buttonImage: Qt.resolvedUrl("../images/reset_icon.png");
75+ buttonLabel: i18n.tr("Reset");
76+
77+ activated: true
78+
79+ onClicked: {
80+ reset();
81+ analogTimer.state = "";
82+ }
83+ }
84+
85 // Column element to hold the saved presets
86 Column {
87 id: listPreset

Subscribers

People subscribed via source and target branches