From 6abb050a3469f10b1b001d3c20ca84795adb63f0 Mon Sep 17 00:00:00 2001 From: hanabi95 Date: Sat, 22 May 2021 13:23:52 +0900 Subject: [PATCH] Hotfix: Don't hide onboarding after display timeout (#20973) --- selfdrive/ui/qt/offroad/onboarding.cc | 13 +++++++++++-- selfdrive/ui/qt/offroad/onboarding.h | 4 ++++ selfdrive/ui/qt/window.cc | 11 +++++++++-- selfdrive/ui/qt/window.h | 1 + 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/qt/offroad/onboarding.cc b/selfdrive/ui/qt/offroad/onboarding.cc index 8ce48becdb592fe..ea34b35e6a79fe1 100644 --- a/selfdrive/ui/qt/offroad/onboarding.cc +++ b/selfdrive/ui/qt/offroad/onboarding.cc @@ -107,8 +107,7 @@ void TermsPage::enableAccept(){ } void OnboardingWindow::updateActiveScreen() { - bool accepted_terms = params.get("HasAcceptedTerms", false).compare(current_terms_version) == 0; - bool training_done = params.get("CompletedTrainingVersion", false).compare(current_training_version) == 0; + updateOnboardingStatus(); if (!accepted_terms) { setCurrentIndex(0); @@ -157,3 +156,13 @@ OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) { updateActiveScreen(); } + +void OnboardingWindow::updateOnboardingStatus() { + accepted_terms = params.get("HasAcceptedTerms", false).compare(current_terms_version) == 0; + training_done = params.get("CompletedTrainingVersion", false).compare(current_training_version) == 0; +} + +bool OnboardingWindow::isOnboardingDone() { + updateOnboardingStatus(); + return accepted_terms && training_done; +} diff --git a/selfdrive/ui/qt/offroad/onboarding.h b/selfdrive/ui/qt/offroad/onboarding.h index 987fad336c9fd2b..92a9b971fcaccb9 100644 --- a/selfdrive/ui/qt/offroad/onboarding.h +++ b/selfdrive/ui/qt/offroad/onboarding.h @@ -77,11 +77,15 @@ class OnboardingWindow : public QStackedWidget { public: explicit OnboardingWindow(QWidget *parent = 0); + bool isOnboardingDone(); private: Params params; std::string current_terms_version; std::string current_training_version; + bool accepted_terms = false; + bool training_done = false; + void updateOnboardingStatus(); signals: void onboardingDone(); diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 864dabf1586aedc..f10fce403a47275 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -22,10 +22,14 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { QObject::connect(settingsWindow, &SettingsWindow::reviewTrainingGuide, this, &MainWindow::reviewTrainingGuide); onboardingWindow = new OnboardingWindow(this); + onboardingDone = onboardingWindow->isOnboardingDone(); main_layout->addWidget(onboardingWindow); main_layout->setCurrentWidget(onboardingWindow); - QObject::connect(onboardingWindow, &OnboardingWindow::onboardingDone, this, &MainWindow::closeSettings); + QObject::connect(onboardingWindow, &OnboardingWindow::onboardingDone, [=](){ + onboardingDone = true; + closeSettings(); + }); onboardingWindow->updateActiveScreen(); device.setAwake(true, true); @@ -59,10 +63,13 @@ void MainWindow::openSettings() { } void MainWindow::closeSettings() { - main_layout->setCurrentWidget(homeWindow); + if(onboardingDone) { + main_layout->setCurrentWidget(homeWindow); + } } void MainWindow::reviewTrainingGuide() { + onboardingDone = false; main_layout->setCurrentWidget(onboardingWindow); onboardingWindow->updateActiveScreen(); } diff --git a/selfdrive/ui/qt/window.h b/selfdrive/ui/qt/window.h index 9d3a2a8912d77c2..5a40e94bb2042b2 100644 --- a/selfdrive/ui/qt/window.h +++ b/selfdrive/ui/qt/window.h @@ -25,6 +25,7 @@ class MainWindow : public QWidget { HomeWindow *homeWindow; SettingsWindow *settingsWindow; OnboardingWindow *onboardingWindow; + bool onboardingDone = false; public slots: void offroadTransition(bool offroad);