mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-08-08 17:55:39 +08:00
UI: update toggles on show (#21812)
This commit is contained in:
@@ -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 ¶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;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user