Skip to content

Commit

Permalink
Merge pull request #409 from Danfro/sleep_labels
Browse files Browse the repository at this point in the history
add total sleep time and reformat sleep times
  • Loading branch information
piggz authored Oct 14, 2024
2 parents faee8ea + 986471e commit d10acd2
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions ui/qml/pages/SleepPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -79,6 +88,14 @@ PagePL {
graphSleepSummary.updateGraph(day);
}

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: {
pushAttached(Qt.resolvedUrl("HeartratePage.qml"))
}
Expand Down

0 comments on commit d10acd2

Please sign in to comment.