Skip to content

Commit

Permalink
Hotfix: Don't hide onboarding after display timeout (#20973)
Browse files Browse the repository at this point in the history
Co-authored-by: Maxime Desroches <desroches.maxime@gmail.com>
  • Loading branch information
adeebshihadeh and maxime-desroches authored May 20, 2021
1 parent 8b274fc commit bf662bb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
13 changes: 11 additions & 2 deletions selfdrive/ui/qt/offroad/onboarding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
4 changes: 4 additions & 0 deletions selfdrive/ui/qt/offroad/onboarding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 9 additions & 2 deletions selfdrive/ui/qt/window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions selfdrive/ui/qt/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class MainWindow : public QWidget {
HomeWindow *homeWindow;
SettingsWindow *settingsWindow;
OnboardingWindow *onboardingWindow;
bool onboardingDone = false;

public slots:
void offroadTransition(bool offroad);
Expand Down

0 comments on commit bf662bb

Please sign in to comment.