UI: fix power buttons disable logic (#23774)

old-commit-hash: 00d469dbc9
taco
Adeeb Shihadeh 3 years ago committed by GitHub
parent 66473b54b2
commit b695ffbfdb
  1. 4
      selfdrive/ui/qt/offroad/settings.cc
  2. 3
      selfdrive/ui/ui.h

@ -196,7 +196,7 @@ void DevicePanel::updateCalibDescription() {
} }
void DevicePanel::reboot() { void DevicePanel::reboot() {
if (uiState()->status == UIStatus::STATUS_DISENGAGED) { if (!uiState()->engaged()) {
if (ConfirmationDialog::confirm("Are you sure you want to reboot?", this)) { if (ConfirmationDialog::confirm("Are you sure you want to reboot?", this)) {
// Check engaged again in case it changed while the dialog was open // Check engaged again in case it changed while the dialog was open
if (uiState()->status == UIStatus::STATUS_DISENGAGED) { if (uiState()->status == UIStatus::STATUS_DISENGAGED) {
@ -209,7 +209,7 @@ void DevicePanel::reboot() {
} }
void DevicePanel::poweroff() { void DevicePanel::poweroff() {
if (uiState()->status == UIStatus::STATUS_DISENGAGED) { if (!uiState()->engaged()) {
if (ConfirmationDialog::confirm("Are you sure you want to power off?", this)) { if (ConfirmationDialog::confirm("Are you sure you want to power off?", this)) {
// Check engaged again in case it changed while the dialog was open // Check engaged again in case it changed while the dialog was open
if (uiState()->status == UIStatus::STATUS_DISENGAGED) { if (uiState()->status == UIStatus::STATUS_DISENGAGED) {

@ -118,6 +118,9 @@ public:
inline bool worldObjectsVisible() const { inline bool worldObjectsVisible() const {
return sm->rcv_frame("liveCalibration") > scene.started_frame; return sm->rcv_frame("liveCalibration") > scene.started_frame;
}; };
inline bool engaged() const {
return scene.started && (*sm)["controlsState"].getControlsState().getEnabled();
};
int fb_w = 0, fb_h = 0; int fb_w = 0, fb_h = 0;

Loading…
Cancel
Save