ui: show tethering status in sidebar (#33786)

show tethering status on sidebar
pull/33776/head
Dean Lee 6 months ago committed by GitHub
parent bf04c4799a
commit 3c5d8da469
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      selfdrive/ui/qt/network/wifi_manager.cc
  2. 1
      selfdrive/ui/qt/network/wifi_manager.h
  3. 10
      selfdrive/ui/qt/sidebar.cc
  4. 2
      selfdrive/ui/qt/sidebar.h

@ -448,6 +448,7 @@ void WifiManager::tetheringActivated(QDBusPendingCallWatcher *call) {
}); });
} }
call->deleteLater(); call->deleteLater();
tethering_on = true;
} }
void WifiManager::setTetheringEnabled(bool enabled) { void WifiManager::setTetheringEnabled(bool enabled) {
@ -465,6 +466,7 @@ void WifiManager::setTetheringEnabled(bool enabled) {
} else { } else {
deactivateConnectionBySsid(tethering_ssid); deactivateConnectionBySsid(tethering_ssid);
tethering_on = false;
} }
} }

@ -42,6 +42,7 @@ public:
QMap<QString, Network> seenNetworks; QMap<QString, Network> seenNetworks;
QMap<QDBusObjectPath, QString> knownConnections; QMap<QDBusObjectPath, QString> knownConnections;
QString ipv4_address; QString ipv4_address;
bool tethering_on = false;
bool ipv4_forward = false; bool ipv4_forward = false;
explicit WifiManager(QObject* parent); explicit WifiManager(QObject* parent);

@ -74,9 +74,11 @@ void Sidebar::updateState(const UIState &s) {
auto &sm = *(s.sm); auto &sm = *(s.sm);
networking = networking ? networking : window()->findChild<Networking *>("");
bool tethering_on = networking && networking->wifi->tethering_on;
auto deviceState = sm["deviceState"].getDeviceState(); auto deviceState = sm["deviceState"].getDeviceState();
setProperty("netType", network_type[deviceState.getNetworkType()]); setProperty("netType", tethering_on ? "Hotspot": network_type[deviceState.getNetworkType()]);
int strength = (int)deviceState.getNetworkStrength(); int strength = tethering_on ? 4 : (int)deviceState.getNetworkStrength();
setProperty("netStrength", strength > 0 ? strength + 1 : 0); setProperty("netStrength", strength > 0 ? strength + 1 : 0);
ItemStatus connectStatus; ItemStatus connectStatus;
@ -131,8 +133,8 @@ void Sidebar::paintEvent(QPaintEvent *event) {
p.setFont(InterFont(35)); p.setFont(InterFont(35));
p.setPen(QColor(0xff, 0xff, 0xff)); p.setPen(QColor(0xff, 0xff, 0xff));
const QRect r = QRect(50, 247, 100, 50); const QRect r = QRect(58, 247, width() - 100, 50);
p.drawText(r, Qt::AlignCenter, net_type); p.drawText(r, Qt::AlignLeft | Qt::AlignVCenter, net_type);
// metrics // metrics
drawMetric(p, temp_status.first, temp_status.second, 338); drawMetric(p, temp_status.first, temp_status.second, 338);

@ -6,6 +6,7 @@
#include <QMap> #include <QMap>
#include "selfdrive/ui/ui.h" #include "selfdrive/ui/ui.h"
#include "selfdrive/ui/qt/network/networking.h"
typedef QPair<QPair<QString, QString>, QColor> ItemStatus; typedef QPair<QPair<QString, QString>, QColor> ItemStatus;
Q_DECLARE_METATYPE(ItemStatus); Q_DECLARE_METATYPE(ItemStatus);
@ -59,4 +60,5 @@ protected:
private: private:
std::unique_ptr<PubMaster> pm; std::unique_ptr<PubMaster> pm;
Networking *networking = nullptr;
}; };

Loading…
Cancel
Save