diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-06-29 01:09:51 +0100 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-06-29 01:09:51 +0100 |
commit | e1617431b4d1ef72c96d89d0754d42ed0e2cdb24 (patch) | |
tree | aff2bf08daacc359cf90a10a2fbbbf7ef2351eb5 | |
parent | 17af88e65e6cb0febcd2340771f52d128eae4fac (diff) |
Return log value if step counter value isn't sane
-rw-r--r-- | qmlplugin/stepsDataLoader.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/qmlplugin/stepsDataLoader.cpp b/qmlplugin/stepsDataLoader.cpp index bbc9b29..44b15bb 100644 --- a/qmlplugin/stepsDataLoader.cpp +++ b/qmlplugin/stepsDataLoader.cpp @@ -36,7 +36,11 @@ StepsDataLoader::StepsDataLoader() : QObject() int StepsDataLoader::getTodayTotal() { QSettings settings("asteroid", "sensorlogd"); - return m_stepcounterSensor->reading()->steps() - settings.value("StepCounterPrivate/stepsOffset", 0).toInt(); + int total = m_stepcounterSensor->reading()->steps() - settings.value("StepCounterPrivate/stepsOffset", 0).toInt(); + if (total < 0) { + return getTotalForDate(QDate::currentDate()); + } + return total; } int StepsDataLoader::getTotalForDate(QDate date) { // This is obvious garbage. This should really be abstracted and cached, so that every page doesn't have to reload the file from scratch. |