Skip to content

Commit

Permalink
UI: fix power buttons disable logic (commaai#23774)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored Feb 16, 2022
1 parent bdf4245 commit 00d469d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions selfdrive/ui/qt/offroad/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void DevicePanel::updateCalibDescription() {
}

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

void DevicePanel::poweroff() {
if (uiState()->status == UIStatus::STATUS_DISENGAGED) {
if (!uiState()->engaged()) {
if (ConfirmationDialog::confirm("Are you sure you want to power off?", this)) {
// Check engaged again in case it changed while the dialog was open
if (uiState()->status == UIStatus::STATUS_DISENGAGED) {
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class UIState : public QObject {
inline bool worldObjectsVisible() const {
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;

Expand Down

0 comments on commit 00d469d

Please sign in to comment.