From f667936f3a41c7ab62e004e8cc5970eb136e84cc Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 17 Aug 2023 16:32:22 +0800 Subject: [PATCH] ui/map: show map on destination set/change (#29327) * show map on dest set/change * check for rcv_frame * clear current_nav_dest * restore allow_open * use requestShow * cleanup * one check * revert behavior changes * Update selfdrive/ui/qt/maps/map.cc * more obvious * Update selfdrive/ui/qt/maps/map.cc --------- Co-authored-by: Shane Smiskol old-commit-hash: 3a277f1b81fbb16673a77a475421a18751127cf2 --- selfdrive/ui/qt/maps/map.cc | 10 ++++++---- selfdrive/ui/qt/maps/map.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index e7e8f757b..b596b1126 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -156,13 +156,15 @@ void MapWindow::updateState(const UIState &s) { } if (sm.updated("navRoute") && sm["navRoute"].getNavRoute().getCoordinates().size()) { + auto nav_dest = coordinate_from_param("NavDestination"); + bool allow_open = std::exchange(last_valid_nav_dest, nav_dest) != nav_dest && + nav_dest && !isVisible(); qWarning() << "Got new navRoute from navd. Opening map:" << allow_open; - // Only open the map on setting destination the first time + // Show map on destination set/change if (allow_open) { emit requestSettings(false); - emit requestVisible(true); // Show map on destination set/change - allow_open = false; + emit requestVisible(true); } } @@ -291,7 +293,7 @@ void MapWindow::clearRoute() { map_instructions->setVisible(false); map_eta->setVisible(false); - allow_open = true; + last_valid_nav_dest = std::nullopt; } void MapWindow::mousePressEvent(QMouseEvent *ev) { diff --git a/selfdrive/ui/qt/maps/map.h b/selfdrive/ui/qt/maps/map.h index d57f6517b..66d10a00a 100644 --- a/selfdrive/ui/qt/maps/map.h +++ b/selfdrive/ui/qt/maps/map.h @@ -50,7 +50,6 @@ private: void setError(const QString &err_str); bool loaded_once = false; - bool allow_open = true; // Panning QPointF m_lastPos; @@ -58,6 +57,7 @@ private: int zoom_counter = 0; // Position + std::optional last_valid_nav_dest; std::optional last_position; std::optional last_bearing; FirstOrderFilter velocity_filter;