UI: update toggles on show (#21812)

pull/21813/head
Adeeb Shihadeh 4 years ago committed by GitHub
parent 15d6bbb47c
commit 0ffe920a86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      selfdrive/ui/qt/offroad/settings.cc
  2. 13
      selfdrive/ui/qt/widgets/controls.h
  3. 4
      selfdrive/ui/qt/widgets/toggle.cc

@ -63,15 +63,15 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
ParamControl *record_toggle = new ParamControl("RecordFront", ParamControl *record_toggle = new ParamControl("RecordFront",
"Record and Upload Driver Camera", "Record and Upload Driver Camera",
"Upload data from the driver facing camera and help improve the driver monitoring algorithm.", "Upload data from the driver facing camera and help improve the driver monitoring algorithm.",
"../assets/offroad/icon_monitoring.png", "../assets/offroad/icon_monitoring.png",
this); this);
toggles.append(record_toggle); toggles.append(record_toggle);
toggles.append(new ParamControl("EndToEndToggle", toggles.append(new ParamControl("EndToEndToggle",
"\U0001f96c Disable use of lanelines (Alpha) \U0001f96c", "\U0001f96c Disable use of lanelines (Alpha) \U0001f96c",
"In this mode openpilot will ignore lanelines and just drive how it thinks a human would.", "In this mode openpilot will ignore lanelines and just drive how it thinks a human would.",
"../assets/offroad/icon_road.png", "../assets/offroad/icon_road.png",
this)); this));
#ifdef ENABLE_MAPS #ifdef ENABLE_MAPS
toggles.append(new ParamControl("NavSettingTime24h", toggles.append(new ParamControl("NavSettingTime24h",

@ -112,14 +112,19 @@ class ParamControl : public ToggleControl {
public: public:
ParamControl(const QString &param, const QString &title, const QString &desc, const QString &icon, QWidget *parent = nullptr) : ToggleControl(title, desc, icon, false, parent) { 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())) { key = param.toStdString();
toggle.togglePosition();
}
QObject::connect(this, &ToggleControl::toggleFlipped, [=](bool state) { 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: private:
std::string key;
Params params; Params params;
}; };

@ -73,10 +73,10 @@ bool Toggle::getEnabled() {
void Toggle::setEnabled(bool value) { void Toggle::setEnabled(bool value) {
enabled = value; enabled = value;
if(value) { if (value) {
circleColor.setRgb(0xfafafa); circleColor.setRgb(0xfafafa);
green.setRgb(0x33ab4c); green.setRgb(0x33ab4c);
}else{ } else {
circleColor.setRgb(0x888888); circleColor.setRgb(0x888888);
green.setRgb(0x227722); green.setRgb(0x227722);
} }

Loading…
Cancel
Save