some more with interactions

This commit is contained in:
Jason Wen
2025-01-04 10:33:01 -05:00
parent 91f190ecd3
commit 54753e09fc
2 changed files with 9 additions and 3 deletions
@@ -34,6 +34,7 @@ SunnypilotPanel::SunnypilotPanel(SettingsWindowSP *parent) : QFrame(parent) {
main_layout->setCurrentWidget(madsWidget);
});
madsSettingsButton->setEnabled(madsToggle->isToggled());
QObject::connect(madsToggle, &ToggleControl::toggleFlipped, madsSettingsButton, &SubPanelButton::setEnabled);
madsWidget = new MadsSettings(this);
connect(madsWidget, &MadsSettings::backPress, [=]() {
@@ -42,9 +43,9 @@ SunnypilotPanel::SunnypilotPanel(SettingsWindowSP *parent) : QFrame(parent) {
});
list->addItem(madsSettingsButton);
QObject::connect(madsToggle, &ToggleControl::toggleFlipped, [=](bool state) {
madsSettingsButton->setEnabled(state);
});
toggleOffroadOnly = {
madsToggle,
};
QObject::connect(uiState(), &UIState::offroadTransition, this, &SunnypilotPanel::updateToggles);
sunnypilotScroller = new ScrollViewSP(list, this);
@@ -81,5 +82,9 @@ void SunnypilotPanel::hideEvent(QHideEvent *event) {
}
void SunnypilotPanel::updateToggles(bool _offroad) {
for (auto *toggle : toggleOffroadOnly) {
toggle->setEnabled(_offroad);
}
offroad = _offroad;
}
@@ -31,6 +31,7 @@ private:
QStackedLayout* main_layout = nullptr;
QWidget* sunnypilotScreen = nullptr;
ScrollViewSP *sunnypilotScroller = nullptr;
std::vector<ParamControl *> toggleOffroadOnly;
bool offroad;
ParamControl *madsToggle;