[Linux] Add battery indicator (#89)

* [Linux] Expose battery info to QML

* [Linux] Add battery indicator

* [Linux] Dynamically hide case battery level if we have no data for it

* Reduce animation speed
This commit is contained in:
Tim Gromeyer
2025-03-30 12:00:13 +02:00
committed by GitHub
parent 543362da69
commit 4e72f6573e
5 changed files with 254 additions and 21 deletions

View File

@@ -1,5 +1,6 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import me.kavishdevar.Battery 1.0
ApplicationWindow {
visible: true
@@ -11,10 +12,61 @@ ApplicationWindow {
spacing: 20
padding: 20
Text {
id: batteryStatus
text: "Battery Status: " + airPodsTrayApp.batteryStatus
color: "#ffffff"
// Battery Indicator
Row {
// center the content
anchors.horizontalCenter: parent.horizontalCenter
spacing: 15
Column {
spacing: 5
Text {
text: "Left"
color: "#ffffff"
font.pixelSize: 12
}
BatteryIndicator {
batteryLevel: airPodsTrayApp.battery.leftPodLevel
isCharging: airPodsTrayApp.battery.leftPodCharging
darkMode: true
}
}
Column {
spacing: 5
Text {
text: "Right"
color: "#ffffff"
font.pixelSize: 12
}
BatteryIndicator {
batteryLevel: airPodsTrayApp.battery.rightPodLevel
isCharging: airPodsTrayApp.battery.rightPodCharging
darkMode: true
}
}
Column {
spacing: 5
// hide the case status if battery level is 0 and no pod is in case
visible: airPodsTrayApp.battery.caseLevel > 0 || airPodsTrayApp.oneOrMorePodsInCase
Text {
text: "Case"
color: "#ffffff"
font.pixelSize: 12
}
BatteryIndicator {
batteryLevel: airPodsTrayApp.battery.caseLevel
isCharging: airPodsTrayApp.battery.caseCharging
darkMode: true
}
}
}
Text {
@@ -91,4 +143,4 @@ ApplicationWindow {
}
}
}
}
}