Make temperature formatting prettier
This commit is contained in:
parent
e939c2d9ce
commit
843cfa8db7
1 changed files with 8 additions and 1 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue