ui: disable longitudinal personality settings when using stock long (#28443)

* disable longitdinal personality settings

* disable title label

* Revert "disable title label"

This reverts commit ef315ac277.

* gray checked button on disable
pull/28460/head
Dean Lee 2 years ago committed by GitHub
parent ff4aae85fe
commit 9295aca8ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      selfdrive/ui/qt/offroad/settings.cc
  2. 1
      selfdrive/ui/qt/offroad/settings.h
  3. 14
      selfdrive/ui/qt/widgets/controls.h

@ -91,7 +91,7 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
std::vector<QString> longi_button_texts{tr("Aggressive"), tr("Standard"), tr("Relaxed")};
ButtonParamControl* long_personality_setting = new ButtonParamControl("LongitudinalPersonality", tr("Driving Personality"),
long_personality_setting = new ButtonParamControl("LongitudinalPersonality", tr("Driving Personality"),
tr("Standard is recommended. In aggressive mode, openpilot will follow lead cars closer and be more aggressive with the gas and brake. In relaxed mode openpilot will stay further away from lead cars."),
"../assets/offroad/icon_speed_limit.png",
longi_button_texts);
@ -143,6 +143,7 @@ void TogglesPanel::updateToggles() {
.arg(tr("New Driving Visualization"))
.arg(tr("The driving visualization will transition to the road-facing wide-angle camera at low speeds to better show some turns. The Experimental mode logo will also be shown in the top right corner."));
long_personality_setting->setEnabled(false);
const bool is_release = params.getBool("IsReleaseBranch");
auto cp_bytes = params.get("CarParamsPersistent");
if (!cp_bytes.empty()) {
@ -161,6 +162,7 @@ void TogglesPanel::updateToggles() {
// normal description and toggle
e2e_toggle->setEnabled(true);
e2e_toggle->setDescription(e2e_description);
long_personality_setting->setEnabled(true);
} else {
// no long for now
e2e_toggle->setEnabled(false);

@ -64,6 +64,7 @@ public slots:
private:
Params params;
std::map<std::string, ParamControl*> toggles;
ButtonParamControl *long_personality_setting;
void updateToggles();
};

@ -216,14 +216,17 @@ public:
QPushButton:pressed {
background-color: #4a4a4a;
}
QPushButton:checked {
QPushButton:checked:enabled {
background-color: #33Ab4C;
}
QPushButton:disabled {
color: #33E4E4E4;
}
)";
key = param.toStdString();
int value = atoi(params.get(key).c_str());
QButtonGroup *button_group = new QButtonGroup(this);
button_group = new QButtonGroup(this);
button_group->setExclusive(true);
for (int i = 0; i < button_texts.size(); i++) {
QPushButton *button = new QPushButton(button_texts[i], this);
@ -242,9 +245,16 @@ public:
});
}
void setEnabled(bool enable) {
for (auto btn : button_group->buttons()) {
btn->setEnabled(enable);
}
}
private:
std::string key;
Params params;
QButtonGroup *button_group;
};
class ListWidget : public QWidget {

Loading…
Cancel
Save