Make temperature formatting prettier

This commit is contained in:
Matti Viljanen 2021-05-22 23:02:25 +03:00
parent e939c2d9ce
commit 843cfa8db7
No known key found for this signature in database
GPG key ID: CF32A1495158F888

View file

@ -180,7 +180,14 @@ Page {
}
MyDetailItem {
label: qsTr("Temperature:")
value: (Qt.locale().measurementSystem == Locale.ImperialUSSystem) ? Math.floor((battery.temperature / 10) * 1.8 + 32) + " F" : Math.floor(battery.temperature / 10) + " °C"
value: battery.temperature === 0x7FFFFFFF ? healthText["unknown"] : formatTemperature(battery.temperature)
function formatTemperature(temp) {
if(Qt.locale().measurementSystem === Locale.ImperialUSSystem) {
return Math.floor((battery.temperature / 10) * 1.8 + 32) + " °F"
}
return Math.floor(battery.temperature / 10) + " °C"
}
}
}
}