From bc67effb6d710e90c0dce9e25fd6b6d728065515 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Mon, 20 Jan 2025 16:04:56 -0500 Subject: [PATCH] ui: Keep power buttons clickable while onroad (#601) --- .../qt/offroad/settings/device_panel.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc index 25bce83e4..89fe0bacf 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc @@ -74,23 +74,17 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) { addItem(device_grid_layout); - QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) { - for (auto btn : findChildren()) { - btn->setEnabled(offroad); - } - }); - // offroad mode and power buttons QHBoxLayout *power_layout = new QHBoxLayout(); power_layout->setSpacing(5); - QPushButton *rebootBtn = new PushButtonSP(tr("Reboot"), 720, this); + PushButtonSP *rebootBtn = new PushButtonSP(tr("Reboot"), 720, this); rebootBtn->setStyleSheet(rebootButtonStyle); power_layout->addWidget(rebootBtn); QObject::connect(rebootBtn, &PushButtonSP::clicked, this, &DevicePanelSP::reboot); - QPushButton *poweroffBtn = new PushButtonSP(tr("Power Off"), 720, this); + PushButtonSP *poweroffBtn = new PushButtonSP(tr("Power Off"), 720, this); poweroffBtn->setStyleSheet(powerOffButtonStyle); power_layout->addWidget(poweroffBtn); QObject::connect(poweroffBtn, &PushButtonSP::clicked, this, &DevicePanelSP::poweroff); @@ -100,4 +94,12 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) { } addItem(power_layout); + + QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) { + for (auto btn : findChildren()) { + if (btn != rebootBtn && btn != poweroffBtn) { + btn->setEnabled(offroad); + } + } + }); }