Merge lp:~doflah/dialer-app/show_duration_hours into lp:dialer-app

Proposed by Dennis O'Flaherty
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 293
Merged at revision: 326
Proposed branch: lp:~doflah/dialer-app/show_duration_hours
Merge into: lp:dialer-app
Diff against target: 128 lines (+83/-11)
3 files modified
src/qml/LiveCallPage/StopWatch.qml (+4/-11)
tests/qml/CMakeLists.txt (+2/-0)
tests/qml/tst_StopWatch.qml (+77/-0)
To merge this branch: bzr merge lp:~doflah/dialer-app/show_duration_hours
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+235552@code.launchpad.net

Commit message

Show hours in the call duration - fixes #1372689

Description of the change

Show hours in the call duration - fixes #1372689

To post a comment you must log in.
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

27 + if (minutes < 10) minutes = "0" + minutes;
28 + if (seconds < 10) seconds = "0" + seconds;

Can you instead just use pad(minutes, 2) just like it was being used before?

Actually, now that I am looking at the patch, maybe we should create a Date object representing the duration and use Qt.formatTime() to format the display according to the user locale.

Would you mind experimenting with that and see if it is possible?

Thanks for the patch.

review: Needs Fixing
290. By Dennis O'Flaherty

Implement feedback and add tests

291. By Dennis O'Flaherty

Use formatTime

292. By Dennis O'Flaherty

Pass seconds value to constructor instead of a separate setSeconds call

Revision history for this message
Dennis O'Flaherty (doflah) wrote :

Using formatTime really cleans it up. I doubt we need to go out to "days" since a 24-hour phone call is probably well outside the typical use case.

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Code looks good and works as expected!

review: Approve
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

I'm sorry it is taking so long for this change to get merged.
Would you mind merging latest changes from trunk into your branch?

293. By Dennis O'Flaherty

Merge from trunk

Revision history for this message
Dennis O'Flaherty (doflah) wrote :

Done!

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Thanks!

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/LiveCallPage/StopWatch.qml'
2--- src/qml/LiveCallPage/StopWatch.qml 2014-07-23 10:13:32 +0000
3+++ src/qml/LiveCallPage/StopWatch.qml 2014-12-16 01:44:35 +0000
4@@ -20,19 +20,12 @@
5 import Ubuntu.Components 1.1
6
7 Item {
8- function pad(text, length) {
9- while (text.length < length) text = '0' + text;
10- return text;
11- }
12
13 property int time: 0
14 property string elapsed: {
15- var divisor_for_minutes = time % (60 * 60);
16- var minutes = String(Math.floor(divisor_for_minutes / 60));
17-
18- var divisor_for_seconds = divisor_for_minutes % 60;
19- var seconds = String(Math.ceil(divisor_for_seconds));
20-
21- return "%1:%2".arg(pad(minutes, 2)).arg(pad(seconds, 2));
22+ var d = new Date(0, 0, 0, 0, 0, time);
23+
24+ return d.getHours() == 0 ? Qt.formatTime(d, "mm:ss") :
25+ Qt.formatTime(d, "h:mm:ss");
26 }
27 }
28
29=== modified file 'tests/qml/CMakeLists.txt'
30--- tests/qml/CMakeLists.txt 2014-11-03 22:53:15 +0000
31+++ tests/qml/CMakeLists.txt 2014-12-16 01:44:35 +0000
32@@ -18,6 +18,7 @@
33 if(QMLTESTRUNNER_BIN AND XVFB_RUN_BIN)
34 declare_qml_test("keypad_button" tst_KeypadButton.qml)
35 declare_qml_test("main_view" tst_MainView.qml)
36+ declare_qml_test("stopwatch" tst_StopWatch.qml)
37 else()
38 if (NOT QMLTESTRUNNER_BIN)
39 message(WARNING "Qml tests disabled: qmltestrunner not found")
40@@ -28,5 +29,6 @@
41
42 set(QML_TST_FILES
43 tst_KeypadButton.qml
44+ tst_StopWatch.qml
45 )
46 add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})
47
48=== added file 'tests/qml/tst_StopWatch.qml'
49--- tests/qml/tst_StopWatch.qml 1970-01-01 00:00:00 +0000
50+++ tests/qml/tst_StopWatch.qml 2014-12-16 01:44:35 +0000
51@@ -0,0 +1,77 @@
52+/*
53+ * Copyright 2014 Canonical Ltd.
54+ *
55+ * This file is part of dialer-app.
56+ *
57+ * dialer-app is free software; you can redistribute it and/or modify
58+ * it under the terms of the GNU General Public License as published by
59+ * the Free Software Foundation; version 3.
60+ *
61+ * dialer-app is distributed in the hope that it will be useful,
62+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
63+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64+ * GNU General Public License for more details.
65+ *
66+ * You should have received a copy of the GNU General Public License
67+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
68+ */
69+
70+import QtQuick 2.2
71+import QtTest 1.0
72+import Ubuntu.Test 0.1
73+
74+import '../../src/qml/LiveCallPage'
75+
76+Item {
77+ id: root
78+
79+ width: units.gu(40)
80+ height: units.gu(60)
81+
82+ StopWatch {
83+ id: timer
84+ }
85+
86+ UbuntuTestCase {
87+ id: stopWatchTestCase
88+ name: 'stopWatchTestCase'
89+
90+ when: windowShown
91+
92+ function test_zero() {
93+ timer.time = 0;
94+ compare(timer.elapsed, "00:00");
95+ }
96+
97+ function test_thirty_seconds() {
98+ timer.time = 30;
99+ compare(timer.elapsed, "00:30");
100+ }
101+
102+ function test_one_minute() {
103+ timer.time = 60;
104+ compare(timer.elapsed, "01:00");
105+ }
106+
107+ function test_one_hour() {
108+ timer.time = 3600;
109+ compare(timer.elapsed, "1:00:00");
110+ }
111+
112+ function test_hour_thirty_seconds() {
113+ timer.time = 3600 + 30;
114+ compare(timer.elapsed, "1:00:30");
115+ }
116+
117+ function test_hour_one_minute() {
118+ timer.time = 3600 + 60;
119+ compare(timer.elapsed, "1:01:00");
120+ }
121+
122+ function test_hour_one_minute_thirty_seconds() {
123+ timer.time = 3600 + 60 + 30;
124+ compare(timer.elapsed, "1:01:30");
125+ }
126+ }
127+
128+}

Subscribers

People subscribed via source and target branches