From 559187cff05e78f4f40be0065c18165ed69e53eb Mon Sep 17 00:00:00 2001 From: Danfro Date: Thu, 10 Oct 2024 12:41:20 +0200 Subject: [PATCH 1/2] add total sleep label, name light sleep text with "light" and format in hrs minutes locale format --- ui/qml/pages/SleepPage.qml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ui/qml/pages/SleepPage.qml b/ui/qml/pages/SleepPage.qml index 0f95e890..b2f63764 100644 --- a/ui/qml/pages/SleepPage.qml +++ b/ui/qml/pages/SleepPage.qml @@ -19,14 +19,23 @@ PagePL { width: parent.width anchors.top: parent.top anchors.margins: styler.themePaddingMedium - spacing: styler.themePaddingLarge + spacing: styler.themePaddingMedium LabelPL { id: lblSleepLastnight - font.pixelSize: styler.themeFontSizeExtraLarge * 3 + font.pixelSize: styler.themeFontSizeExtraLarge * 2 anchors.horizontalCenter: parent.horizontalCenter width: parent.width - text: qsTr("%1 hrs").arg(parseFloat(Math.round(graphSleepSummary.lastY * 100) / 100).toFixed(2)) + text: qsTr("Total %1").arg(decimalToHourMin(graphSleepSummary.lastY + graphSleepSummary.lastZ)) + horizontalAlignment: Text.AlignHCenter + } + + LabelPL { + id: lblLightSleepLastnight + font.pixelSize: styler.themeFontSizeExtraLarge + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width + text: qsTr("Light %1").arg(decimalToHourMin(graphSleepSummary.lastY)) horizontalAlignment: Text.AlignHCenter } @@ -35,7 +44,7 @@ PagePL { font.pixelSize:styler.themeFontSizeExtraLarge anchors.horizontalCenter: parent.horizontalCenter width: parent.width - text: qsTr("Deep %1 hrs").arg(parseFloat(Math.round(graphSleepSummary.lastZ * 100) / 100).toFixed(2)) + text: qsTr("Deep %1").arg(decimalToHourMin(graphSleepSummary.lastZ)) horizontalAlignment: Text.AlignHCenter } @@ -79,6 +88,12 @@ PagePL { graphSleepSummary.updateGraph(day); } + function decimalToHourMin(decHours) { + var timeDate = new Date(0,0); + timeDate.setMinutes(decHours * 60); + return timeDate.toLocaleTimeString([], {timeStyle: 'short'}); + } + onPageStatusActive: { pushAttached(Qt.resolvedUrl("HeartratePage.qml")) } From 986471ec7e299e68b725b48b51eecd0da9686ae2 Mon Sep 17 00:00:00 2001 From: Danfro Date: Mon, 14 Oct 2024 13:05:02 +0200 Subject: [PATCH 2/2] fix time to omit am/pm notation --- ui/qml/pages/SleepPage.qml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/qml/pages/SleepPage.qml b/ui/qml/pages/SleepPage.qml index b2f63764..9a26af49 100644 --- a/ui/qml/pages/SleepPage.qml +++ b/ui/qml/pages/SleepPage.qml @@ -88,10 +88,12 @@ PagePL { graphSleepSummary.updateGraph(day); } - function decimalToHourMin(decHours) { - var timeDate = new Date(0,0); - timeDate.setMinutes(decHours * 60); - return timeDate.toLocaleTimeString([], {timeStyle: 'short'}); + function decimalToHourMin(decTime) { + var totalMinutes = Math.round(decTime * 60); + var hours = Math.floor(totalMinutes / 60); + var minutes = (totalMinutes % 60).toString().padStart(2, '0'); + + return hours + ":" + minutes; } onPageStatusActive: {