From dd05ef786c136a0a51a42efbd6d5454719dca8c5 Mon Sep 17 00:00:00 2001 From: tr1x_em Date: Mon, 11 Aug 2025 10:11:15 +0530 Subject: [PATCH] Buton Hover in Bluetooth --- modules/controlcenter/bluetooth.py | 27 +++++++++++++++++---------- styles/controlcenter.css | 7 ++++++- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/controlcenter/bluetooth.py b/modules/controlcenter/bluetooth.py index f4de9f0..9042a49 100644 --- a/modules/controlcenter/bluetooth.py +++ b/modules/controlcenter/bluetooth.py @@ -40,16 +40,15 @@ class BluetoothDeviceSlot(CenterBox): style_classes=" ".join(self.styles), ) - self.start_children = [ - Button( - on_clicked=lambda *_: self.toggle_connecting(), - child=Box( - orientation="h", - h_expand=True, - children=[self.dimage, Label(label=device.name)], - ), # type: ignore - ), - ] + self.device_button = Button( + on_clicked=lambda *_: self.toggle_connecting(), + child=Box( + orientation="h", + h_expand=True, + children=[self.dimage, Label(label=device.name)], + ), # type: ignore + ) + self.start_children = [self.device_button] # Add battery info if available if hasattr(device, "battery_percentage") and device.battery_percentage > 0: @@ -76,8 +75,16 @@ class BluetoothDeviceSlot(CenterBox): battery_box.children = [battery_icon, battery_label] self.end_children = [battery_box] + self.device_button.connect("enter-notify-event", self.on_button_enter) + self.device_button.connect("leave-notify-event", self.on_button_leave) self.device.emit("changed") # to update display status + def on_button_enter(self, widget, event): + self.add_style_class("button-hovered") + + def on_button_leave(self, widget, event): + self.remove_style_class("button-hovered") + def toggle_connecting(self): self.device.emit("changed") self.device.set_connecting(not self.device.connected) diff --git a/styles/controlcenter.css b/styles/controlcenter.css index 13c117f..ad1f6e8 100644 --- a/styles/controlcenter.css +++ b/styles/controlcenter.css @@ -893,7 +893,12 @@ #device-button { /* background-color: #000; */ + border-radius: 8px; } -#device-button.button:hover { +.device-slot:hover { + background-color: rgba(255, 255, 255, 0.05); +} + +.button-hovered { background-color: rgba(255, 255, 255, 0.1); }