diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 9a143d33f4..86ab2f1812 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -24,6 +24,7 @@ const QString ICON_SUFFIX = ".png"; MapWindow::MapWindow(const QMapboxGLSettings &settings) : m_settings(settings), velocity_filter(0, 10, 0.05) { QObject::connect(uiState(), &UIState::uiUpdate, this, &MapWindow::updateState); + QObject::connect(uiState(), &UIState::uiUpdate, this, &MapWindow::updateState); map_overlay = new QWidget (this); map_overlay->setAttribute(Qt::WA_TranslucentBackground, true); diff --git a/selfdrive/ui/qt/maps/map_panel.cc b/selfdrive/ui/qt/maps/map_panel.cc index b2d00bf049..6fe71b9d47 100644 --- a/selfdrive/ui/qt/maps/map_panel.cc +++ b/selfdrive/ui/qt/maps/map_panel.cc @@ -33,3 +33,9 @@ MapPanel::MapPanel(const QMapboxGLSettings &mapboxSettings, QWidget *parent) : Q }); content_stack->addWidget(settings); } + +void MapPanel::mapSettingsRequested() { + emit mapPanelRequested(); + setVisible(true); + content_stack->setCurrentIndex(1); +} diff --git a/selfdrive/ui/qt/maps/map_panel.h b/selfdrive/ui/qt/maps/map_panel.h index 488250a636..1f663cbabb 100644 --- a/selfdrive/ui/qt/maps/map_panel.h +++ b/selfdrive/ui/qt/maps/map_panel.h @@ -13,6 +13,10 @@ public: signals: void mapPanelRequested(); +public slots: + void mapSettingsRequested(); + + private: QStackedLayout *content_stack; }; diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 19b715add6..541770e983 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -20,6 +20,12 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { main_layout->addLayout(stacked_layout); nvg = new AnnotatedCameraWidget(VISION_STREAM_ROAD, this); + QObject::connect(nvg, &AnnotatedCameraWidget::mapSettingsRequested, [=]() { + qDebug() << "double clicked!"; +// if (map) { +// map->mapSettingsRequested(); +// } + }); QWidget * split_wrapper = new QWidget; split = new QHBoxLayout(split_wrapper); @@ -92,6 +98,7 @@ void OnroadWindow::offroadTransition(bool offroad) { map = m; QObject::connect(m, &MapPanel::mapPanelRequested, this, &OnroadWindow::mapPanelRequested); + QObject::connect(nvg, &AnnotatedCameraWidget::mapSettingsRequested, m, &MapPanel::mapSettingsRequested); m->setFixedWidth(topWidget(this)->width() / 2 - UI_BORDER_SIZE); split->insertWidget(0, m); @@ -231,11 +238,12 @@ MapSettingsButton::MapSettingsButton(QWidget *parent) : experimental_mode(false) } void MapSettingsButton::changeMode() { - const auto cp = (*uiState()->sm)["carParams"].getCarParams(); - bool can_change = hasLongitudinalControl(cp) && params.getBool("ExperimentalModeConfirmed"); - if (can_change) { - params.putBool("ExperimentalMode", !experimental_mode); - } + emit mapSettingsRequested(); +// const auto cp = (*uiState()->sm)["carParams"].getCarParams(); +// bool can_change = hasLongitudinalControl(cp) && params.getBool("ExperimentalModeConfirmed"); +// if (can_change) { +// params.putBool("ExperimentalMode", !experimental_mode); +// } } void MapSettingsButton::updateState(const UIState &s) { @@ -275,6 +283,15 @@ AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* par main_layout->addWidget(experimental_btn, 0, Qt::AlignTop | Qt::AlignRight); map_settings_btn = new MapSettingsButton(this); + // TODO: connect to clicked! + QObject::connect(map_settings_btn, &MapSettingsButton::mapSettingsRequested, this, &AnnotatedCameraWidget::mapSettingsRequested); +// QObject::connect(map_settings_btn, &MapSettingsButton::mapSettingsRequested, [=]() { +// qDebug() << "clicked!"; +// if (map) { +// map->mapSettingsRequested(); +// } +// }); +// QObject::connect(this, &QPushButton::clicked, this, &MapSettingsButton::changeMode); main_layout->addWidget(map_settings_btn, 0, Qt::AlignBottom | Qt::AlignRight); dm_img = loadPixmap("../assets/img_driver_face.png", {img_size + 5, img_size + 5}); diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index bf5a01b4a5..0b9db8ab2b 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -55,6 +55,9 @@ public: explicit MapSettingsButton(QWidget *parent = 0); void updateState(const UIState &s); +signals: + void mapSettingsRequested(); + private: void paintEvent(QPaintEvent *event) override; void changeMode(); @@ -86,6 +89,9 @@ public: explicit AnnotatedCameraWidget(VisionStreamType type, QWidget* parent = 0); void updateState(const UIState &s); +signals: + void mapSettingsRequested(); + private: void drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity); void drawText(QPainter &p, int x, int y, const QString &text, int alpha = 255);