update mads settings button on show event

This commit is contained in:
Jason Wen
2025-01-04 20:19:46 -05:00
parent b8c0399ab7
commit efa9c321c2
2 changed files with 4 additions and 2 deletions
@@ -27,13 +27,12 @@ SunnypilotPanel::SunnypilotPanel(SettingsWindowSP *parent) : QFrame(parent) {
madsToggle->setConfirmation(true, false); madsToggle->setConfirmation(true, false);
list->addItem(madsToggle); list->addItem(madsToggle);
SubPanelButton *madsSettingsButton = new SubPanelButton(tr("Customize MADS")); madsSettingsButton = new SubPanelButton(tr("Customize MADS"));
madsSettingsButton->setObjectName("mads_btn"); madsSettingsButton->setObjectName("mads_btn");
connect(madsSettingsButton, &QPushButton::clicked, [=]() { connect(madsSettingsButton, &QPushButton::clicked, [=]() {
sunnypilotScroller->setLastScrollPosition(); sunnypilotScroller->setLastScrollPosition();
main_layout->setCurrentWidget(madsWidget); main_layout->setCurrentWidget(madsWidget);
}); });
madsSettingsButton->setEnabled(madsToggle->isToggled());
QObject::connect(madsToggle, &ToggleControl::toggleFlipped, madsSettingsButton, &SubPanelButton::setEnabled); QObject::connect(madsToggle, &ToggleControl::toggleFlipped, madsSettingsButton, &SubPanelButton::setEnabled);
madsWidget = new MadsSettings(this); madsWidget = new MadsSettings(this);
@@ -86,5 +85,7 @@ void SunnypilotPanel::updateToggles(bool _offroad) {
toggle->setEnabled(_offroad); toggle->setEnabled(_offroad);
} }
madsSettingsButton->setEnabled(madsToggle->isToggled());
offroad = _offroad; offroad = _offroad;
} }
@@ -35,5 +35,6 @@ private:
bool offroad; bool offroad;
ParamControl *madsToggle; ParamControl *madsToggle;
SubPanelButton *madsSettingsButton;
MadsSettings *madsWidget = nullptr; MadsSettings *madsWidget = nullptr;
}; };