ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #04818
[Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
Bartosz Kosiorek has proposed merging lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app.
Commit message:
Fix stopwatch issue appering during changing timezone during runtime (LP: #1493358)
Requested reviews:
Ubuntu Clock Developers (ubuntu-clock-dev)
Related bugs:
Bug #1493358 in Ubuntu Clock App: "Stopwatch is not working correctly after change timezone during runtime"
https://bugs.launchpad.net/ubuntu-clock-app/+bug/1493358
For more details, see:
https://code.launchpad.net/~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix/+merge/270396
Fix stopwatch issue appering during changing timezone during runtime (LP: #1493358)
--
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app.
=== modified file 'app/MainPage.qml'
--- app/MainPage.qml 2015-08-20 16:03:35 +0000
+++ app/MainPage.qml 2015-09-08 12:52:12 +0000
@@ -63,9 +63,8 @@
Settings {
id: stopwatchState
category: "Stopwatch"
- property alias startTime: stopwatchPage.startTime
property alias running: stopwatchPage.running
- property alias oldDiff: stopwatchPage.oldDiff
+ property alias oldDiff: stopwatchPage.previousLapsTime
}
VisualItemModel {
=== modified file 'app/stopwatch/StopwatchPage.qml'
--- app/stopwatch/StopwatchPage.qml 2015-09-02 13:15:50 +0000
+++ app/stopwatch/StopwatchPage.qml 2015-09-08 12:52:12 +0000
@@ -24,51 +24,43 @@
id: _stopwatchPage
objectName: "stopwatchPage"
- property date startTime: getUTCDate()
- property date snapshot: startTime
+
+ StopwatchFormatTime {
+ id: stopwatchFormatTime
+ }
+
+ //property date startTime: getUTCDate()
+ //property date snapshot: startTime
property bool running: false
- property int timeDiff: snapshot - startTime
- property int oldDiff: 0
+ property int lapTime: 0
+ property int previousLapsTime: 0
- property int totalTimeDiff: timeDiff + oldDiff
+ property int totalTime: lapTime + previousLapsTime
Component.onCompleted: {
console.log("[LOG]: Stopwatch Page Loaded")
}
- function getUTCDate() {
- var localDate = new Date()
- return new Date(localDate.getUTCFullYear(),
- localDate.getUTCMonth(),
- localDate.getUTCDate(),
- localDate.getUTCHours(),
- localDate.getUTCMinutes(),
- localDate.getUTCSeconds(),
- localDate.getUTCMilliseconds())
- }
-
function start() {
- startTime = getUTCDate()
- snapshot = startTime
+ if (lapTime === 0) {
+ lapHistory.startStopwatch();
+ }
running = true
}
function stop() {
- oldDiff += timeDiff
- startTime = getUTCDate()
- snapshot = startTime
running = false
}
function update() {
- snapshot = getUTCDate()
+ lapTime = lapHistory.updateStopwatch();
}
function clear() {
- oldDiff = 0
- startTime = getUTCDate()
- snapshot = startTime
+ running = false
+ lapTime = 0
+ previousLapsTime = 0
lapHistory.clear()
}
@@ -86,7 +78,7 @@
id: stopwatch
objectName: "stopwatch"
- milliseconds: _stopwatchPage.totalTimeDiff
+ milliseconds: _stopwatchPage.totalTime
anchors {
top: parent.top
@@ -109,9 +101,9 @@
Button {
id: stopButton
- width: oldDiff !== 0 || running ? (parent.width - parent.spacing) / 2 : parent.width
+ width: previousLapsTime !== 0 || running ? (parent.width - parent.spacing) / 2 : parent.width
color: !_stopwatchPage.running ? UbuntuColors.green : UbuntuColors.red
- text: _stopwatchPage.running ? i18n.tr("Stop") : (oldDiff === 0 ? i18n.tr("Start") : i18n.tr("Resume"))
+ text: _stopwatchPage.running ? i18n.tr("Stop") : (previousLapsTime === 0 ? i18n.tr("Start") : i18n.tr("Resume"))
onClicked: {
if (_stopwatchPage.running) {
_stopwatchPage.stop()
@@ -129,13 +121,13 @@
Button {
id: lapButton
text: _stopwatchPage.running ? i18n.tr("Lap") : i18n.tr("Clear")
- width: oldDiff !== 0 || running ? (parent.width - parent.spacing) / 2 : 0
+ width: previousLapsTime !== 0 || running ? (parent.width - parent.spacing) / 2 : 0
strokeColor: UbuntuColors.lightGrey
- visible: oldDiff !== 0 || running
+ visible: previousLapsTime !== 0 || running
onClicked: {
if (_stopwatchPage.running) {
_stopwatchPage.update()
- lapHistory.addLap(_stopwatchPage.totalTimeDiff)
+ lapHistory.addLap(_stopwatchPage.totalTime)
} else {
_stopwatchPage.clear()
}
@@ -162,7 +154,7 @@
Loader {
id: lapListViewLoader
anchors.fill: parent
- sourceComponent: !_stopwatchPage.running && _stopwatchPage.totalTimeDiff == 0 ? undefined : lapListViewComponent
+ sourceComponent: !_stopwatchPage.running && _stopwatchPage.totalTime == 0 ? undefined : lapListViewComponent
}
}
=== modified file 'backend/modules/Stopwatch/history.cpp'
--- backend/modules/Stopwatch/history.cpp 2015-08-24 23:37:28 +0000
+++ backend/modules/Stopwatch/history.cpp 2015-09-08 12:52:12 +0000
@@ -31,6 +31,15 @@
m_settings(QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).first() + "/com.ubuntu.clock/com.ubuntu.clock.conf", QSettings::IniFormat)
{
qDebug() << "[LOG] Loading laps from " << m_settings.fileName();
+ QDateTime startTime = m_settings.value("Stopwatch/startDateTime").toDateTime();
+ if(startTime.isValid())
+ {
+ m_stopwatchStartDateTime = startTime;
+ }
+ else
+ {
+ startStopwatch();
+ }
}
int LapHistory::rowCount(const QModelIndex &parent) const
@@ -95,3 +104,15 @@
m_settings.setValue("Stopwatch/laps", QVariantList());
endResetModel();
}
+
+void LapHistory::startStopwatch()
+{
+ m_stopwatchStartDateTime = QDateTime::currentDateTimeUtc();
+ m_settings.setValue("Stopwatch/startDateTime", m_stopwatchStartDateTime);
+}
+
+int LapHistory::updateStopwatch()
+{
+ return m_stopwatchStartDateTime.msecsTo(QDateTime::currentDateTimeUtc());
+}
+
=== modified file 'backend/modules/Stopwatch/history.h'
--- backend/modules/Stopwatch/history.h 2015-08-24 23:37:28 +0000
+++ backend/modules/Stopwatch/history.h 2015-09-08 12:52:12 +0000
@@ -21,6 +21,7 @@
#include <QAbstractListModel>
#include <QSettings>
+#include <QDateTime>
class LapHistory : public QAbstractListModel
{
@@ -48,6 +49,7 @@
QHash<int, QByteArray> roleNames() const override;
public slots:
+
// Function to add a stopwatch lap
void addLap(int timeDiff);
@@ -57,8 +59,12 @@
// Function to clear all stopwatch laps
void clear();
+ void startStopwatch();
+ int updateStopwatch();
+
private:
QSettings m_settings;
+ QDateTime m_stopwatchStartDateTime;
};
#endif // HISTORY_H
Follow ups
-
[Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: noreply, 2015-09-14
-
[Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Alan Pope , 2015-09-14
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Bartosz Kosiorek, 2015-09-12
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Nekhelesh Ramananthan, 2015-09-12
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-12
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-12
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Nekhelesh Ramananthan, 2015-09-11
-
[Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Nekhelesh Ramananthan, 2015-09-11
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-11
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-11
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Nekhelesh Ramananthan, 2015-09-11
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Nekhelesh Ramananthan, 2015-09-11
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-11
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-11
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-10
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-10
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-10
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-09
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-09
-
[Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Bartosz Kosiorek, 2015-09-09
-
[Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Bartosz Kosiorek, 2015-09-09
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Bartosz Kosiorek, 2015-09-09
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Nekhelesh Ramananthan, 2015-09-09
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Victor Thompson, 2015-09-09
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Nekhelesh Ramananthan, 2015-09-08
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-08
-
Re: [Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-stopwatch-runtime-timezone-fix into lp:ubuntu-clock-app
From: Ubuntu Phone Apps Jenkins Bot, 2015-09-08