wip
This commit is contained in:
29
selfdrive/ui/qt/widgets/controls.h
Executable file → Normal file
29
selfdrive/ui/qt/widgets/controls.h
Executable file → Normal 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;
|
||||
|
||||
Reference in New Issue
Block a user