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>
old-commit-hash: d63dab950a
commatwo_master
iejMac 4 years ago committed by GitHub
parent c5194fcb85
commit 4a3e73ddb5
  1. 62
      selfdrive/ui/qt/offroad/settings.cc
  2. 1
      selfdrive/ui/qt/offroad/settings.hpp
  3. 22
      selfdrive/ui/qt/widgets/controls.hpp
  4. 1
      selfdrive/ui/qt/window.cc

@ -82,45 +82,41 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
QString serial = QString::fromStdString(params.get("HardwareSerial", false)); QString serial = QString::fromStdString(params.get("HardwareSerial", false));
device_layout->addWidget(new LabelControl("Serial", serial)); device_layout->addWidget(new LabelControl("Serial", serial));
device_layout->addWidget(horizontal_line());
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); }));
device_layout->addWidget(horizontal_line()); // offroad-only buttons
QList<ButtonControl*> offroad_btns;
// 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()); 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(new ButtonControl("Review Training Guide", "REVIEW", offroad_btns.append(new ButtonControl("Reset Calibration", "RESET",
"Review the rules, features, and limitations of openpilot", "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?")) {
if (ConfirmationDialog::confirm("Are you sure you want to review the training guide?")) { Params().delete_db_value("CalibrationParams");
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"; QString brand = params.read_db_bool("Passive") ? "dashcam" : "openpilot";
device_layout->addWidget(new ButtonControl("Uninstall " + brand, "UNINSTALL", offroad_btns.append(new ButtonControl("Uninstall " + brand, "UNINSTALL", "", [=]() {
"", if (ConfirmationDialog::confirm("Are you sure you want to uninstall?")) {
[=]() { Params().write_db_value("DoUninstall", "1");
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 // power buttons
QHBoxLayout *power_layout = new QHBoxLayout(); QHBoxLayout *power_layout = new QHBoxLayout();

@ -39,6 +39,7 @@ public:
signals: signals:
void closeSettings(); void closeSettings();
void offroadTransitions(bool offroad);
void reviewTrainingGuide(); void reviewTrainingGuide();
private: 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) { 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.setText(text);
btn.setStyleSheet(R"( btn.setStyleSheet(R"(
padding: 0; QPushButton {
border-radius: 50px; padding: 0;
font-size: 35px; border-radius: 50px;
font-weight: 500; font-size: 35px;
color: #E4E4E4; font-weight: 500;
background-color: #393939; color: #E4E4E4;
background-color: #393939;
}
QPushButton:disabled {
color: #33E4E4E4;
}
)"); )");
btn.setFixedSize(250, 100); btn.setFixedSize(250, 100);
QObject::connect(&btn, &QPushButton::released, functor); QObject::connect(&btn, &QPushButton::released, functor);
@ -66,6 +71,11 @@ public:
} }
void setText(const QString &text) { btn.setText(text); } void setText(const QString &text) { btn.setText(text); }
public slots:
void setEnabled(bool enabled) {
btn.setEnabled(enabled);
};
private: private:
QPushButton btn; QPushButton btn;
}; };

@ -17,6 +17,7 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
QObject::connect(homeWindow, SIGNAL(openSettings()), this, SLOT(openSettings())); QObject::connect(homeWindow, SIGNAL(openSettings()), this, SLOT(openSettings()));
QObject::connect(homeWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings())); QObject::connect(homeWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings()));
QObject::connect(homeWindow, SIGNAL(offroadTransition(bool)), this, SLOT(offroadTransition(bool))); 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(closeSettings()), this, SLOT(closeSettings()));
QObject::connect(settingsWindow, SIGNAL(reviewTrainingGuide()), this, SLOT(reviewTrainingGuide())); QObject::connect(settingsWindow, SIGNAL(reviewTrainingGuide()), this, SLOT(reviewTrainingGuide()));

Loading…
Cancel
Save