diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 98daa6a764..427aa52de6 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -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", diff --git a/selfdrive/ui/qt/widgets/controls.h b/selfdrive/ui/qt/widgets/controls.h index 7df1c06d4d..f2192396b8 100644 --- a/selfdrive/ui/qt/widgets/controls.h +++ b/selfdrive/ui/qt/widgets/controls.h @@ -112,14 +112,19 @@ class ParamControl : public ToggleControl { public: ParamControl(const QString ¶m, 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; }; diff --git a/selfdrive/ui/qt/widgets/toggle.cc b/selfdrive/ui/qt/widgets/toggle.cc index e909180d15..82302ad5bc 100644 --- a/selfdrive/ui/qt/widgets/toggle.cc +++ b/selfdrive/ui/qt/widgets/toggle.cc @@ -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); }