diff options
Diffstat (limited to 'desktop/modules/bluetooth/BluetoothRow.qml')
| -rw-r--r-- | desktop/modules/bluetooth/BluetoothRow.qml | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/desktop/modules/bluetooth/BluetoothRow.qml b/desktop/modules/bluetooth/BluetoothRow.qml index a7aecd0..297dc02 100644 --- a/desktop/modules/bluetooth/BluetoothRow.qml +++ b/desktop/modules/bluetooth/BluetoothRow.qml @@ -20,6 +20,14 @@ Rectangle { required property var bt required property var device + // BlueZ's org.bluez.Battery1 pushes a live value when the device reports + // one. A gamepad does not, so fall back to the module's power_supply map. + // Null means neither source knows, and the field stays hidden. + readonly property var battPct: { + if (row.device.batteryAvailable) return Math.round((row.device.battery ?? 0) * 100); + return row.bt.batteryFor(row.device.address); + } + implicitHeight: col.implicitHeight + 16 radius: 8 color: device.connected ? Qt.alpha(Theme.accent, 0.10) : Qt.alpha(Theme.surface, 0.35) @@ -49,8 +57,8 @@ Rectangle { Text { anchors.verticalCenter: parent.verticalCenter - visible: row.device.batteryAvailable ?? false - text: Math.round((row.device.battery ?? 0) * 100) + "%" + visible: row.battPct !== null + text: row.battPct + "%" font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 } color: Theme.overlay } |
