From f4c7b04682fca619d630546903949764093106d9 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Fri, 9 May 2025 22:40:23 -0400 Subject: [PATCH] ui: encapsulate always enabled buttons into a list in Device panel (#900) * fix style handling * vector them * another pr --------- Co-authored-by: nayan8teen --- .../ui/sunnypilot/qt/offroad/settings/device_panel.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc index 3e613e1022..70ead6e282 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc @@ -112,9 +112,17 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) { addItem(power_group_layout); + std::vector always_enabled_btns = { + rebootBtn, + poweroffBtn, + offroadBtn, + }; + QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) { for (auto btn : findChildren()) { - if (btn != rebootBtn && btn != poweroffBtn && btn != offroadBtn) { + bool always_enabled = std::find(always_enabled_btns.begin(), always_enabled_btns.end(), btn) != always_enabled_btns.end(); + + if (!always_enabled) { btn->setEnabled(offroad); } }