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",
"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",

@ -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;
};

@ -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);
}

Loading…
Cancel
Save