UI: fix power buttons disable logic (#23774)

pull/23779/head
Adeeb Shihadeh 2022-02-15 16:18:09 -08:00 committed by GitHub
parent bdf4245e00
commit 00d469dbc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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) {
@ -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) {

View File

@ -118,6 +118,9 @@ public:
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;