Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Terms and Training guide skip when the screen turns off #20942

Merged
merged 1 commit into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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