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