ui: encapsulate always enabled buttons into a list in Device panel (#900)

* fix style handling

* vector them

* another pr

---------

Co-authored-by: nayan8teen <nayan8teen@gmail.com>
This commit is contained in:
Jason Wen
2025-05-09 22:40:23 -04:00
committed by GitHub
parent e5ac7d5b57
commit f4c7b04682
@@ -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<PushButtonSP*>()) {
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);
}
}