From 2b6237dd4c6d3ce6f4e3936655ee77b40d153dea Mon Sep 17 00:00:00 2001 From: grekiki Date: Mon, 22 Feb 2021 10:47:33 +0100 Subject: [PATCH] Qt ui: close settings on onroad transition (#20114) * need to test * works * reduce diff * refactor Co-authored-by: Comma Device old-commit-hash: dab2e1298b62991e57123972a34167a3ce62de8a --- selfdrive/ui/qt/home.cc | 1 + selfdrive/ui/qt/home.hpp | 1 + selfdrive/ui/qt/window.cc | 7 +++++++ selfdrive/ui/qt/window.hpp | 1 + 4 files changed, 10 insertions(+) diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index 79b084f5fc..e71902c25b 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -143,6 +143,7 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { home = new OffroadHome(); layout->addWidget(home, 0, 0); QObject::connect(glWindow, SIGNAL(offroadTransition(bool)), this, SLOT(setVisibility(bool))); + QObject::connect(glWindow, SIGNAL(offroadTransition(bool)), this, SIGNAL(offroadTransition(bool))); QObject::connect(this, SIGNAL(openSettings()), home, SLOT(refresh())); setLayout(layout); setStyleSheet(R"( diff --git a/selfdrive/ui/qt/home.hpp b/selfdrive/ui/qt/home.hpp index 11e5fb6719..419c279334 100644 --- a/selfdrive/ui/qt/home.hpp +++ b/selfdrive/ui/qt/home.hpp @@ -83,6 +83,7 @@ public: GLWindow* glWindow; signals: + void offroadTransition(bool offroad); void openSettings(); protected: diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 71b4e21942..239eb6a6ac 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -15,6 +15,7 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { main_layout->setMargin(0); setLayout(main_layout); QObject::connect(homeWindow, SIGNAL(openSettings()), this, SLOT(openSettings())); + QObject::connect(homeWindow, SIGNAL(offroadTransition(bool)), this, SLOT(offroadTransition(bool))); QObject::connect(settingsWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings())); // start at onboarding @@ -29,6 +30,12 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { )"); } +void MainWindow::offroadTransition(bool offroad){ + if(!offroad){ + closeSettings(); + } +} + void MainWindow::openSettings() { main_layout->setCurrentWidget(settingsWindow); } diff --git a/selfdrive/ui/qt/window.hpp b/selfdrive/ui/qt/window.hpp index 10822f1fbc..2c61ac07c3 100644 --- a/selfdrive/ui/qt/window.hpp +++ b/selfdrive/ui/qt/window.hpp @@ -23,6 +23,7 @@ private: OnboardingWindow *onboardingWindow; public slots: + void offroadTransition(bool offroad); void openSettings(); void closeSettings(); };