From 2cf16c98c5c903f796bd6679ce5ebf1ff042fac3 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 1 Aug 2025 00:16:54 +0545 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(controlcenter):=20replace=20SV?= =?UTF-8?q?G=20icons=20with=20symbolic=20icons=20for=20Bluetooth=20and=20W?= =?UTF-8?q?i-Fi,=20improving=20theming=20and=20state=20indication?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/controlcenter/controlcenter.xml | 1 - modules/controlcenter/main.py | 91 +++++++++++++++---------- styles/controlcenter.css | 44 +++++++++++- 3 files changed, 95 insertions(+), 41 deletions(-) diff --git a/modules/controlcenter/controlcenter.xml b/modules/controlcenter/controlcenter.xml index 5a82fe4..5cb49af 100644 --- a/modules/controlcenter/controlcenter.xml +++ b/modules/controlcenter/controlcenter.xml @@ -7,7 +7,6 @@ self.focus_widget - diff --git a/modules/controlcenter/main.py b/modules/controlcenter/main.py index 127479f..9361ed9 100644 --- a/modules/controlcenter/main.py +++ b/modules/controlcenter/main.py @@ -8,6 +8,7 @@ from fabric.widgets.centerbox import CenterBox from fabric.widgets.label import Label from fabric.widgets.scale import Scale from fabric.widgets.svg import Svg +from fabric.widgets.image import Image from gi.repository import Gdk, GLib from modules.controlcenter.bluetooth import BluetoothConnections @@ -51,8 +52,17 @@ class ModusControlCenter(Window): audio_service.connect("changed", self.volume_changed) self.wlan_label = Label(wlan, name="wifi-widget-label", h_align="start") + if bluetooth != "disabled": + if bluetooth.startswith("connected:"): + parts = bluetooth.split(":") + bluetooth_display = parts[1] if len(parts) >= 2 else "Connected" + else: + bluetooth_display = "On" + else: + bluetooth_display = "Off" + self.bluetooth_label = Label( - bluetooth, name="bluetooth-widget-label", h_align="start" + bluetooth_display, name="bluetooth-widget-label", h_align="start" ) self.volume_scale = Scale( value=volume, @@ -103,24 +113,17 @@ class ModusControlCenter(Window): self.has_bluetooth_open = False self.has_wifi_open = False - self.bluetooth_svg = Svg( - svg_file=get_relative_path( - "../../config/assets/icons/bluetooth.svg" - if bluetooth == "On" - else "../../config/assets/icons/bluetooth-off.svg" - ), - style_classes="icon", + self.bluetooth_svg = Image( + name="bluetooth-icon", + icon_name="bluetooth-symbolic", + size=24, + style_classes="connected" if bluetooth != "disabled" else "", ) - self.wifi_svg = ( - Svg( - svg_file=get_relative_path("../../config/assets/icons/wifi.svg"), - style_classes="icon", - ) - if wlan != "No Connection" - else Svg( - svg_file=get_relative_path("../../config/assets/icons/wifi-off.svg"), - style_classes="icon", - ) + self.wifi_svg = Image( + name="wifi-icon", + icon_name="network-wireless-symbolic", + size=24, + style_classes="connected" if wlan != "No Connection" else "", ) self.bluetooth_widget = Button( @@ -169,7 +172,7 @@ class ModusControlCenter(Window): self.focus_icon = Svg( svg_file=get_relative_path("../../config/assets/icons/dnd-off.svg"), - style_classes="icon", + size=24, ) self.focus_widget = Button( @@ -249,9 +252,9 @@ class ModusControlCenter(Window): modus_service.dont_disturb = self.focus_mode self.focus_icon.set_from_file( get_relative_path( - "../../config/assets/icons/dnd.svg" + "config/assets/icons/dnd.svg" if self.focus_mode - else "../../config/assets/icons/dnd-off.svg" + else "config/assets/icons/dnd-off.svg" ) ) @@ -342,24 +345,38 @@ class ModusControlCenter(Window): ) def wlan_changed(self, _, wlan): - self.wifi_svg.set_from_file( - get_relative_path( - "../../config/assets/icons/wifi.svg" - if wlan != "No Connection" - else "../../config/assets/icons/wifi-off.svg" - ) - ) - GLib.idle_add(lambda: self.wlan_label.set_property("label", wlan)) + if wlan != "No Connection": + self.wifi_svg.set_property("style-classes", "connected") + if wlan.startswith("connected:"): + parts = wlan.split(":") + if len(parts) >= 2: + wifi_name = parts[1] + GLib.idle_add(lambda: self.wlan_label.set_property("label", wifi_name)) + else: + GLib.idle_add(lambda: self.wlan_label.set_property("label", "Connected")) + else: + GLib.idle_add(lambda: self.wlan_label.set_property("label", wlan)) + else: + self.wifi_svg.set_property("style-classes", "") + GLib.idle_add(lambda: self.wlan_label.set_property("label", wlan)) def bluetooth_changed(self, _, bluetooth): - self.bluetooth_svg.set_from_file( - get_relative_path( - "../../config/assets/icons/bluetooth.svg" - if bluetooth == "On" - else "../../config/assets/icons/bluetooth-off.svg" - ) - ) - GLib.idle_add(lambda: self.bluetooth_label.set_property("label", bluetooth)) + if bluetooth != "disabled": + self.bluetooth_svg.set_property("style-classes", "connected") + if bluetooth.startswith("connected:"): + parts = bluetooth.split(":") + if len(parts) >= 2: + device_name = parts[1] + GLib.idle_add(lambda: self.bluetooth_label.set_property("label", device_name)) + else: + GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "Connected")) + elif bluetooth == "enabled": + GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "On")) + else: + GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "On")) + else: + self.bluetooth_svg.set_property("style-classes", "") + GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "Off")) def audio_changed(self, *_): pass diff --git a/styles/controlcenter.css b/styles/controlcenter.css index cc91a21..b019a7f 100644 --- a/styles/controlcenter.css +++ b/styles/controlcenter.css @@ -19,10 +19,26 @@ padding: 10px; } -.icon { +#focus-widget { + padding: 10px; + min-width: 100px; +} + +#bluetooth-icon, +#wifi-icon { + background-color: #666666; + padding: 8px; + min-width: 24px; + min-height: 24px; + border-radius: 50%; + color: #ffffff; + opacity: 0.6; +} + +#bluetooth-icon.connected, +#wifi-icon.connected { background-color: #2369ff; - font-size: 15px; - padding: 20px 20px; + opacity: 1; } #bluetooth-widget-label, @@ -65,6 +81,28 @@ background-color: #2369ff; } +#device-icon.connecting { + background-color: #ff9500; + animation: pulse 1s infinite; +} + +#device-icon.disconnecting { + background-color: #ff3b30; + animation: pulse 1s infinite; +} + +@keyframes pulse { + 0% { + opacity: 1; + } + 50% { + opacity: 0.6; + } + 100% { + opacity: 1; + } +} + #toggle-button { min-width: 40px; min-height: 20px;