From 91f190ecd3f8fe65ba9d705e1e48581ddddfcea4 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sat, 4 Jan 2025 10:19:07 -0500 Subject: [PATCH] more --- .../qt/offroad/settings/sunnypilot_panel.cc | 15 ++++++++++----- .../qt/offroad/settings/sunnypilot_panel.h | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/sunnypilot_panel.cc b/selfdrive/ui/sunnypilot/qt/offroad/settings/sunnypilot_panel.cc index eddc701f93..38b62a229f 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/settings/sunnypilot_panel.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/sunnypilot_panel.cc @@ -24,6 +24,7 @@ SunnypilotPanel::SunnypilotPanel(SettingsWindowSP *parent) : QFrame(parent) { tr("Modular Assistive Driving System (MADS)"), tr("Enable the beloved MADS feature. Disable toggle to revert back to stock openpilot engagement/disengagement."), ""); + madsToggle->setConfirmation(true, false); list->addItem(madsToggle); SubPanelButton *madsSettingsButton = new SubPanelButton(tr("Customize MADS")); @@ -32,6 +33,7 @@ SunnypilotPanel::SunnypilotPanel(SettingsWindowSP *parent) : QFrame(parent) { sunnypilotScroller->setLastScrollPosition(); main_layout->setCurrentWidget(madsWidget); }); + madsSettingsButton->setEnabled(madsToggle->isToggled()); madsWidget = new MadsSettings(this); connect(madsWidget, &MadsSettings::backPress, [=]() { @@ -40,6 +42,11 @@ SunnypilotPanel::SunnypilotPanel(SettingsWindowSP *parent) : QFrame(parent) { }); list->addItem(madsSettingsButton); + QObject::connect(madsToggle, &ToggleControl::toggleFlipped, [=](bool state) { + madsSettingsButton->setEnabled(state); + }); + QObject::connect(uiState(), &UIState::offroadTransition, this, &SunnypilotPanel::updateToggles); + sunnypilotScroller = new ScrollViewSP(list, this); vlayout->addWidget(sunnypilotScroller); vlayout->addStretch(1); @@ -66,15 +73,13 @@ SunnypilotPanel::SunnypilotPanel(SettingsWindowSP *parent) : QFrame(parent) { } void SunnypilotPanel::showEvent(QShowEvent *event) { - updateToggles(); + updateToggles(offroad); } void SunnypilotPanel::hideEvent(QHideEvent *event) { main_layout->setCurrentWidget(sunnypilotScreen); } -void SunnypilotPanel::updateToggles() { - if (!isVisible()) { - return; - } +void SunnypilotPanel::updateToggles(bool _offroad) { + offroad = _offroad; } diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/sunnypilot_panel.h b/selfdrive/ui/sunnypilot/qt/offroad/settings/sunnypilot_panel.h index edb145ca61..d6f1ea81fd 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/settings/sunnypilot_panel.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/sunnypilot_panel.h @@ -25,12 +25,13 @@ public: void hideEvent(QHideEvent* event) override; public slots: - void updateToggles(); + void updateToggles(bool _offroad); private: QStackedLayout* main_layout = nullptr; QWidget* sunnypilotScreen = nullptr; ScrollViewSP *sunnypilotScroller = nullptr; + bool offroad; ParamControl *madsToggle; MadsSettings *madsWidget = nullptr;