diff --git a/selfdrive/ui/qt/network/wifi_manager.cc b/selfdrive/ui/qt/network/wifi_manager.cc index ddf13d26b7ff60..fd9ee17078c86c 100644 --- a/selfdrive/ui/qt/network/wifi_manager.cc +++ b/selfdrive/ui/qt/network/wifi_manager.cc @@ -448,6 +448,7 @@ void WifiManager::tetheringActivated(QDBusPendingCallWatcher *call) { }); } call->deleteLater(); + tethering_on = true; } void WifiManager::setTetheringEnabled(bool enabled) { @@ -465,6 +466,7 @@ void WifiManager::setTetheringEnabled(bool enabled) { } else { deactivateConnectionBySsid(tethering_ssid); + tethering_on = false; } } diff --git a/selfdrive/ui/qt/network/wifi_manager.h b/selfdrive/ui/qt/network/wifi_manager.h index 5d18b87d861b32..e5f79c5149bf3c 100644 --- a/selfdrive/ui/qt/network/wifi_manager.h +++ b/selfdrive/ui/qt/network/wifi_manager.h @@ -42,6 +42,7 @@ class WifiManager : public QObject { QMap seenNetworks; QMap knownConnections; QString ipv4_address; + bool tethering_on = false; bool ipv4_forward = false; explicit WifiManager(QObject* parent); diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index 7a93534da9b289..966396edc23aa1 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -74,9 +74,11 @@ void Sidebar::updateState(const UIState &s) { auto &sm = *(s.sm); + networking = networking ? networking : window()->findChild(""); + bool tethering_on = networking && networking->wifi->tethering_on; auto deviceState = sm["deviceState"].getDeviceState(); - setProperty("netType", network_type[deviceState.getNetworkType()]); - int strength = (int)deviceState.getNetworkStrength(); + setProperty("netType", tethering_on ? "Hotspot": network_type[deviceState.getNetworkType()]); + int strength = tethering_on ? 4 : (int)deviceState.getNetworkStrength(); setProperty("netStrength", strength > 0 ? strength + 1 : 0); ItemStatus connectStatus; @@ -131,8 +133,8 @@ void Sidebar::paintEvent(QPaintEvent *event) { p.setFont(InterFont(35)); p.setPen(QColor(0xff, 0xff, 0xff)); - const QRect r = QRect(50, 247, 100, 50); - p.drawText(r, Qt::AlignCenter, net_type); + const QRect r = QRect(58, 247, width() - 100, 50); + p.drawText(r, Qt::AlignLeft | Qt::AlignVCenter, net_type); // metrics drawMetric(p, temp_status.first, temp_status.second, 338); diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index f627aac810ec3d..2091418e528675 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -6,6 +6,7 @@ #include #include "selfdrive/ui/ui.h" +#include "selfdrive/ui/qt/network/networking.h" typedef QPair, QColor> ItemStatus; Q_DECLARE_METATYPE(ItemStatus); @@ -59,4 +60,5 @@ public slots: private: std::unique_ptr pm; + Networking *networking = nullptr; };