mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
wifi button shows connecting (#37202)
* connecting wifi button * use real wifi strength * simplify * meh cursor brought up edge case
This commit is contained in:
@@ -160,18 +160,24 @@ class NetworkLayoutMici(NavWidget):
|
||||
|
||||
# Update wi-fi button with ssid and ip address
|
||||
# TODO: make sure we handle hidden ssids
|
||||
connecting_ssid = self._wifi_manager.connecting_to_ssid
|
||||
connected_network = next((network for network in networks if network.is_connected), None)
|
||||
self._wifi_button.set_text(normalize_ssid(connected_network.ssid) if connected_network is not None else "wi-fi")
|
||||
self._wifi_button.set_value(self._wifi_manager.ipv4_address or "not connected")
|
||||
if connected_network is not None:
|
||||
strength = WifiIcon.get_strength_icon_idx(connected_network.strength)
|
||||
if strength == 2:
|
||||
strength_icon = self._wifi_full_txt
|
||||
elif strength == 1:
|
||||
strength_icon = self._wifi_medium_txt
|
||||
else:
|
||||
strength_icon = self._wifi_low_txt
|
||||
self._wifi_button.set_icon(strength_icon)
|
||||
if connecting_ssid:
|
||||
display_network = next((n for n in networks if n.ssid == connecting_ssid), None)
|
||||
self._wifi_button.set_text(normalize_ssid(connecting_ssid))
|
||||
self._wifi_button.set_value("connecting...")
|
||||
elif connected_network is not None:
|
||||
display_network = connected_network
|
||||
self._wifi_button.set_text(normalize_ssid(connected_network.ssid))
|
||||
self._wifi_button.set_value(self._wifi_manager.ipv4_address or "not connected")
|
||||
else:
|
||||
display_network = None
|
||||
self._wifi_button.set_text("wi-fi")
|
||||
self._wifi_button.set_value("not connected")
|
||||
|
||||
if display_network is not None:
|
||||
strength = WifiIcon.get_strength_icon_idx(display_network.strength)
|
||||
self._wifi_button.set_icon(self._wifi_full_txt if strength == 2 else self._wifi_medium_txt if strength == 1 else self._wifi_low_txt)
|
||||
else:
|
||||
self._wifi_button.set_icon(self._wifi_slash_txt)
|
||||
|
||||
|
||||
@@ -233,6 +233,10 @@ class WifiManager:
|
||||
def current_network_metered(self) -> MeteredType:
|
||||
return self._current_network_metered
|
||||
|
||||
@property
|
||||
def connecting_to_ssid(self) -> str:
|
||||
return self._connecting_to_ssid
|
||||
|
||||
@property
|
||||
def tethering_password(self) -> str:
|
||||
return self._tethering_password
|
||||
|
||||
Reference in New Issue
Block a user