mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 00:05:59 +08:00
UI: double click to switch between body and onroad views (#24214)
* UI: double click to switch between body and onroad views * fix that * Update selfdrive/ui/qt/home.cc Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+14
-1
@@ -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) {
|
||||
|
||||
@@ -51,6 +51,7 @@ public slots:
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* e) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent* e) override;
|
||||
|
||||
private:
|
||||
Sidebar *sidebar;
|
||||
|
||||
Reference in New Issue
Block a user