battery-wid
This commit is contained in:
@@ -10,4 +10,14 @@ Singleton {
|
|||||||
readonly property list<UPowerDevice> devices: UPower.devices.values
|
readonly property list<UPowerDevice> devices: UPower.devices.values
|
||||||
readonly property bool onBattery: UPower.onBattery
|
readonly property bool onBattery: UPower.onBattery
|
||||||
readonly property UPowerDevice displayDevice: UPower.displayDevice
|
readonly property UPowerDevice displayDevice: UPower.displayDevice
|
||||||
|
|
||||||
|
property UPowerDevice batteryDevice
|
||||||
|
|
||||||
|
function findDevice(): void {
|
||||||
|
for ( let i = 0; i < root.devices.length; i++ ) {
|
||||||
|
if ( root.devices[i].type === "Battery" ) {
|
||||||
|
root.batteryDevice = root.devices[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,16 +12,10 @@ Item {
|
|||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
function findDevice() {
|
Component.onCompleted: UPower.findDevice()
|
||||||
for ( let i = 0; i < UPower.devices.count; i++ ) {
|
|
||||||
if ( UPower.devices[i].isLaptopBattery ) {
|
|
||||||
return UPower.devices[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomText {
|
CustomText {
|
||||||
text: findDevice().percentage
|
text: UPower.batteryDevice.percentage + "%"
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user