🐛 fix(panel): reduce icon size and hide battery indicator when no battery is detected

This commit is contained in:
sankalp committed 2025-08-10 22:31:33 +05:45
1 parent dca44f9f69
commit c33adef98b
1 file changed
+12 -9
+12 -9
View File
@@ -23,7 +23,7 @@ class BluetoothIndicator(Box):
self.bluetooth = BluetoothClient() self.bluetooth = BluetoothClient()
self.bt_icon = Svg( self.bt_icon = Svg(
name="bt-icon", name="bt-icon",
size=22, size=18,
svg_file=get_relative_path( svg_file=get_relative_path(
"../../../config/assets/icons/applets/bluetooth-clear.svg" "../../../config/assets/icons/applets/bluetooth-clear.svg"
), ),
@@ -167,7 +167,7 @@ class NetworkIndicator(Box):
self.network_icon = Svg( self.network_icon = Svg(
name="network-icon", name="network-icon",
size=22, size=18,
svg_file=get_relative_path( svg_file=get_relative_path(
"../../../config/assets/icons/applets/wifi-clear.svg" "../../../config/assets/icons/applets/wifi-clear.svg"
), ),
@@ -434,10 +434,13 @@ class BatteryIndicator(Box):
def update_state(self): def update_state(self):
if not self.battery_service.is_present: if not self.battery_service.is_present:
icon_file = "battery.svg" # Hide the entire battery component when no battery is present
tooltip = "No battery detected" self.set_visible(False)
percentage_text = "N/A" return
else: else:
# Show the battery component when battery is present
self.set_visible(True)
percentage = self.battery_service.percentage percentage = self.battery_service.percentage
state = self.battery_service.state state = self.battery_service.state
is_charging = state in ["CHARGING", "FULLY_CHARGED"] is_charging = state in ["CHARGING", "FULLY_CHARGED"]
@@ -448,10 +451,10 @@ class BatteryIndicator(Box):
tooltip = self.get_battery_tooltip(percentage, state) tooltip = self.get_battery_tooltip(percentage, state)
percentage_text = f"{percentage}%" percentage_text = f"{percentage}%"
# Update icon, tooltip, and percentage label # Update icon, tooltip, and percentage label
self.battery_icon.set_from_file(get_relative_path(icon_file)) self.battery_icon.set_from_file(get_relative_path(icon_file))
self.battery_button.set_tooltip_text(tooltip) self.battery_button.set_tooltip_text(tooltip)
self.battery_label.set_label(percentage_text) self.battery_label.set_label(percentage_text)
def on_battery_clicked(self, *args): def on_battery_clicked(self, *args):
"""Handle Battery indicator click""" """Handle Battery indicator click"""