Merge lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
- ubuntu-clock-stopwatch-runtime-timezone-fix
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Alan Pope πΊπ§π± π¦ |
Approved revision: | 390 |
Merged at revision: | 384 |
Proposed branch: | lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix |
Merge into: | lp:ubuntu-clock-app |
Diff against target: |
621 lines (+224/-116) 14 files modified
README.autopilot (+1/-1) README.developers (+2/-2) README.unittest (+3/-3) app/MainPage.qml (+3/-10) app/components/HeaderNavigation.qml (+1/-1) app/stopwatch/LapListView.qml (+1/-1) app/stopwatch/StopwatchPage.qml (+18/-71) backend/CMakeLists.txt (+1/-1) backend/modules/Stopwatch/backend.cpp (+2/-2) backend/modules/Stopwatch/engine.cpp (+113/-10) backend/modules/Stopwatch/engine.h (+56/-14) debian/changelog (+1/-0) tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/stopwatch.pxu (+21/-0) tests/manual/2014.com.ubuntu.clock:clock-tests/whitelists/clock-app-stopwatch.whitelist (+1/-0) |
To merge this branch: | bzr merge lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Bartosz Kosiorek | Approve | ||
Nekhelesh Ramananthan | testing and code review. | Approve | |
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Victor Thompson | Needs Fixing | ||
Michael Zanetti | Pending | ||
Review via email: mp+270396@code.launchpad.net |
Commit message
Rewrote stopwatch engine in c++ which should improve performance and fix all timezone issues.
Description of the change
Fix stopwatch issue appearing during changing timezone during runtime (LP: #1493358)
- 371. By Bartosz Kosiorek
-
Update changelog
- 372. By Bartosz Kosiorek
-
Remove not needed code
- 373. By Bartosz Kosiorek
-
Merge with trunk
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
- 374. By Bartosz Kosiorek
-
Fixing resume and stoping stopwatch
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:374
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nekhelesh Ramananthan (nik90) wrote : | # |
I haven't had the time to do a full code review yet, but I see it is missing manual tests for this bug 1493358 and bug 1491024. Please fix that. It should at most another 10 mins.
Victor Thompson (vthompson) wrote : | # |
Please also at least fix the spelling error for "appering" in the commit message.
Victor Thompson (vthompson) wrote : | # |
Please also at least fix the spelling error for "appering" in the commit message.
Nekhelesh Ramananthan (nik90) wrote : | # |
A couple minor points,
1. Please rename, startStopwatch() function to something like setStopwatchSta
2. I think we could move "running", "previousLapTime", "lapsTime" properties and even start(), update(), stop() into the c++ class and just use Stopwatch.qml for managing the UI alone. I mention this because all other stuff seems to have already been moved into the c++ class.
Bartosz Kosiorek (gang65) wrote : | # |
Thanks for comments guys.
I will apply them soon.
Have you tested stopwatch itself? Is it working for you correctly?
- 375. By Bartosz Kosiorek
-
Refactor class and variable names
- 376. By Bartosz Kosiorek
-
Rename clear method to clearLaps
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:376
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 377. By Bartosz Kosiorek
-
Rename file names
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:377
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 378. By Bartosz Kosiorek
-
Migrate engine to C++
- 379. By Bartosz Kosiorek
-
Fix small issues with C++ code
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:379
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
- 380. By Bartosz Kosiorek
-
Minor changes
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:380
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 381. By Bartosz Kosiorek
-
Switch automatically to stopwatch when stopwatch is running
- 382. By Bartosz Kosiorek
-
Update manual tests
- 383. By Bartosz Kosiorek
-
Small dim fix
- 384. By Bartosz Kosiorek
-
Make set methods as private
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:384
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
- 385. By Bartosz Kosiorek
-
Engines fixes which include,
- Ensure get() functions only return the variable value and nothing else
- Renamed property isRunning to Running to match upstream Qt property naming
- Added a updateStopwatch() public slot
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:385
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
- 386. By Bartosz Kosiorek
-
Merge with trunk
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:386
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nekhelesh Ramananthan (nik90) wrote : | # |
Added some inline comments to improve manual test wordings.
Nekhelesh Ramananthan (nik90) wrote : | # |
I also think we should move the initialization of the StopwatchEngine{} to the StopwatchPage.qml and just expose the running property to the mainPage.qml.
- 387. By Bartosz Kosiorek
-
Update manual tests
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:387
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 388. By Bartosz Kosiorek
-
- Replace QML Timer with QTimer
- Move StopwatchEngine to StopwatchPage.qml
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:388
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nekhelesh Ramananthan (nik90) wrote : | # |
I am going to test the new engine tonight. I would like Michael Zanetti to quickly glance through the c++ code and check if everything is good.
- 389. By Bartosz Kosiorek
-
Merge with trunk
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:389
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 390. By Bartosz Kosiorek
-
Increase default number of jobs to 3 in README files
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:390
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nekhelesh Ramananthan (nik90) wrote : | # |
Did manual testing for about 12 hrs, and tried stuff like changing timezones, closing app and reopening it...and what not. It works really well. Also did a code review and looks good. Approving.
Bartosz Kosiorek (gang65) : | # |
Preview Diff
1 | === modified file 'README.autopilot' |
2 | --- README.autopilot 2015-08-12 19:04:13 +0000 |
3 | +++ README.autopilot 2015-09-12 11:55:48 +0000 |
4 | @@ -32,7 +32,7 @@ |
5 | |
6 | * Build the clock app, |
7 | $ mkdir builddir && cd builddir |
8 | - $ cmake .. && make |
9 | + $ cmake .. && cmake --build . -- -j 3 |
10 | $ cd .. |
11 | |
12 | * Navigate to the tests/autopilot directory. |
13 | |
14 | === modified file 'README.developers' |
15 | --- README.developers 2015-08-12 19:04:13 +0000 |
16 | +++ README.developers 2015-09-12 11:55:48 +0000 |
17 | @@ -7,7 +7,7 @@ |
18 | $ bzr branch lp:ubuntu-clock-app branch-name |
19 | $ cd branch-name |
20 | $ mkdir builddir && cd builddir |
21 | - $ cmake .. && cmake --build . |
22 | + $ cmake .. && cmake --build . -- -j 3 |
23 | $ qmlscene ../app/ubuntu-clock-app.qml -I backend/ |
24 | |
25 | Submitting a patch upstream |
26 | @@ -56,7 +56,7 @@ |
27 | |
28 | $ cd branch-name |
29 | $ mkdir builddir && cd builddir |
30 | - $ cmake -DCMAKE_BUILD_TYPE=Debug .. && cmake --build . |
31 | + $ cmake -DCMAKE_BUILD_TYPE=Debug .. && cmake --build . -- -j 3 |
32 | |
33 | To run GDB: |
34 | |
35 | |
36 | === modified file 'README.unittest' |
37 | --- README.unittest 2015-08-12 19:04:13 +0000 |
38 | +++ README.unittest 2015-09-12 11:55:48 +0000 |
39 | @@ -10,11 +10,11 @@ |
40 | merge request. |
41 | |
42 | * Branch the clock app code, |
43 | - $ bzr branch lp:ubuntu-clock-app/reboot |
44 | - |
45 | + $ bzr branch lp:ubuntu-clock-app |
46 | + |
47 | * Build the clock app, |
48 | $ mkdir builddir && cd builddir |
49 | - $ cmake .. && make |
50 | + $ cmake .. && cmake --build . -- -j 3 |
51 | |
52 | Running all unit test at once |
53 | ============================= |
54 | |
55 | === modified file 'app/MainPage.qml' |
56 | --- app/MainPage.qml 2015-08-20 16:03:35 +0000 |
57 | +++ app/MainPage.qml 2015-09-12 11:55:48 +0000 |
58 | @@ -57,15 +57,7 @@ |
59 | |
60 | ScreenSaver { |
61 | // Disable screen dimming/off when stopwatch is running |
62 | - screenSaverEnabled: !stopwatchPage.running |
63 | - } |
64 | - |
65 | - Settings { |
66 | - id: stopwatchState |
67 | - category: "Stopwatch" |
68 | - property alias startTime: stopwatchPage.startTime |
69 | - property alias running: stopwatchPage.running |
70 | - property alias oldDiff: stopwatchPage.oldDiff |
71 | + screenSaverEnabled: !stopwatchPage.isRunning |
72 | } |
73 | |
74 | VisualItemModel { |
75 | @@ -100,8 +92,9 @@ |
76 | |
77 | // Show the stopwatch page on app startup if it is running |
78 | Component.onCompleted: { |
79 | - if (stopwatchState.running) |
80 | + if (stopwatchPage.isRunning) { |
81 | positionViewAtIndex(1, ListView.SnapPosition) |
82 | + } |
83 | } |
84 | |
85 | anchors { |
86 | |
87 | === modified file 'app/components/HeaderNavigation.qml' |
88 | --- app/components/HeaderNavigation.qml 2015-08-17 12:25:22 +0000 |
89 | +++ app/components/HeaderNavigation.qml 2015-09-12 11:55:48 +0000 |
90 | @@ -58,7 +58,7 @@ |
91 | |
92 | Rectangle { |
93 | height: parent.height |
94 | - x: listview.currentIndex == 0 ? 0 : parent.width-width |
95 | + x: listview.currentIndex == 0 ? 0 : parent.width - width |
96 | width: units.gu(5.5) |
97 | color: UbuntuColors.orange |
98 | Behavior on x { |
99 | |
100 | === modified file 'app/stopwatch/LapListView.qml' |
101 | --- app/stopwatch/LapListView.qml 2015-08-26 22:41:34 +0000 |
102 | +++ app/stopwatch/LapListView.qml 2015-09-12 11:55:48 +0000 |
103 | @@ -82,7 +82,7 @@ |
104 | Action { |
105 | iconName: "delete" |
106 | onTriggered: { |
107 | - lapHistory.removeLap(index) |
108 | + stopwatchEngine.removeLap(index) |
109 | } |
110 | } |
111 | ] |
112 | |
113 | === modified file 'app/stopwatch/StopwatchPage.qml' |
114 | --- app/stopwatch/StopwatchPage.qml 2015-09-02 13:15:50 +0000 |
115 | +++ app/stopwatch/StopwatchPage.qml 2015-09-12 11:55:48 +0000 |
116 | @@ -24,69 +24,21 @@ |
117 | id: _stopwatchPage |
118 | objectName: "stopwatchPage" |
119 | |
120 | - property date startTime: getUTCDate() |
121 | - property date snapshot: startTime |
122 | - property bool running: false |
123 | - |
124 | - property int timeDiff: snapshot - startTime |
125 | - property int oldDiff: 0 |
126 | - |
127 | - property int totalTimeDiff: timeDiff + oldDiff |
128 | + property alias isRunning: stopwatchEngine.running |
129 | |
130 | Component.onCompleted: { |
131 | console.log("[LOG]: Stopwatch Page Loaded") |
132 | } |
133 | |
134 | - function getUTCDate() { |
135 | - var localDate = new Date() |
136 | - return new Date(localDate.getUTCFullYear(), |
137 | - localDate.getUTCMonth(), |
138 | - localDate.getUTCDate(), |
139 | - localDate.getUTCHours(), |
140 | - localDate.getUTCMinutes(), |
141 | - localDate.getUTCSeconds(), |
142 | - localDate.getUTCMilliseconds()) |
143 | - } |
144 | - |
145 | - function start() { |
146 | - startTime = getUTCDate() |
147 | - snapshot = startTime |
148 | - running = true |
149 | - } |
150 | - |
151 | - function stop() { |
152 | - oldDiff += timeDiff |
153 | - startTime = getUTCDate() |
154 | - snapshot = startTime |
155 | - running = false |
156 | - } |
157 | - |
158 | - function update() { |
159 | - snapshot = getUTCDate() |
160 | - } |
161 | - |
162 | - function clear() { |
163 | - oldDiff = 0 |
164 | - startTime = getUTCDate() |
165 | - snapshot = startTime |
166 | - lapHistory.clear() |
167 | - } |
168 | - |
169 | - Timer { |
170 | - id: refreshTimer |
171 | - interval: 45 |
172 | - repeat: true |
173 | - running: _stopwatchPage.running |
174 | - onTriggered: { |
175 | - _stopwatchPage.update() |
176 | - } |
177 | + StopwatchEngine { |
178 | + id: stopwatchEngine |
179 | } |
180 | |
181 | StopwatchFace { |
182 | id: stopwatch |
183 | objectName: "stopwatch" |
184 | |
185 | - milliseconds: _stopwatchPage.totalTimeDiff |
186 | + milliseconds: stopwatchEngine.totalTimeOfStopwatch |
187 | |
188 | anchors { |
189 | top: parent.top |
190 | @@ -109,14 +61,14 @@ |
191 | |
192 | Button { |
193 | id: stopButton |
194 | - width: oldDiff !== 0 || running ? (parent.width - parent.spacing) / 2 : parent.width |
195 | - color: !_stopwatchPage.running ? UbuntuColors.green : UbuntuColors.red |
196 | - text: _stopwatchPage.running ? i18n.tr("Stop") : (oldDiff === 0 ? i18n.tr("Start") : i18n.tr("Resume")) |
197 | + width: stopwatchEngine.previousTimeOfStopwatch !== 0 || stopwatchEngine.running ? (parent.width - parent.spacing) / 2 : parent.width |
198 | + color: !stopwatchEngine.running ? UbuntuColors.green : UbuntuColors.red |
199 | + text: stopwatchEngine.running ? i18n.tr("Stop") : (stopwatchEngine.previousTimeOfStopwatch === 0 ? i18n.tr("Start") : i18n.tr("Resume")) |
200 | onClicked: { |
201 | - if (_stopwatchPage.running) { |
202 | - _stopwatchPage.stop() |
203 | + if (stopwatchEngine.running) { |
204 | + stopwatchEngine.pauseStopwatch(); |
205 | } else { |
206 | - _stopwatchPage.start() |
207 | + stopwatchEngine.startStopwatch(); |
208 | } |
209 | } |
210 | Behavior on width { |
211 | @@ -128,16 +80,15 @@ |
212 | |
213 | Button { |
214 | id: lapButton |
215 | - text: _stopwatchPage.running ? i18n.tr("Lap") : i18n.tr("Clear") |
216 | - width: oldDiff !== 0 || running ? (parent.width - parent.spacing) / 2 : 0 |
217 | + text: stopwatchEngine.running ? i18n.tr("Lap") : i18n.tr("Clear") |
218 | + width: stopwatchEngine.previousTimeOfStopwatch !== 0 || stopwatchEngine.running ? (parent.width - parent.spacing) / 2 : 0 |
219 | strokeColor: UbuntuColors.lightGrey |
220 | - visible: oldDiff !== 0 || running |
221 | + visible: stopwatchEngine.previousTimeOfStopwatch !== 0 || stopwatchEngine.running |
222 | onClicked: { |
223 | - if (_stopwatchPage.running) { |
224 | - _stopwatchPage.update() |
225 | - lapHistory.addLap(_stopwatchPage.totalTimeDiff) |
226 | + if (stopwatchEngine.running) { |
227 | + stopwatchEngine.addLap() |
228 | } else { |
229 | - _stopwatchPage.clear() |
230 | + stopwatchEngine.clearStopwatch() |
231 | } |
232 | } |
233 | Behavior on width { |
234 | @@ -162,19 +113,15 @@ |
235 | Loader { |
236 | id: lapListViewLoader |
237 | anchors.fill: parent |
238 | - sourceComponent: !_stopwatchPage.running && _stopwatchPage.totalTimeDiff == 0 ? undefined : lapListViewComponent |
239 | + sourceComponent: !stopwatchEngine.running && stopwatchEngine.totalTimeOfStopwatch === 0 ? undefined : lapListViewComponent |
240 | } |
241 | } |
242 | |
243 | - LapHistory { |
244 | - id: lapHistory |
245 | - } |
246 | - |
247 | Component { |
248 | id: lapListViewComponent |
249 | LapListView { |
250 | id: lapListView |
251 | - model: lapHistory |
252 | + model: stopwatchEngine |
253 | } |
254 | } |
255 | } |
256 | |
257 | === modified file 'backend/CMakeLists.txt' |
258 | --- backend/CMakeLists.txt 2015-08-26 23:37:06 +0000 |
259 | +++ backend/CMakeLists.txt 2015-09-12 11:55:48 +0000 |
260 | @@ -28,7 +28,7 @@ |
261 | set( |
262 | stopwatch_SRCS |
263 | modules/Stopwatch/backend.cpp |
264 | - modules/Stopwatch/history.cpp |
265 | + modules/Stopwatch/engine.cpp |
266 | modules/Stopwatch/formattime.cpp |
267 | ) |
268 | |
269 | |
270 | === modified file 'backend/modules/Stopwatch/backend.cpp' |
271 | --- backend/modules/Stopwatch/backend.cpp 2015-08-26 22:41:34 +0000 |
272 | +++ backend/modules/Stopwatch/backend.cpp 2015-09-12 11:55:48 +0000 |
273 | @@ -19,14 +19,14 @@ |
274 | #include <QtQml> |
275 | #include <QtQml/QQmlContext> |
276 | #include "backend.h" |
277 | -#include "history.h" |
278 | +#include "engine.h" |
279 | #include "formattime.h" |
280 | |
281 | void BackendPlugin::registerTypes(const char *uri) |
282 | { |
283 | Q_ASSERT(uri == QLatin1String("Stopwatch")); |
284 | |
285 | - qmlRegisterType<LapHistory>(uri, 1, 0, "LapHistory"); |
286 | + qmlRegisterType<StopwatchEngine>(uri, 1, 0, "StopwatchEngine"); |
287 | qmlRegisterType<FormatTime>(uri, 1, 0, "StopwatchFormatTime"); |
288 | } |
289 | |
290 | |
291 | === renamed file 'backend/modules/Stopwatch/history.cpp' => 'backend/modules/Stopwatch/engine.cpp' |
292 | --- backend/modules/Stopwatch/history.cpp 2015-08-24 23:37:28 +0000 |
293 | +++ backend/modules/Stopwatch/engine.cpp 2015-09-12 11:55:48 +0000 |
294 | @@ -16,24 +16,47 @@ |
295 | * * |
296 | ****************************************************************************/ |
297 | |
298 | -#include "history.h" |
299 | +#include "engine.h" |
300 | |
301 | #include <QStandardPaths> |
302 | #include <QDebug> |
303 | |
304 | -LapHistory::LapHistory(QObject *parent) : |
305 | +StopwatchEngine::StopwatchEngine(QObject *parent) : |
306 | QAbstractListModel(parent), |
307 | /* |
308 | #FIXME: Change QStandardPaths::ConfigLocation to QStandardPaths::AppConfigLocation |
309 | when Ubuntu Touch moves over to Qt 5.5. AppConfigLocation will directly return |
310 | /home/phablet/.config/com.ubuntu.clock path. |
311 | */ |
312 | - m_settings(QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).first() + "/com.ubuntu.clock/com.ubuntu.clock.conf", QSettings::IniFormat) |
313 | + m_settings(QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).first() + "/com.ubuntu.clock/com.ubuntu.clock.conf", QSettings::IniFormat), |
314 | + m_previousTimeInmsecs(0), |
315 | + m_totalTimeInmsecs(0) |
316 | { |
317 | qDebug() << "[LOG] Loading laps from " << m_settings.fileName(); |
318 | + |
319 | + m_timer.setInterval(45); |
320 | + connect(&m_timer, &QTimer::timeout, this, &StopwatchEngine::updateStopwatch); |
321 | + |
322 | + QDateTime startTime = m_settings.value("Stopwatch/startDateTime").toDateTime(); |
323 | + if(startTime.isValid()) |
324 | + { |
325 | + m_stopwatchStartDateTime = startTime; |
326 | + } |
327 | + |
328 | + m_isStopwatchRunning = m_settings.value("Stopwatch/isStopwatchRunning").toBool(); |
329 | + m_previousTimeInmsecs = m_settings.value("Stopwatch/previousTimeInmsecs").toInt(); |
330 | + |
331 | + if(m_previousTimeInmsecs != 0) { |
332 | + setTotalTimeOfStopwatch(m_previousTimeInmsecs); |
333 | + } |
334 | + |
335 | + if(m_isStopwatchRunning == true) |
336 | + { |
337 | + m_timer.start(); |
338 | + } |
339 | } |
340 | |
341 | -int LapHistory::rowCount(const QModelIndex &parent) const |
342 | +int StopwatchEngine::rowCount(const QModelIndex &parent) const |
343 | { |
344 | /* |
345 | QT's models also handle tables and tree views, so the index is not just a |
346 | @@ -46,7 +69,7 @@ |
347 | return m_settings.value("Stopwatch/laps").toList().count(); |
348 | } |
349 | |
350 | -QVariant LapHistory::data(const QModelIndex &index, int role) const |
351 | +QVariant StopwatchEngine::data(const QModelIndex &index, int role) const |
352 | { |
353 | switch (role) { |
354 | case RoleTotalTime: |
355 | @@ -63,7 +86,7 @@ |
356 | return QVariant(); |
357 | } |
358 | |
359 | -QHash<int, QByteArray> LapHistory::roleNames() const |
360 | +QHash<int, QByteArray> StopwatchEngine::roleNames() const |
361 | { |
362 | QHash< int, QByteArray> roles; |
363 | roles.insert(RoleTotalTime, "totaltime"); |
364 | @@ -71,16 +94,17 @@ |
365 | return roles; |
366 | } |
367 | |
368 | -void LapHistory::addLap(int timeDiff) |
369 | +void StopwatchEngine::addLap() |
370 | { |
371 | QVariantList laps = m_settings.value("Stopwatch/laps").toList(); |
372 | beginInsertRows(QModelIndex(), 0, 0); |
373 | + int timeDiff = m_totalTimeInmsecs; |
374 | laps.prepend(timeDiff); |
375 | m_settings.setValue("Stopwatch/laps", laps); |
376 | endInsertRows(); |
377 | } |
378 | |
379 | -void LapHistory::removeLap(int lapIndex) |
380 | +void StopwatchEngine::removeLap(int lapIndex) |
381 | { |
382 | QVariantList laps = m_settings.value("Stopwatch/laps").toList(); |
383 | beginRemoveRows(QModelIndex(), lapIndex, lapIndex); |
384 | @@ -89,9 +113,88 @@ |
385 | endRemoveRows(); |
386 | } |
387 | |
388 | -void LapHistory::clear() |
389 | -{ |
390 | +void StopwatchEngine::setStopwatchStartDateTime() |
391 | +{ |
392 | + m_stopwatchStartDateTime = QDateTime::currentDateTimeUtc(); |
393 | + m_settings.setValue("Stopwatch/startDateTime", m_stopwatchStartDateTime); |
394 | +} |
395 | + |
396 | +void StopwatchEngine::startStopwatch() |
397 | +{ |
398 | + setStopwatchStartDateTime(); |
399 | + setRunning(true); |
400 | + m_timer.start(); |
401 | +} |
402 | + |
403 | +void StopwatchEngine::updateStopwatch() |
404 | +{ |
405 | + setTotalTimeOfStopwatch(m_previousTimeInmsecs + m_stopwatchStartDateTime.msecsTo(QDateTime::currentDateTimeUtc())); |
406 | +} |
407 | + |
408 | +void StopwatchEngine::pauseStopwatch() |
409 | +{ |
410 | + setPreviousTimeOfStopwatch(m_previousTimeInmsecs + m_stopwatchStartDateTime.msecsTo(QDateTime::currentDateTimeUtc())); |
411 | + setTotalTimeOfStopwatch(m_previousTimeInmsecs); |
412 | + setRunning(false); |
413 | + m_timer.stop(); |
414 | +} |
415 | + |
416 | +void StopwatchEngine::clearStopwatch() |
417 | +{ |
418 | + setPreviousTimeOfStopwatch(0); |
419 | + setTotalTimeOfStopwatch(0); |
420 | + |
421 | beginResetModel(); |
422 | m_settings.setValue("Stopwatch/laps", QVariantList()); |
423 | endResetModel(); |
424 | } |
425 | + |
426 | +bool StopwatchEngine::running() const |
427 | +{ |
428 | + return m_isStopwatchRunning; |
429 | +} |
430 | + |
431 | +int StopwatchEngine::previousTimeOfStopwatch() const |
432 | +{ |
433 | + return m_previousTimeInmsecs; |
434 | +} |
435 | + |
436 | +int StopwatchEngine::totalTimeOfStopwatch() const |
437 | +{ |
438 | + return m_totalTimeInmsecs; |
439 | +} |
440 | + |
441 | +void StopwatchEngine::setRunning(bool value) |
442 | +{ |
443 | + if(value == m_isStopwatchRunning) |
444 | + { |
445 | + return; |
446 | + } |
447 | + |
448 | + m_isStopwatchRunning = value; |
449 | + m_settings.setValue("Stopwatch/isStopwatchRunning", m_isStopwatchRunning); |
450 | + emit runningChanged(); |
451 | +} |
452 | + |
453 | +void StopwatchEngine::setPreviousTimeOfStopwatch(int value) |
454 | +{ |
455 | + if(value == m_previousTimeInmsecs) |
456 | + { |
457 | + return; |
458 | + } |
459 | + |
460 | + m_previousTimeInmsecs = value; |
461 | + m_settings.setValue("Stopwatch/previousTimeInmsecs", m_previousTimeInmsecs); |
462 | + emit previousTimeOfStopwatchChanged(); |
463 | +} |
464 | + |
465 | +void StopwatchEngine::setTotalTimeOfStopwatch(int value) |
466 | +{ |
467 | + if(value == m_totalTimeInmsecs) |
468 | + { |
469 | + return; |
470 | + } |
471 | + |
472 | + m_totalTimeInmsecs = value; |
473 | + emit totalTimeOfStopwatchChanged(); |
474 | +} |
475 | |
476 | === renamed file 'backend/modules/Stopwatch/history.h' => 'backend/modules/Stopwatch/engine.h' |
477 | --- backend/modules/Stopwatch/history.h 2015-08-24 23:37:28 +0000 |
478 | +++ backend/modules/Stopwatch/engine.h 2015-09-12 11:55:48 +0000 |
479 | @@ -16,23 +16,47 @@ |
480 | * * |
481 | ****************************************************************************/ |
482 | |
483 | -#ifndef HISTORY_H |
484 | -#define HISTORY_H |
485 | +#ifndef ENGINE_H |
486 | +#define ENGINE_H |
487 | |
488 | #include <QAbstractListModel> |
489 | +#include <QTimer> |
490 | #include <QSettings> |
491 | +#include <QDateTime> |
492 | |
493 | -class LapHistory : public QAbstractListModel |
494 | +class StopwatchEngine : public QAbstractListModel |
495 | { |
496 | Q_OBJECT |
497 | |
498 | + Q_PROPERTY( bool running |
499 | + READ running |
500 | + NOTIFY runningChanged) |
501 | + |
502 | + Q_PROPERTY( int totalTimeOfStopwatch |
503 | + READ totalTimeOfStopwatch |
504 | + NOTIFY totalTimeOfStopwatchChanged) |
505 | + |
506 | + Q_PROPERTY( int previousTimeOfStopwatch |
507 | + READ previousTimeOfStopwatch |
508 | + NOTIFY previousTimeOfStopwatchChanged) |
509 | + |
510 | +signals: |
511 | + // Signal to notify the running status change to QML |
512 | + void runningChanged(); |
513 | + |
514 | + // Signal to notify the total time change to QML |
515 | + void totalTimeOfStopwatchChanged(); |
516 | + |
517 | + // Signal to notify the total time change to QML |
518 | + void previousTimeOfStopwatchChanged(); |
519 | + |
520 | public: |
521 | enum Role { |
522 | RoleTotalTime, |
523 | RoleDiffToPrevious |
524 | }; |
525 | |
526 | - explicit LapHistory(QObject *parent = 0); |
527 | + explicit StopwatchEngine(QObject *parent = 0); |
528 | |
529 | /* |
530 | Let's override the pure virtual functions (the ones marked as |
531 | @@ -47,18 +71,36 @@ |
532 | */ |
533 | QHash<int, QByteArray> roleNames() const override; |
534 | |
535 | -public slots: |
536 | - // Function to add a stopwatch lap |
537 | - void addLap(int timeDiff); |
538 | - |
539 | - // Function to remove a stopwatch lap |
540 | - void removeLap(int lapIndex); |
541 | - |
542 | - // Function to clear all stopwatch laps |
543 | - void clear(); |
544 | + // Getter functions for the properties |
545 | + bool running() const; |
546 | + int totalTimeOfStopwatch() const; |
547 | + int previousTimeOfStopwatch() const; |
548 | + |
549 | + Q_INVOKABLE void addLap(); |
550 | + Q_INVOKABLE void removeLap(int lapIndex); |
551 | + |
552 | + Q_INVOKABLE void startStopwatch(); |
553 | + Q_INVOKABLE void pauseStopwatch(); |
554 | + Q_INVOKABLE void clearStopwatch(); |
555 | + |
556 | +private slots: |
557 | + void updateStopwatch(); |
558 | |
559 | private: |
560 | + void setStopwatchStartDateTime(); |
561 | + |
562 | + void setRunning(bool value); |
563 | + void setTotalTimeOfStopwatch(int value); |
564 | + void setPreviousTimeOfStopwatch(int value); |
565 | + |
566 | QSettings m_settings; |
567 | + |
568 | + QDateTime m_stopwatchStartDateTime; |
569 | + QTimer m_timer; |
570 | + |
571 | + bool m_isStopwatchRunning; |
572 | + int m_previousTimeInmsecs; |
573 | + int m_totalTimeInmsecs; |
574 | }; |
575 | |
576 | -#endif // HISTORY_H |
577 | +#endif // ENGINE_H |
578 | |
579 | === modified file 'debian/changelog' |
580 | --- debian/changelog 2015-09-11 14:01:47 +0000 |
581 | +++ debian/changelog 2015-09-12 11:55:48 +0000 |
582 | @@ -12,6 +12,7 @@ |
583 | * Fix wrong time after changing timezone, when stopwatch is running (LP: #1491024) |
584 | * Reduce size of images (with tinypng.com) to decrease click image size (LP: #1492057) |
585 | * Fix Czech Republic country name (LP: #1494004) |
586 | + * Fix stopwatch issue appering during changing timezone during runtime (LP: #1493358) |
587 | |
588 | -- Bartosz Kosiorek <gang65@poczta.onet.pl> Wed, 02 Sep 2015 15:16:29 +0200 |
589 | |
590 | |
591 | === added file 'tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/stopwatch.pxu' |
592 | --- tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/stopwatch.pxu 1970-01-01 00:00:00 +0000 |
593 | +++ tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/stopwatch.pxu 2015-09-12 11:55:48 +0000 |
594 | @@ -0,0 +1,21 @@ |
595 | +id: stopwatch/language-change |
596 | +plugin: manual |
597 | +_summary: Test to check if stopwatch is working properly after timezone change, without closing Stopwatch |
598 | +estimated_duration: 600 |
599 | +_description: |
600 | + Test to check if stopwatch is working properly after timezone change, without closing Stopwatch |
601 | + 1. Launch the clock app. |
602 | + Clock app opens showing the current local time. |
603 | + 2. Press the Stopwatch icon on the top of the screen. |
604 | + Stopwatch is visible and is not running. The Stopwatch main display shows 00:00:00 000. |
605 | + 3. Press the Start button. |
606 | + The main display starts counting time. The Start button disappears and the buttons Stop and Lap appear. |
607 | + 4. Press the Lap button. |
608 | + New lap row appears together with the lap header. |
609 | + 5. Switch to the system settings app. Navigate to Date & Time. |
610 | + The field with current timezone should be visible. Remember current timezone setting. |
611 | + 6. Press the current timezone field and change system timezone to something different. |
612 | + The timezone field now shows the newly selected timezone. |
613 | + 7. Switch to clock app. |
614 | + The stopwatch hours has not changed. The stopwatch should have incremented by just a few seconds (at most a minute). |
615 | + |
616 | |
617 | === added file 'tests/manual/2014.com.ubuntu.clock:clock-tests/whitelists/clock-app-stopwatch.whitelist' |
618 | --- tests/manual/2014.com.ubuntu.clock:clock-tests/whitelists/clock-app-stopwatch.whitelist 1970-01-01 00:00:00 +0000 |
619 | +++ tests/manual/2014.com.ubuntu.clock:clock-tests/whitelists/clock-app-stopwatch.whitelist 2015-09-12 11:55:48 +0000 |
620 | @@ -0,0 +1,1 @@ |
621 | +stopwatch/.* |
PASSED: Continuous integration, rev:373 91.189. 93.70:8080/ job/ubuntu- clock-app- ci/828/ 91.189. 93.70:8080/ job/ubuntu- clock-app- vivid-amd64- ci/173
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- clock-app- ci/828/ rebuild
http://