mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-16 08:42:07 +08:00
more
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user