From 8267743fb522d20d3bae73b6daaa4683a5836b08 Mon Sep 17 00:00:00 2001 From: voidarc Date: Fri, 7 Aug 2026 17:14:38 +0100 Subject: [PATCH] bluetooth donesies i think --- Bar/Bluetooth.qml | 69 ++++++++++++++++++++++++++++++----- Services/BluetoothManager.qml | 15 +++++++- 2 files changed, 72 insertions(+), 12 deletions(-) diff --git a/Bar/Bluetooth.qml b/Bar/Bluetooth.qml index 42c45b4..b89d6a1 100644 --- a/Bar/Bluetooth.qml +++ b/Bar/Bluetooth.qml @@ -121,30 +121,79 @@ Container { rightMargin: devicePlaqueRoot.margin } - Item { - anchors.fill: parent + RowLayout { + id: deviceInfoRow + + property double margin: 7 + + spacing: margin * 2 + + anchors { + fill: parent + leftMargin: margin + } Rectangle { id: iconContainer - property double margin: 7 + property double boxRadius: 4 color: Colors.text - implicitWidth: deviceListRoot.plaqueHeight - (margin * 2) - radius: 4 + implicitHeight: deviceListRoot.plaqueHeight - (deviceInfoRow.margin * 2) + implicitWidth: deviceListRoot.plaqueHeight - (deviceInfoRow.margin * 2) + radius: boxRadius - anchors { - bottom: parent.bottom - left: parent.left - margins: iconContainer.margin - top: parent.top + Rectangle { + id: batteryIndicator + + color: Colors.green + implicitHeight: (deviceListRoot.plaqueHeight - (deviceInfoRow.margin * 2)) + * devicePlaqueRoot.deviceText["batteryRaw"] + radius: iconContainer.boxRadius + + anchors { + bottom: parent.bottom + left: parent.left + right: parent.right + } + } + + HoverHandler { + id: batteryHoverHandler + + onHoveredChanged: { + if (batteryHoverHandler.hovered == true) { + batteryText.text = devicePlaqueRoot.deviceText["battery"]; + } else { + batteryText.text = devicePlaqueRoot.deviceText["icon"]; + } + } } CenteredText { + id: batteryText + fontSize: 17 text: devicePlaqueRoot.deviceText["icon"] } } + + Column { + Layout.alignment: Qt.AlignVCenter + Layout.fillWidth: true + + StyledText { + color: Colors.text + fontSize: 14 + text: devicePlaqueRoot.deviceText["name"] + } + + StyledText { + color: Colors.subtext1 + fontSize: 10 + text: devicePlaqueRoot.deviceText["mac"] + } + } } } } diff --git a/Services/BluetoothManager.qml b/Services/BluetoothManager.qml index 6805eb4..f3c268c 100644 --- a/Services/BluetoothManager.qml +++ b/Services/BluetoothManager.qml @@ -33,12 +33,23 @@ Singleton { function getDeviceText(device) { let deviceName = device.deviceName; - let deviceIcon = getIcon(device.icon); + let deviceMac = device.address; + let hasBattery = device.batteryAvailable; + let deviceBattery = deviceIcon; + let deviceBatteryRaw = 0; + if (hasBattery) { + deviceBattery = device.battery * 100; + deviceBatteryRaw = device.battery; + } return { "icon": deviceIcon, - "name": deviceName + "name": deviceName, + "mac": deviceMac, + "hasBattery": hasBattery, + "battery": deviceBattery, + "batteryRaw": deviceBatteryRaw }; }