diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index 950b34e8bc..c2e6135871 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -345,7 +345,7 @@ def thermald_thread(): # with 2% left, we killall, otherwise the phone will take a long time to boot startup_conditions["free_space"] = msg.deviceState.freeSpacePercent > 2 startup_conditions["completed_training"] = params.get("CompletedTrainingVersion") == training_version or \ - (current_branch in ['dashcam', 'dashcam-staging']) + params.get_bool("Passive") startup_conditions["not_driver_view"] = not params.get_bool("IsDriverViewEnabled") startup_conditions["not_taking_snapshot"] = not params.get_bool("IsTakingSnapshot") # if any CPU gets above 107 or the battery gets above 63, kill all processes diff --git a/selfdrive/ui/qt/offroad/onboarding.cc b/selfdrive/ui/qt/offroad/onboarding.cc index 0842a29e97..2c100885ec 100644 --- a/selfdrive/ui/qt/offroad/onboarding.cc +++ b/selfdrive/ui/qt/offroad/onboarding.cc @@ -88,15 +88,6 @@ void TermsPage::showEvent(QShowEvent *event) { accept_btn->setEnabled(false); buttons->addWidget(accept_btn); QObject::connect(accept_btn, &QPushButton::released, this, &TermsPage::acceptedTerms); - - setStyleSheet(R"( - QPushButton { - padding: 50px; - font-size: 50px; - border-radius: 10px; - background-color: #292929; - } - )"); } void TermsPage::enableAccept() { @@ -137,23 +128,14 @@ void DeclinePage::showEvent(QShowEvent *event) { Params().putBool("DoUninstall", true); } }); - - setStyleSheet(R"( - QPushButton { - padding: 50px; - font-size: 50px; - border-radius: 10px; - background-color: #292929; - } - )"); } void OnboardingWindow::updateActiveScreen() { - updateOnboardingStatus(); - + accepted_terms = params.get("HasAcceptedTerms") == current_terms_version; + training_done = params.get("CompletedTrainingVersion") == current_training_version; if (!accepted_terms) { setCurrentIndex(0); - } else if (!training_done) { + } else if (!training_done && !params.getBool("Passive")) { setCurrentIndex(1); } else { emit onboardingDone(); @@ -161,35 +143,27 @@ void OnboardingWindow::updateActiveScreen() { } OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) { - params = Params(); - current_terms_version = params.get("TermsVersion", false); - current_training_version = params.get("TrainingVersion", false); + current_terms_version = params.get("TermsVersion"); + current_training_version = params.get("TrainingVersion"); TermsPage* terms = new TermsPage(this); addWidget(terms); - connect(terms, &TermsPage::acceptedTerms, [=]() { Params().put("HasAcceptedTerms", current_terms_version); updateActiveScreen(); }); + connect(terms, &TermsPage::declinedTerms, [=]() { setCurrentIndex(2); }); TrainingGuide* tr = new TrainingGuide(this); + addWidget(tr); connect(tr, &TrainingGuide::completedTraining, [=]() { Params().put("CompletedTrainingVersion", current_training_version); updateActiveScreen(); }); - addWidget(tr); DeclinePage* declinePage = new DeclinePage(this); addWidget(declinePage); - - connect(terms, &TermsPage::declinedTerms, [=]() { - setCurrentIndex(2); - }); - - connect(declinePage, &DeclinePage::getBack, [=]() { - updateActiveScreen(); - }); + connect(declinePage, &DeclinePage::getBack, [=]() { updateActiveScreen(); }); setStyleSheet(R"( * { @@ -198,7 +172,8 @@ OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) { } QPushButton { padding: 50px; - border-radius: 30px; + font-size: 50px; + border-radius: 10px; background-color: #292929; } QPushButton:disabled { @@ -206,16 +181,8 @@ OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) { background-color: #222222; } )"); - - 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; +void OnboardingWindow::showEvent(QShowEvent *event) { + updateActiveScreen(); } diff --git a/selfdrive/ui/qt/offroad/onboarding.h b/selfdrive/ui/qt/offroad/onboarding.h index 584adda4f0..8752e831b7 100644 --- a/selfdrive/ui/qt/offroad/onboarding.h +++ b/selfdrive/ui/qt/offroad/onboarding.h @@ -14,12 +14,11 @@ class TrainingGuide : public QFrame { public: explicit TrainingGuide(QWidget *parent = 0) : QFrame(parent) {}; -protected: +private: void showEvent(QShowEvent *event) override; void paintEvent(QPaintEvent *event) override; void mouseReleaseEvent(QMouseEvent* e) override; -private: QImage image; QPoint imageCorner; int currentIndex = 0; @@ -58,16 +57,15 @@ class TermsPage : public QFrame { public: explicit TermsPage(QWidget *parent = 0) : QFrame(parent) {}; -protected: - void showEvent(QShowEvent *event) override; +public slots: + void enableAccept(); private: + void showEvent(QShowEvent *event) override; + QPushButton *accept_btn; QPushButton *decline_btn; -public slots: - void enableAccept(); - signals: void acceptedTerms(); void declinedTerms(); @@ -79,10 +77,8 @@ class DeclinePage : public QFrame { public: explicit DeclinePage(QWidget *parent = 0) : QFrame(parent) {}; -protected: - void showEvent(QShowEvent *event) override; - private: + void showEvent(QShowEvent *event) override; QPushButton *back_btn; QPushButton *uninstall_btn; @@ -95,20 +91,17 @@ class OnboardingWindow : public QStackedWidget { public: explicit OnboardingWindow(QWidget *parent = 0); - bool isOnboardingDone(); private: + void showEvent(QShowEvent *event) override; + void updateActiveScreen(); + 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(); - void resetTrainingGuide(); - -public slots: - void updateActiveScreen(); }; diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 5256bfa50a..84f3533858 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -147,13 +147,16 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) { resetCalibBtn->setDescription(desc); }); - auto retrainingBtn = new ButtonControl("Review Training Guide", "REVIEW", "Review the rules, features, and limitations of openpilot"); - connect(retrainingBtn, &ButtonControl::released, [=]() { - if (ConfirmationDialog::confirm("Are you sure you want to review the training guide?", this)) { - Params().remove("CompletedTrainingVersion"); - emit reviewTrainingGuide(); - } - }); + ButtonControl *retrainingBtn = nullptr; + if (!params.getBool("Passive")) { + retrainingBtn = new ButtonControl("Review Training Guide", "REVIEW", "Review the rules, features, and limitations of openpilot"); + connect(retrainingBtn, &ButtonControl::released, [=]() { + if (ConfirmationDialog::confirm("Are you sure you want to review the training guide?", this)) { + Params().remove("CompletedTrainingVersion"); + emit reviewTrainingGuide(); + } + }); + } auto uninstallBtn = new ButtonControl("Uninstall " + getBrand(), "UNINSTALL"); connect(uninstallBtn, &ButtonControl::released, [=]() { @@ -163,9 +166,11 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) { }); for (auto btn : {dcamBtn, resetCalibBtn, retrainingBtn, uninstallBtn}) { - main_layout->addWidget(horizontal_line()); - connect(parent, SIGNAL(offroadTransition(bool)), btn, SLOT(setEnabled(bool))); - main_layout->addWidget(btn); + if (btn) { + main_layout->addWidget(horizontal_line()); + connect(parent, SIGNAL(offroadTransition(bool)), btn, SLOT(setEnabled(bool))); + main_layout->addWidget(btn); + } } // power buttons diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 8edfb2efae..2a821abde4 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -8,6 +8,12 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { main_layout = new QStackedLayout(this); main_layout->setMargin(0); + onboardingWindow = new OnboardingWindow(this); + main_layout->addWidget(onboardingWindow); + QObject::connect(onboardingWindow, &OnboardingWindow::onboardingDone, [=]() { + main_layout->setCurrentWidget(homeWindow); + }); + homeWindow = new HomeWindow(this); main_layout->addWidget(homeWindow); QObject::connect(homeWindow, &HomeWindow::openSettings, this, &MainWindow::openSettings); @@ -21,26 +27,25 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { main_layout->addWidget(settingsWindow); QObject::connect(settingsWindow, &SettingsWindow::closeSettings, this, &MainWindow::closeSettings); QObject::connect(&qs, &QUIState::offroadTransition, settingsWindow, &SettingsWindow::offroadTransition); - QObject::connect(settingsWindow, &SettingsWindow::reviewTrainingGuide, this, &MainWindow::reviewTrainingGuide); + QObject::connect(settingsWindow, &SettingsWindow::reviewTrainingGuide, [=]() { + main_layout->setCurrentWidget(onboardingWindow); + }); QObject::connect(settingsWindow, &SettingsWindow::showDriverView, [=] { homeWindow->showDriverView(true); }); - onboardingWindow = new OnboardingWindow(this); - onboardingDone = onboardingWindow->isOnboardingDone(); - main_layout->addWidget(onboardingWindow); - - main_layout->setCurrentWidget(onboardingWindow); - QObject::connect(onboardingWindow, &OnboardingWindow::onboardingDone, [=]() { - onboardingDone = true; - closeSettings(); - }); - onboardingWindow->updateActiveScreen(); - device.setAwake(true, true); QObject::connect(&qs, &QUIState::uiUpdate, &device, &Device::update); - QObject::connect(&qs, &QUIState::offroadTransition, this, &MainWindow::offroadTransition); - QObject::connect(&device, &Device::displayPowerChanged, this, &MainWindow::closeSettings); + QObject::connect(&qs, &QUIState::offroadTransition, [=](bool offroad) { + if (!offroad) { + closeSettings(); + } + }); + QObject::connect(&device, &Device::displayPowerChanged, [=]() { + if(main_layout->currentWidget() != onboardingWindow) { + closeSettings(); + } + }); // load fonts QFontDatabase::addApplicationFont("../assets/fonts/opensans_regular.ttf"); @@ -56,26 +61,12 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { )"); } -void MainWindow::offroadTransition(bool offroad) { - if(!offroad) { - closeSettings(); - } -} - void MainWindow::openSettings() { main_layout->setCurrentWidget(settingsWindow); } void MainWindow::closeSettings() { - if(onboardingDone) { - main_layout->setCurrentWidget(homeWindow); - } -} - -void MainWindow::reviewTrainingGuide() { - onboardingDone = false; - main_layout->setCurrentWidget(onboardingWindow); - onboardingWindow->updateActiveScreen(); + main_layout->setCurrentWidget(homeWindow); } bool MainWindow::eventFilter(QObject *obj, QEvent *event) { diff --git a/selfdrive/ui/qt/window.h b/selfdrive/ui/qt/window.h index 5a40e94bb2..069831cffe 100644 --- a/selfdrive/ui/qt/window.h +++ b/selfdrive/ui/qt/window.h @@ -6,18 +6,18 @@ #include "selfdrive/ui/qt/home.h" #include "selfdrive/ui/qt/offroad/onboarding.h" #include "selfdrive/ui/qt/offroad/settings.h" -#include "selfdrive/ui/ui.h" class MainWindow : public QWidget { Q_OBJECT -protected: - bool eventFilter(QObject *obj, QEvent *event) override; - public: explicit MainWindow(QWidget *parent = 0); private: + bool eventFilter(QObject *obj, QEvent *event) override; + void openSettings(); + void closeSettings(); + Device device; QUIState qs; @@ -25,11 +25,4 @@ private: HomeWindow *homeWindow; SettingsWindow *settingsWindow; OnboardingWindow *onboardingWindow; - bool onboardingDone = false; - -public slots: - void offroadTransition(bool offroad); - void openSettings(); - void closeSettings(); - void reviewTrainingGuide(); };