diff --git a/selfdrive/ui/qt/maps/map_panel.cc b/selfdrive/ui/qt/maps/map_panel.cc index f1b8f812fa..3ac857d7e8 100644 --- a/selfdrive/ui/qt/maps/map_panel.cc +++ b/selfdrive/ui/qt/maps/map_panel.cc @@ -3,8 +3,6 @@ #include #include -#include "selfdrive/ui/qt/maps/map.h" -#include "selfdrive/ui/qt/maps/map_settings.h" #include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/ui.h" @@ -12,7 +10,7 @@ MapPanel::MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent) : Q content_stack = new QStackedLayout(this); content_stack->setContentsMargins(0, 0, 0, 0); - auto map = new MapWindow(mapboxSettings); + map = new MapWindow(mapboxSettings); QObject::connect(uiState(), &UIState::offroadTransition, map, &MapWindow::offroadTransition); QObject::connect(device(), &Device::interactiveTimeout, [=]() { content_stack->setCurrentIndex(0); @@ -22,12 +20,12 @@ MapPanel::MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent) : Q if (visible) { emit mapPanelRequested(); } setVisible(visible); }); - QObject::connect(map, &MapWindow::requestSettings, [=](bool settings) { - content_stack->setCurrentIndex(settings ? 1 : 0); + QObject::connect(map, &MapWindow::requestSettings, [=](bool _settings) { + content_stack->setCurrentIndex(_settings ? 1 : 0); }); content_stack->addWidget(map); - auto settings = new MapSettings(true, parent); + settings = new MapSettings(true, parent); QObject::connect(settings, &MapSettings::closeSettings, [=]() { content_stack->setCurrentIndex(0); }); @@ -36,8 +34,15 @@ MapPanel::MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent) : Q void MapPanel::toggleMapSettings() { // show settings if not visible, then toggle between map and settings - int new_index = isVisible() ? (1 - content_stack->currentIndex()) : 1; - content_stack->setCurrentIndex(new_index); + if (isVisible()) { + content_stack->setCurrentWidget(settings); + } else { + if (content_stack->currentWidget() == map) { + content_stack->setCurrentWidget(settings); + } else { + content_stack->setCurrentWidget(map); + } + } emit mapPanelRequested(); show(); } diff --git a/selfdrive/ui/qt/maps/map_panel.h b/selfdrive/ui/qt/maps/map_panel.h index 43a2cc7c89..eaac76b9aa 100644 --- a/selfdrive/ui/qt/maps/map_panel.h +++ b/selfdrive/ui/qt/maps/map_panel.h @@ -4,11 +4,14 @@ #include #include +#include "selfdrive/ui/qt/maps/map_settings.h" +#include "selfdrive/ui/qt/maps/map.h" + class MapPanel : public QFrame { Q_OBJECT public: - explicit MapPanel(const QMapboxGLSettings &settings, QWidget *parent = nullptr); + explicit MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent = nullptr); signals: void mapPanelRequested(); @@ -18,4 +21,8 @@ public slots: private: QStackedLayout *content_stack; + MapWindow *map; +// QWidget *map; + MapSettings *settings; +// QWidget *settings; };