From 341523ca24fd3186893a3689c4a367d244d2bdb3 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 27 Jul 2025 05:30:38 +0545 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(dashboard):=20make=20Bluetooth?= =?UTF-8?q?=20and=20Network=20tiles=20toggleable=20via=20content=20area=20?= =?UTF-8?q?click?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dashboard/bluetooth.py | 16 ++++++++++++++++ modules/dashboard/network.py | 17 +++++++++++++++++ modules/dashboard/tile.py | 13 ++++++++++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/modules/dashboard/bluetooth.py b/modules/dashboard/bluetooth.py index f91e952..a5d3c69 100644 --- a/modules/dashboard/bluetooth.py +++ b/modules/dashboard/bluetooth.py @@ -104,6 +104,9 @@ class Bluetooth(Tile): # Initialize state self._update_tile_state() + # Override the type_box button behavior to toggle Bluetooth + self._setup_content_button() + def _update_tile_state(self): """Update tile visual state based on Bluetooth status.""" self.state = self.bluetooth_client.enabled @@ -119,6 +122,19 @@ class Bluetooth(Tile): # Update tile icon based on Bluetooth state self._update_tile_icon() + def _setup_content_button(self): + """Setup the content button to toggle Bluetooth instead of showing menu.""" + if hasattr(self, 'type_box'): + # Disconnect the existing click handler + self.type_box.disconnect_by_func(self.handle_click) + # Connect to Bluetooth toggle handler + self.type_box.connect("clicked", self._on_bluetooth_toggle) + + def _on_bluetooth_toggle(self, *_): + """Handle Bluetooth toggle when clicking on the main content area.""" + # Toggle Bluetooth state + self.bluetooth_client.enabled = not self.bluetooth_client.enabled + def _update_tile_icon(self): """Update the tile icon based on Bluetooth status and connected devices.""" if not self.bluetooth_client.enabled: diff --git a/modules/dashboard/network.py b/modules/dashboard/network.py index d05f68b..dea5967 100644 --- a/modules/dashboard/network.py +++ b/modules/dashboard/network.py @@ -106,6 +106,9 @@ class Network(Tile): if self.network_client.wifi_device: self._setup_wifi_device() + # Override the type_box button behavior to toggle WiFi + self._setup_content_button() + def handle_connection_change(self, *_): """Handle network connection state changes.""" self._update_tile_state() @@ -213,6 +216,20 @@ class Network(Tile): self._stop_animation() self.icon.set_markup(icons.wifi_off) + def _setup_content_button(self): + """Setup the content button to toggle WiFi instead of showing menu.""" + if hasattr(self, 'type_box'): + # Disconnect the existing click handler + self.type_box.disconnect_by_func(self.handle_click) + # Connect to WiFi toggle handler + self.type_box.connect("clicked", self._on_wifi_toggle) + + def _on_wifi_toggle(self, *_): + """Handle WiFi toggle when clicking on the main content area.""" + wifi = self.network_client.wifi_device + if wifi: + # Toggle WiFi state + wifi.wireless_enabled = not wifi.wireless_enabled def create_content(self): """Create the detailed network content for the dashboard.""" diff --git a/modules/dashboard/tile.py b/modules/dashboard/tile.py index 0d29ff8..31905f3 100644 --- a/modules/dashboard/tile.py +++ b/modules/dashboard/tile.py @@ -85,7 +85,7 @@ class Tile(Box): ) # Container for label and properties - self.type_box = Box( + content_box = Box( style_classes="tile-type", orientation="v", v_expand=True, @@ -94,6 +94,17 @@ class Tile(Box): children=[self.tile_label, self.props], ) + # Make the type_box clickable using a button + self.type_box = Button( + style_classes="tile-content-button", + h_expand=True, + v_expand=True, + child=content_box, + on_clicked=self.handle_click, + ) + # Add hover cursor to the content area + add_hover_cursor(self.type_box) + def _create_tile_layout(self, has_menu: bool): """Create the tile's layout structure.""" # Create menu button if needed