UI: update toggles on show (#21812)

This commit is contained in:
Adeeb Shihadeh
2021-07-30 16:21:42 -07:00
committed by GitHub
parent 15d6bbb47c
commit 0ffe920a86
3 changed files with 18 additions and 13 deletions
+7 -7
View File
@@ -63,15 +63,15 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
ParamControl *record_toggle = new ParamControl("RecordFront",
"Record and Upload Driver Camera",
"Upload data from the driver facing camera and help improve the driver monitoring algorithm.",
"../assets/offroad/icon_monitoring.png",
this);
"Upload data from the driver facing camera and help improve the driver monitoring algorithm.",
"../assets/offroad/icon_monitoring.png",
this);
toggles.append(record_toggle);
toggles.append(new ParamControl("EndToEndToggle",
"\U0001f96c Disable use of lanelines (Alpha) \U0001f96c",
"In this mode openpilot will ignore lanelines and just drive how it thinks a human would.",
"../assets/offroad/icon_road.png",
this));
"\U0001f96c Disable use of lanelines (Alpha) \U0001f96c",
"In this mode openpilot will ignore lanelines and just drive how it thinks a human would.",
"../assets/offroad/icon_road.png",
this));
#ifdef ENABLE_MAPS
toggles.append(new ParamControl("NavSettingTime24h",
+9 -4
View File
@@ -112,14 +112,19 @@ class ParamControl : public ToggleControl {
public:
ParamControl(const QString &param, const QString &title, const QString &desc, const QString &icon, QWidget *parent = nullptr) : ToggleControl(title, desc, icon, false, parent) {
if (params.getBool(param.toStdString().c_str())) {
toggle.togglePosition();
}
key = param.toStdString();
QObject::connect(this, &ToggleControl::toggleFlipped, [=](bool state) {
params.putBool(param.toStdString().c_str(), state);
params.putBool(key, state);
});
}
void showEvent(QShowEvent *event) override {
if (params.getBool(key) != toggle.on) {
toggle.togglePosition();
}
};
private:
std::string key;
Params params;
};
+2 -2
View File
@@ -73,10 +73,10 @@ bool Toggle::getEnabled() {
void Toggle::setEnabled(bool value) {
enabled = value;
if(value) {
if (value) {
circleColor.setRgb(0xfafafa);
green.setRgb(0x33ab4c);
}else{
} else {
circleColor.setRgb(0x888888);
green.setRgb(0x227722);
}