diff options
Diffstat (limited to 'qmlplugin')
-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. |