From 86c255e3e881c81d6066b04f1d118fddb39b4a81 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 11 Jul 2021 00:32:11 -0700 Subject: [PATCH] nav: restore zoom and position on double click (#21551) --- selfdrive/ui/qt/maps/map.cc | 6 ++++++ selfdrive/ui/qt/maps/map.h | 1 + 2 files changed, 7 insertions(+) diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index fbee2d666d..7fdb366e8d 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -400,6 +400,12 @@ void MapWindow::mousePressEvent(QMouseEvent *ev) { ev->accept(); } +void MapWindow::mouseDoubleClickEvent(QMouseEvent *ev) { + if (last_position) m_map->setCoordinate(*last_position); + if (last_bearing) m_map->setBearing(*last_bearing); + m_map->setZoom(util::map_val(velocity_filter.x(), 0, 30, MAX_ZOOM, MIN_ZOOM)); +} + void MapWindow::mouseMoveEvent(QMouseEvent *ev) { QPointF delta = ev->localPos() - m_lastPos; diff --git a/selfdrive/ui/qt/maps/map.h b/selfdrive/ui/qt/maps/map.h index 68d6a6421a..7da1024485 100644 --- a/selfdrive/ui/qt/maps/map.h +++ b/selfdrive/ui/qt/maps/map.h @@ -86,6 +86,7 @@ private: void initLayers(); void mousePressEvent(QMouseEvent *ev) final; + void mouseDoubleClickEvent(QMouseEvent *ev) final; void mouseMoveEvent(QMouseEvent *ev) final; void wheelEvent(QWheelEvent *ev) final; bool event(QEvent *event) final;