diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index 198d99be19..fc1f97c8cd 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -55,7 +55,7 @@ void Sidebar::updateState(const UIState &s) { auto deviceState = sm["deviceState"].getDeviceState(); setProperty("netType", network_type[deviceState.getNetworkType()]); - setProperty("netStrength", signal_imgs[deviceState.getNetworkStrength()]); + setProperty("netStrength", (int)deviceState.getNetworkStrength()); auto last_ping = deviceState.getLastAthenaPingTime(); if (last_ping == 0) { @@ -102,7 +102,14 @@ void Sidebar::paintEvent(QPaintEvent *event) { p.drawImage(60, 1080 - 180 - 40, home_img); // network - p.drawImage(58, 196, net_strength); + int x = 58; + const QColor gray(0x54, 0x54, 0x54); + for (int i = 0; i < 5; ++i) { + p.setBrush(i < net_strength ? Qt::white : gray); + p.drawEllipse(x, 196, 27, 27); + x += 37; + } + configFont(p, "Open Sans", 35, "Regular"); p.setPen(QColor(0xff, 0xff, 0xff)); const QRect r = QRect(50, 247, 100, 50); diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index f03871045a..fe1ec63647 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -13,7 +13,7 @@ class Sidebar : public QFrame { Q_PROPERTY(int tempVal MEMBER temp_val NOTIFY valueChanged); Q_PROPERTY(QColor tempStatus MEMBER temp_status NOTIFY valueChanged); Q_PROPERTY(QString netType MEMBER net_type NOTIFY valueChanged); - Q_PROPERTY(QImage netStrength MEMBER net_strength NOTIFY valueChanged); + Q_PROPERTY(int netStrength MEMBER net_strength NOTIFY valueChanged); public: explicit Sidebar(QWidget* parent = 0); @@ -41,13 +41,6 @@ private: {cereal::DeviceState::NetworkType::CELL4_G, "LTE"}, {cereal::DeviceState::NetworkType::CELL5_G, "5G"} }; - const QMap signal_imgs = { - {cereal::DeviceState::NetworkStrength::UNKNOWN, QImage("../assets/images/network_0.png")}, - {cereal::DeviceState::NetworkStrength::POOR, QImage("../assets/images/network_1.png")}, - {cereal::DeviceState::NetworkStrength::MODERATE, QImage("../assets/images/network_2.png")}, - {cereal::DeviceState::NetworkStrength::GOOD, QImage("../assets/images/network_3.png")}, - {cereal::DeviceState::NetworkStrength::GREAT, QImage("../assets/images/network_4.png")}, - }; const QRect settings_btn = QRect(50, 35, 200, 117); const QColor good_color = QColor(255, 255, 255); @@ -61,5 +54,5 @@ private: int temp_val = 0; QColor temp_status = warning_color; QString net_type; - QImage net_strength; + int net_strength = 0; };