From c0f46cd44ad2ee61d8471e616597607d7d5cbb51 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Thu, 18 Apr 2024 17:06:41 -0400 Subject: [PATCH] do this instead, and flip the logics --- selfdrive/ui/qt/offroad/settings.cc | 21 +++++++++------------ selfdrive/ui/qt/offroad/settings.h | 3 --- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index f43c92d3a0..7a265cb797 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -420,11 +420,6 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) { #offroad_btn:pressed { background-color: #4a4a4a; } )"); - connect(uiState(), &UIState::offroadTransition, [=](bool offroad) { - is_onroad = !offroad; - updateLabels(); - }); - updateLabels(); } @@ -502,22 +497,24 @@ void DevicePanel::poweroff() { void DevicePanel::forceoffroad() { if (!uiState()->engaged()) { - if (is_onroad) { - if (ConfirmationDialog::confirm(tr("Are you sure you want to force offroad?"), tr("Force"), this)) { - if (!uiState()->engaged()) { - params.putBool("ForceOffroad", true); - } - } - } else { + if (params.getBool("ForceOffroad")) { if (ConfirmationDialog::confirm(tr("Are you sure you want to unforce offroad?"), tr("Unforce"), this)) { if (!uiState()->engaged()) { params.remove("ForceOffroad"); } } + } else { + if (ConfirmationDialog::confirm(tr("Are you sure you want to force offroad?"), tr("Force"), this)) { + if (!uiState()->engaged()) { + params.putBool("ForceOffroad", true); + } + } } } else { ConfirmationDialog::alert(tr("Disengage to Force Offroad"), this); } + + updateLabels(); } void DevicePanel::showEvent(QShowEvent *event) { diff --git a/selfdrive/ui/qt/offroad/settings.h b/selfdrive/ui/qt/offroad/settings.h index 8ea7835b37..a29dda8ffc 100644 --- a/selfdrive/ui/qt/offroad/settings.h +++ b/selfdrive/ui/qt/offroad/settings.h @@ -76,9 +76,6 @@ private: QFileSystemWatcher *fs_watch; QPushButton *offroad_btn; - -protected: - bool is_onroad = false; }; class TogglesPanel : public ListWidget {