Skip to content

Commit

Permalink
ui: show tethering status in sidebar (#33786)
Browse files Browse the repository at this point in the history
show tethering status on sidebar
  • Loading branch information
deanlee authored Oct 14, 2024
1 parent bf04c47 commit 3c5d8da
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/network/wifi_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ void WifiManager::tetheringActivated(QDBusPendingCallWatcher *call) {
});
}
call->deleteLater();
tethering_on = true;
}

void WifiManager::setTetheringEnabled(bool enabled) {
Expand All @@ -465,6 +466,7 @@ void WifiManager::setTetheringEnabled(bool enabled) {

} else {
deactivateConnectionBySsid(tethering_ssid);
tethering_on = false;
}
}

Expand Down
1 change: 1 addition & 0 deletions selfdrive/ui/qt/network/wifi_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class WifiManager : public QObject {
QMap<QString, Network> seenNetworks;
QMap<QDBusObjectPath, QString> knownConnections;
QString ipv4_address;
bool tethering_on = false;
bool ipv4_forward = false;

explicit WifiManager(QObject* parent);
Expand Down
10 changes: 6 additions & 4 deletions selfdrive/ui/qt/sidebar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ void Sidebar::updateState(const UIState &s) {

auto &sm = *(s.sm);

networking = networking ? networking : window()->findChild<Networking *>("");
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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/sidebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QMap>

#include "selfdrive/ui/ui.h"
#include "selfdrive/ui/qt/network/networking.h"

typedef QPair<QPair<QString, QString>, QColor> ItemStatus;
Q_DECLARE_METATYPE(ItemStatus);
Expand Down Expand Up @@ -59,4 +60,5 @@ public slots:

private:
std::unique_ptr<PubMaster> pm;
Networking *networking = nullptr;
};

0 comments on commit 3c5d8da

Please sign in to comment.