diff --git a/selfdrive/ui/qt/offroad/onboarding.cc b/selfdrive/ui/qt/offroad/onboarding.cc index 7c2be2e163..3b6b32c608 100644 --- a/selfdrive/ui/qt/offroad/onboarding.cc +++ b/selfdrive/ui/qt/offroad/onboarding.cc @@ -1,12 +1,8 @@ #include -#include #include -#include -#include -#include #include -#include #include +#include #include #include "common/params.h" @@ -31,14 +27,14 @@ void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) { if (currentIndex >= boundingBox.size()) { emit completedTraining(); - return; } else { image.load("../assets/training/step" + QString::number(currentIndex) + ".jpg"); update(); } } -TrainingGuide::TrainingGuide(QWidget* parent) : QFrame(parent){ +void TrainingGuide::showEvent(QShowEvent *event) { + currentIndex = 0; image.load("../assets/training/step0.jpg"); } @@ -143,6 +139,7 @@ OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) { }); addWidget(tr); + setStyleSheet(R"( * { color: white; diff --git a/selfdrive/ui/qt/offroad/onboarding.hpp b/selfdrive/ui/qt/offroad/onboarding.hpp index 998efde3bf..9ff0b1111b 100644 --- a/selfdrive/ui/qt/offroad/onboarding.hpp +++ b/selfdrive/ui/qt/offroad/onboarding.hpp @@ -13,17 +13,19 @@ class TrainingGuide : public QFrame { Q_OBJECT public: - explicit TrainingGuide(QWidget *parent = 0); + explicit TrainingGuide(QWidget *parent = 0) : QFrame(parent) {}; protected: - void mouseReleaseEvent(QMouseEvent* e) override; + void showEvent(QShowEvent *event) override; void paintEvent(QPaintEvent *event) override; + void mouseReleaseEvent(QMouseEvent* e) override; private: - int currentIndex = 0; QImage image; + int currentIndex = 0; - // Vector of bounding boxes for the a given training guide step. (minx, maxx, miny, maxy) + // Bounding boxes for the a given training guide step + // (minx, maxx, miny, maxy) QVector> boundingBox {{250, 930, 750, 900}, {280, 1280, 650, 950}, {330, 1130, 590, 900}, {910, 1580, 500, 1000}, {1180, 1300, 630, 720}, {290, 1050, 590, 960}, {1090, 1240, 550, 660}, {1050, 1580, 250, 900}, {320, 1130, 670, 1020}, {1010, 1580, 410, 750}, {1040, 1500, 230, 1030}, {300, 1190, 590, 920}, {1050, 1310, 170, 870}, {950, 1530, 460, 770}, {190, 970, 750, 970}}; @@ -61,6 +63,7 @@ private: 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 e6f2fed7f9..d472911bff 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -110,6 +110,17 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) { device_layout->addWidget(horizontal_line()); + device_layout->addWidget(new ButtonControl("Review Training Guide", "REVIEW", + "Review the rules, features, and limitations of openpilot", + [=]() { + if (ConfirmationDialog::confirm("Are you sure you want to review the training guide?")) { + Params().delete_db_value("CompletedTrainingVersion"); + emit reviewTrainingGuide(); + } + })); + + device_layout->addWidget(horizontal_line()); + QString brand = params.read_db_bool("Passive") ? "dashcam" : "openpilot"; device_layout->addWidget(new ButtonControl("Uninstall " + brand, "UNINSTALL", "", @@ -246,8 +257,11 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { QObject::connect(close_btn, SIGNAL(released()), this, SIGNAL(closeSettings())); // setup panels + DevicePanel *device = new DevicePanel(this); + QObject::connect(device, SIGNAL(reviewTrainingGuide()), this, SIGNAL(reviewTrainingGuide())); + QPair panels[] = { - {"Device", new DevicePanel(this)}, + {"Device", device}, {"Network", network_panel(this)}, {"Toggles", toggles_panel()}, {"Developer", new DeveloperPanel()}, diff --git a/selfdrive/ui/qt/offroad/settings.hpp b/selfdrive/ui/qt/offroad/settings.hpp index 9c6fe9840d..1a26293116 100644 --- a/selfdrive/ui/qt/offroad/settings.hpp +++ b/selfdrive/ui/qt/offroad/settings.hpp @@ -17,6 +17,8 @@ class DevicePanel : public QWidget { Q_OBJECT public: explicit DevicePanel(QWidget* parent = nullptr); +signals: + void reviewTrainingGuide(); }; class DeveloperPanel : public QFrame { @@ -37,6 +39,7 @@ public: signals: void closeSettings(); + void reviewTrainingGuide(); private: QPushButton *sidebar_alert_widget; diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index a9cd9a647b..0a783b57b8 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -17,6 +17,7 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { QObject::connect(homeWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings())); QObject::connect(homeWindow, SIGNAL(offroadTransition(bool)), this, SLOT(offroadTransition(bool))); QObject::connect(settingsWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings())); + QObject::connect(settingsWindow, SIGNAL(reviewTrainingGuide()), this, SLOT(reviewTrainingGuide())); // start at onboarding main_layout->setCurrentWidget(onboardingWindow); @@ -47,6 +48,11 @@ void MainWindow::closeSettings() { main_layout->setCurrentWidget(homeWindow); } +void MainWindow::reviewTrainingGuide() { + main_layout->setCurrentWidget(onboardingWindow); + onboardingWindow->updateActiveScreen(); +} + bool MainWindow::eventFilter(QObject *obj, QEvent *event){ if (event->type() == QEvent::MouseButtonPress) { homeWindow->glWindow->wake(); diff --git a/selfdrive/ui/qt/window.hpp b/selfdrive/ui/qt/window.hpp index 2c61ac07c3..37cc70722d 100644 --- a/selfdrive/ui/qt/window.hpp +++ b/selfdrive/ui/qt/window.hpp @@ -26,4 +26,5 @@ public slots: void offroadTransition(bool offroad); void openSettings(); void closeSettings(); + void reviewTrainingGuide(); };