diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 8e663c0f1a..abe2c02389 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -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()); - - - 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()); - - // 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"); - } - })); + // offroad-only buttons + QList offroad_btns; - 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", - "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(); - } - })); + 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"); + } + })); - 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(); diff --git a/selfdrive/ui/qt/offroad/settings.hpp b/selfdrive/ui/qt/offroad/settings.hpp index 1a26293116..d1719b646c 100644 --- a/selfdrive/ui/qt/offroad/settings.hpp +++ b/selfdrive/ui/qt/offroad/settings.hpp @@ -39,6 +39,7 @@ public: signals: void closeSettings(); + void offroadTransitions(bool offroad); void reviewTrainingGuide(); private: diff --git a/selfdrive/ui/qt/widgets/controls.hpp b/selfdrive/ui/qt/widgets/controls.hpp index 6066159ef2..3f048c4bba 100644 --- a/selfdrive/ui/qt/widgets/controls.hpp +++ b/selfdrive/ui/qt/widgets/controls.hpp @@ -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; }; diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 5205acdb99..c88a47dd94 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(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()));