diff --git a/selfdrive/ui/qt/body.cc b/selfdrive/ui/qt/body.cc index 7e87361916..08d3611b46 100644 --- a/selfdrive/ui/qt/body.cc +++ b/selfdrive/ui/qt/body.cc @@ -14,6 +14,8 @@ BodyWindow::BodyWindow(QWidget *parent) : QLabel(parent) { setAlignment(Qt::AlignCenter); + setAttribute(Qt::WA_TransparentForMouseEvents, true); + QObject::connect(uiState(), &UIState::uiUpdate, this, &BodyWindow::updateState); } diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index d2d8c77f48..0b64900770 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -32,6 +32,7 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { body = new BodyWindow(this); slayout->addWidget(body); + body->setEnabled(false); driver_view = new DriverViewWindow(this); connect(driver_view, &DriverViewWindow::done, [=] { @@ -51,7 +52,8 @@ void HomeWindow::updateState(const UIState &s) { const SubMaster &sm = *(s.sm); // switch to the generic robot UI - if (onroad->isVisible() && sm["carParams"].getCarParams().getNotCar()) { + if (onroad->isVisible() && !body->isEnabled() && sm["carParams"].getCarParams().getNotCar()) { + body->setEnabled(true); slayout->setCurrentWidget(body); } } @@ -82,6 +84,17 @@ void HomeWindow::mousePressEvent(QMouseEvent* e) { } } +void HomeWindow::mouseDoubleClickEvent(QMouseEvent* e) { + const SubMaster &sm = *(uiState()->sm); + if (sm["carParams"].getCarParams().getNotCar()) { + if (onroad->isVisible()) { + slayout->setCurrentWidget(body); + } else if (body->isVisible()) { + slayout->setCurrentWidget(onroad); + } + } +} + // OffroadHome: the offroad home page OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) { diff --git a/selfdrive/ui/qt/home.h b/selfdrive/ui/qt/home.h index 7c043908e4..94f1330109 100644 --- a/selfdrive/ui/qt/home.h +++ b/selfdrive/ui/qt/home.h @@ -51,6 +51,7 @@ public slots: protected: void mousePressEvent(QMouseEvent* e) override; + void mouseDoubleClickEvent(QMouseEvent* e) override; private: Sidebar *sidebar;