mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-05 08:16:03 +08:00
ui: support selected button enabled for ButtonParamControlSP (#937)
ui: support specific button enabled selections for `ButtonParamControlSP` Replaced setDisabledSelectedButton with setEnableSelectedButtons for improved flexibility. The new implementation allows enabling multiple buttons based on a given list and maintains clarity in handling button states. This enhances functionality and aligns with better code practices.
This commit is contained in:
@@ -324,10 +324,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void setDisabledSelectedButton(std::string val) {
|
||||
int value = atoi(val.c_str());
|
||||
void setEnableSelectedButtons(bool enable, const std::vector<int>& enabled_btns = {}) const {
|
||||
for (int i = 0; i < button_group->buttons().size(); i++) {
|
||||
button_group->buttons()[i]->setEnabled(i != value);
|
||||
// Enable the button if its index is in the enabled list
|
||||
bool should_enable = std::find(enabled_btns.begin(), enabled_btns.end(), i) != enabled_btns.end();
|
||||
button_group->buttons()[i]->setEnabled(enable && should_enable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user