do this instead, and flip the logics

This commit is contained in:
Jason Wen
2024-04-18 17:06:41 -04:00
parent 4abdf85dd1
commit c0f46cd44a
2 changed files with 9 additions and 15 deletions
+9 -12
View File
@@ -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) {
-3
View File
@@ -76,9 +76,6 @@ private:
QFileSystemWatcher *fs_watch;
QPushButton *offroad_btn;
protected:
bool is_onroad = false;
};
class TogglesPanel : public ListWidget {