use material icons instead of svgs in battery widget
This commit is contained in:
parent
bb6377a86a
commit
d46d7ddc8a
@ -27,32 +27,37 @@ Rectangle {
|
|||||||
color: Colors.foreground
|
color: Colors.foreground
|
||||||
}
|
}
|
||||||
Icons {
|
Icons {
|
||||||
|
property bool isCharging: UPower.displayDevice.state === UPowerDeviceState.Charging
|
||||||
function getBatteryIcon() {
|
function getBatteryIcon() {
|
||||||
if (UPower.displayDevice.percentage < 12) {
|
if (isCharging) {
|
||||||
return "battery_android_0";
|
return "battery_android_frame_bolt";
|
||||||
}
|
}
|
||||||
if (UPower.displayDevice.percentage < 24) {
|
if (UPower.displayDevice.percentage < 0.12) {
|
||||||
return "battery_android_1";
|
return "battery_android_frame_0";
|
||||||
}
|
}
|
||||||
if (UPower.displayDevice.percentage < 36) {
|
if (UPower.displayDevice.percentage < 0.24) {
|
||||||
return "battery_android_2";
|
return "battery_android_frame_1";
|
||||||
}
|
}
|
||||||
if (UPower.displayDevice.percentage < 48) {
|
if (UPower.displayDevice.percentage < 0.36) {
|
||||||
return "battery_android_3";
|
return "battery_android_frame_2";
|
||||||
}
|
}
|
||||||
if (UPower.displayDevice.percentage < 60) {
|
if (UPower.displayDevice.percentage < 0.48) {
|
||||||
return "battery_android_4";
|
return "battery_android_frame_3";
|
||||||
}
|
}
|
||||||
if (UPower.displayDevice.percentage < 72) {
|
if (UPower.displayDevice.percentage < 0.60) {
|
||||||
return "battery_android_5";
|
return "battery_android_frame_4";
|
||||||
}
|
}
|
||||||
if (UPower.displayDevice.percentage < 84) {
|
if (UPower.displayDevice.percentage < 0.72) {
|
||||||
return "battery_android_6";
|
return "battery_android_frame_5";
|
||||||
}
|
}
|
||||||
if (UPower.displayDevice.percentage > 84) {
|
if (UPower.displayDevice.percentage < 0.84) {
|
||||||
|
return "battery_android_frame_6";
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.percentage > 0.84) {
|
||||||
return "battery_android_full";
|
return "battery_android_full";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
text: getBatteryIcon()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
@ -66,6 +71,7 @@ Rectangle {
|
|||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
color: Colors.foreground
|
color: Colors.foreground
|
||||||
text: isCharging ? timeToFull.toFixed(1) + "h to full" : timeToEmpty.toFixed(1) + "h left"
|
text: isCharging ? timeToFull.toFixed(1) + "h to full" : timeToEmpty.toFixed(1) + "h left"
|
||||||
|
onTextChanged: console.log(UPower.displayDevice.percentage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user