mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-10 11:52:10 +08:00
review training guide button (#20466)
* works * move the param deletion * clean that up * Revert "move the param deletion" This reverts commit 31d8a65f004e7bcf14d29465a9c9d6db03e9dee7. * clean up Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Comma Device <device@comma.ai> old-commit-hash: 806226820cb76c83a33dc0f83cc4d67e8c657226
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
#include <QLabel>
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
#include <QScroller>
|
||||
#include <QScrollBar>
|
||||
#include <QGridLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickWidget>
|
||||
#include <QQmlContext>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -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<QVector<int>> 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();
|
||||
|
||||
@@ -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<QString, QWidget *> panels[] = {
|
||||
{"Device", new DevicePanel(this)},
|
||||
{"Device", device},
|
||||
{"Network", network_panel(this)},
|
||||
{"Toggles", toggles_panel()},
|
||||
{"Developer", new DeveloperPanel()},
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -26,4 +26,5 @@ public slots:
|
||||
void offroadTransition(bool offroad);
|
||||
void openSettings();
|
||||
void closeSettings();
|
||||
void reviewTrainingGuide();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user