From 305ab3cb3eeee3f821f7ff5ca823616390dc253f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 11 Jul 2023 00:58:28 -0700 Subject: [PATCH] ui: don't hide sidebar twice (#28868) * draft * draft 2 * comment and clean up * delete * better name * even better? --- selfdrive/ui/qt/home.cc | 2 +- selfdrive/ui/qt/maps/map_panel.cc | 2 ++ selfdrive/ui/qt/maps/map_panel.h | 5 +---- selfdrive/ui/qt/onroad.cc | 2 +- selfdrive/ui/qt/onroad.h | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index 0f54061f3c..b4181f82b7 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -34,7 +34,7 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { slayout->addWidget(home); onroad = new OnroadWindow(this); - QObject::connect(onroad, &OnroadWindow::mapWindowShown, this, [=] { sidebar->hide(); }); + QObject::connect(onroad, &OnroadWindow::mapPanelRequested, this, [=] { sidebar->hide(); }); slayout->addWidget(onroad); body = new BodyWindow(this); diff --git a/selfdrive/ui/qt/maps/map_panel.cc b/selfdrive/ui/qt/maps/map_panel.cc index e1a393f689..6bee7f0923 100644 --- a/selfdrive/ui/qt/maps/map_panel.cc +++ b/selfdrive/ui/qt/maps/map_panel.cc @@ -15,6 +15,8 @@ MapPanel::MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent) : Q auto map = new MapWindow(mapboxSettings); QObject::connect(uiState(), &UIState::offroadTransition, map, &MapWindow::offroadTransition); QObject::connect(map, &MapWindow::requestVisible, [=](bool visible) { + // when we show the map for a new route, signal HomeWindow to hide the sidebar + if (visible) { emit mapPanelRequested(); } setVisible(visible); }); QObject::connect(map, &MapWindow::openSettings, [=]() { diff --git a/selfdrive/ui/qt/maps/map_panel.h b/selfdrive/ui/qt/maps/map_panel.h index 9da188701c..488250a636 100644 --- a/selfdrive/ui/qt/maps/map_panel.h +++ b/selfdrive/ui/qt/maps/map_panel.h @@ -10,11 +10,8 @@ class MapPanel : public QFrame { public: explicit MapPanel(const QMapboxGLSettings &settings, QWidget *parent = nullptr); -private: - void showEvent(QShowEvent *event) { emit mapWindowShown(); }; - signals: - void mapWindowShown(); + void mapPanelRequested(); private: QStackedLayout *content_stack; diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index a3e13c02a1..eaef8b9225 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -89,7 +89,7 @@ void OnroadWindow::offroadTransition(bool offroad) { auto m = new MapPanel(get_mapbox_settings()); map = m; - QObject::connect(m, &MapPanel::mapWindowShown, this, &OnroadWindow::mapWindowShown); + QObject::connect(m, &MapPanel::mapPanelRequested, this, &OnroadWindow::mapPanelRequested); m->setFixedWidth(topWidget(this)->width() / 2 - UI_BORDER_SIZE); split->insertWidget(0, m); diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index e42f5f8cd8..6f30d0f37e 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -119,7 +119,7 @@ public: bool isMapVisible() const { return map && map->isVisible(); } signals: - void mapWindowShown(); + void mapPanelRequested(); private: void paintEvent(QPaintEvent *event);