This commit is contained in:
Your Name
2024-04-27 13:43:16 -05:00
parent 21363ce751
commit ea1aad5ed1
128 changed files with 3533 additions and 1918 deletions

29
selfdrive/ui/qt/widgets/controls.h Executable file → Normal file
View File

@@ -127,15 +127,15 @@ public:
QObject::connect(&toggle, &Toggle::stateChanged, this, &ToggleControl::toggleFlipped);
}
void setVisualOn() {
toggle.togglePosition();
}
void setEnabled(bool enabled) {
toggle.setEnabled(enabled);
toggle.update();
}
void refresh() {
toggle.togglePosition();
}
signals:
void toggleFlipped(bool state);
@@ -206,7 +206,7 @@ public:
background-color: #4a4a4a;
}
QPushButton:checked:enabled {
background-color: #0048FF;
background-color: #33Ab4C;
}
QPushButton:disabled {
color: #33E4E4E4;
@@ -227,10 +227,8 @@ public:
button_group->addButton(button, i);
}
QObject::connect(button_group, QOverload<int, bool>::of(&QButtonGroup::buttonToggled), [=](int id, bool checked) {
if (checked) {
params.put(key, std::to_string(id));
}
QObject::connect(button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), [=](int id) {
params.put(key, std::to_string(id));
});
}
@@ -240,6 +238,19 @@ public:
}
}
void setCheckedButton(int id) {
button_group->button(id)->setChecked(true);
}
void refresh() {
int value = atoi(params.get(key).c_str());
button_group->button(value)->setChecked(true);
}
void showEvent(QShowEvent *event) override {
refresh();
}
private:
std::string key;
Params params;