From a867dea6810ffd74bf68142e631a091bf0e76a4b Mon Sep 17 00:00:00 2001 From: Nayan Date: Tue, 15 Apr 2025 12:12:08 -0400 Subject: [PATCH] UI: Bugfix Max Time Offroad (#820) bugfixes Co-authored-by: Discountchubbs <159560811+Discountchubbs@users.noreply.github.com> --- selfdrive/ui/sunnypilot/qt/widgets/controls.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/sunnypilot/qt/widgets/controls.h b/selfdrive/ui/sunnypilot/qt/widgets/controls.h index bb3cec88f9..d1edaf8621 100644 --- a/selfdrive/ui/sunnypilot/qt/widgets/controls.h +++ b/selfdrive/ui/sunnypilot/qt/widgets/controls.h @@ -418,12 +418,12 @@ class OptionControlSP : public AbstractControlSP_SELECTOR { private: bool isInlineLayout; QHBoxLayout *optionSelectorLayout = isInlineLayout ? new QHBoxLayout() : hlayout; - + struct MinMaxValue { int min_value; int max_value; }; - + int getParamValue() { const auto param_value = QString::fromStdString(params.get(key)); const auto result = valueMap != nullptr ? valueMap->key(param_value) : param_value; @@ -490,6 +490,8 @@ public: if (i == 0) { optionSelectorLayout->addWidget(&label, 0, Qt::AlignCenter); } + button->setEnabled((i == 0) ? !(value <= range.min_value) : !(value >= range.max_value)); + button->setFocusPolicy(Qt::NoFocus); // This prevents unintended scroll due to loss of focus when the button gets disabled based on min/max values button_group->addButton(button, i); QObject::connect(button, &QPushButton::clicked, [=]() {