mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-21 05:52:06 +08:00
disable buttons when onroad (#20475)
* disables reset calib * works for all buttons * naming convention + final works on PC * stylesheets + works on manager.py * fixing stylesheet * add that backg * no reviewing while onroad * better disabled hint * little cleanup Co-authored-by: Comma Device <device@comma.ai> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
@@ -82,45 +82,41 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
|
||||
|
||||
QString serial = QString::fromStdString(params.get("HardwareSerial", false));
|
||||
device_layout->addWidget(new LabelControl("Serial", serial));
|
||||
device_layout->addWidget(horizontal_line());
|
||||
|
||||
// offroad-only buttons
|
||||
QList<ButtonControl*> offroad_btns;
|
||||
|
||||
device_layout->addWidget(new ButtonControl("Driver Camera", "PREVIEW",
|
||||
"Preview the driver facing camera to help optimize device mounting position for best driver monitoring experience. (vehicle must be off)",
|
||||
[=]() { Params().write_db_value("IsDriverViewEnabled", "1", 1); }));
|
||||
offroad_btns.append(new ButtonControl("Driver Camera", "PREVIEW",
|
||||
"Preview the driver facing camera to help optimize device mounting position for best driver monitoring experience. (vehicle must be off)",
|
||||
[=]() { Params().write_db_value("IsDriverViewEnabled", "1", 1); }));
|
||||
|
||||
device_layout->addWidget(horizontal_line());
|
||||
offroad_btns.append(new ButtonControl("Reset Calibration", "RESET",
|
||||
"openpilot requires the device to be mounted within 4° left or right and within 5° up or down. openpilot is continuously calibrating, resetting is rarely required.", [=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to reset calibration?")) {
|
||||
Params().delete_db_value("CalibrationParams");
|
||||
}
|
||||
}));
|
||||
|
||||
// TODO: show current calibration values
|
||||
device_layout->addWidget(new ButtonControl("Reset Calibration", "RESET",
|
||||
"openpilot requires the device to be mounted within 4° left or right and within 5° up or down. openpilot is continuously calibrating, resetting is rarely required.",
|
||||
[=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to reset calibration?")) {
|
||||
Params().delete_db_value("CalibrationParams");
|
||||
}
|
||||
}));
|
||||
|
||||
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());
|
||||
offroad_btns.append(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();
|
||||
}
|
||||
}));
|
||||
|
||||
QString brand = params.read_db_bool("Passive") ? "dashcam" : "openpilot";
|
||||
device_layout->addWidget(new ButtonControl("Uninstall " + brand, "UNINSTALL",
|
||||
"",
|
||||
[=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to uninstall?")) {
|
||||
Params().write_db_value("DoUninstall", "1");
|
||||
}
|
||||
}));
|
||||
offroad_btns.append(new ButtonControl("Uninstall " + brand, "UNINSTALL", "", [=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to uninstall?")) {
|
||||
Params().write_db_value("DoUninstall", "1");
|
||||
}
|
||||
}));
|
||||
|
||||
for(auto &btn : offroad_btns){
|
||||
device_layout->addWidget(horizontal_line());
|
||||
QObject::connect(parent, SIGNAL(offroadTransitions(bool)), btn, SLOT(setEnabled(bool)));
|
||||
device_layout->addWidget(btn);
|
||||
}
|
||||
|
||||
// power buttons
|
||||
QHBoxLayout *power_layout = new QHBoxLayout();
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
|
||||
signals:
|
||||
void closeSettings();
|
||||
void offroadTransitions(bool offroad);
|
||||
void reviewTrainingGuide();
|
||||
|
||||
private:
|
||||
|
||||
@@ -53,12 +53,17 @@ public:
|
||||
ButtonControl(const QString &title, const QString &text, const QString &desc, Functor functor, const QString &icon = "", QWidget *parent = nullptr) : AbstractControl(title, desc, icon, parent) {
|
||||
btn.setText(text);
|
||||
btn.setStyleSheet(R"(
|
||||
padding: 0;
|
||||
border-radius: 50px;
|
||||
font-size: 35px;
|
||||
font-weight: 500;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
QPushButton {
|
||||
padding: 0;
|
||||
border-radius: 50px;
|
||||
font-size: 35px;
|
||||
font-weight: 500;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
color: #33E4E4E4;
|
||||
}
|
||||
)");
|
||||
btn.setFixedSize(250, 100);
|
||||
QObject::connect(&btn, &QPushButton::released, functor);
|
||||
@@ -66,6 +71,11 @@ public:
|
||||
}
|
||||
void setText(const QString &text) { btn.setText(text); }
|
||||
|
||||
public slots:
|
||||
void setEnabled(bool enabled) {
|
||||
btn.setEnabled(enabled);
|
||||
};
|
||||
|
||||
private:
|
||||
QPushButton btn;
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
|
||||
QObject::connect(homeWindow, SIGNAL(openSettings()), this, SLOT(openSettings()));
|
||||
QObject::connect(homeWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings()));
|
||||
QObject::connect(homeWindow, SIGNAL(offroadTransition(bool)), this, SLOT(offroadTransition(bool)));
|
||||
QObject::connect(homeWindow, SIGNAL(offroadTransition(bool)), settingsWindow, SIGNAL(offroadTransition(bool)));
|
||||
QObject::connect(settingsWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings()));
|
||||
QObject::connect(settingsWindow, SIGNAL(reviewTrainingGuide()), this, SLOT(reviewTrainingGuide()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user