diff --git a/common/params.cc b/common/params.cc index 88de8da..c29560a 100644 --- a/common/params.cc +++ b/common/params.cc @@ -360,6 +360,7 @@ std::unordered_map keys = { {"SilentMode", PERSISTENT}, {"ShowCPU", PERSISTENT}, {"ShowGPU", PERSISTENT}, + {"ShowIP", PERSISTENT}, {"ShowMemoryUsage", PERSISTENT}, {"ShowStorageLeft", PERSISTENT}, {"ShowStorageUsed", PERSISTENT}, diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index 4ede551..8e04d54 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -43,6 +43,8 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed( isCPU = params.getBool("ShowCPU"); isGPU = params.getBool("ShowGPU"); + isIP = params.getBool("ShowIP"); + isMemoryUsage = params.getBool("ShowMemoryUsage"); isStorageLeft = params.getBool("ShowStorageLeft"); isStorageUsed = params.getBool("ShowStorageUsed"); @@ -99,10 +101,12 @@ void Sidebar::mousePressEvent(QMouseEvent *event) { // Declare the click boxes QRect cpuRect = {30, 496, 240, 126}; QRect memoryRect = {30, 654, 240, 126}; + QRect networkRect = {30, 196, 240, 126}; QRect tempRect = {30, 338, 240, 126}; static int showChip = 0; static int showMemory = 0; + static int showNetwork = 0; static int showTemp = 0; // Swap between the respective metrics upon tap @@ -122,6 +126,11 @@ void Sidebar::mousePressEvent(QMouseEvent *event) { params.putBoolNonBlocking("ShowStorageLeft", isStorageLeft); params.putBoolNonBlocking("ShowStorageUsed", isStorageUsed); update(); + } else if (networkRect.contains(event->pos())) { + showNetwork = (showNetwork + 1) % 2; + isIP = (showNetwork == 1); + params.putBoolNonBlocking("ShowIP", isIP); + update(); } else if (tempRect.contains(event->pos())) { showTemp = (showTemp + 1) % 3; scene.fahrenheit = showTemp == 2; @@ -282,14 +291,24 @@ void Sidebar::paintEvent(QPaintEvent *event) { // network 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; + p.setFont(InterFont(35)); + + if (isIP) { + p.setPen(QColor(0xff, 0xff, 0xff)); + p.save(); + p.setFont(InterFont(30)); + QRect ipBox = QRect(50, 196, 225, 27); + p.drawText(ipBox, Qt::AlignLeft | Qt::AlignVCenter, uiState()->wifi->getIp4Address()); + p.restore(); + } else { + for (int i = 0; i < 5; ++i) { + p.setBrush(i < net_strength ? Qt::white : gray); + p.drawEllipse(x, 196, 27, 27); + x += 37; + } + p.setPen(QColor(0xff, 0xff, 0xff)); } - 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); diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index 14effe9..5fd7f14 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -73,6 +73,7 @@ private: bool isCPU; bool isGPU; + bool isIP; bool isMemoryUsage; bool isStorageLeft; bool isStorageUsed;