diff --git a/selfdrive/ui/qt/offroad/sunnypilot/visuals_settings.cc b/selfdrive/ui/qt/offroad/sunnypilot/visuals_settings.cc
index 6d2b1ebff6..46bd84b6d9 100644
--- a/selfdrive/ui/qt/offroad/sunnypilot/visuals_settings.cc
+++ b/selfdrive/ui/qt/offroad/sunnypilot/visuals_settings.cc
@@ -60,7 +60,7 @@ VisualsPanel::VisualsPanel(QWidget *parent) : ListWidget(parent) {
{
"MapboxFullScreen",
tr("Navigation: Display in Full Screen"),
- QString(tr("Enable this will display the built-in navigation in full screen.
To switch back to driving view, tap on the border edge.")),
+ tr("Enable this will display the built-in navigation in full screen.
To switch back to driving view, tap on the border edge."),
"../assets/offroad/icon_blank.png",
},
{
diff --git a/selfdrive/ui/qt/widgets/controls.h b/selfdrive/ui/qt/widgets/controls.h
index 860cb7ad2b..49e261f56c 100644
--- a/selfdrive/ui/qt/widgets/controls.h
+++ b/selfdrive/ui/qt/widgets/controls.h
@@ -243,7 +243,7 @@ class ButtonParamControl : public SPAbstractControl {
Q_OBJECT
public:
ButtonParamControl(const QString ¶m, const QString &title, const QString &desc, const QString &icon,
- const std::vector &button_texts, const int minimum_button_width = 300) : SPAbstractControl(title, desc, icon) {
+ const std::vector &button_texts, const int minimum_button_width = 300) : SPAbstractControl(title, desc, icon), button_texts(button_texts) {
const QString style = R"(
QPushButton {
border-radius: 20px;
@@ -306,6 +306,14 @@ public:
void refresh() {
int value = atoi(params.get(key).c_str());
+
+ if (value >= button_texts.size()) {
+ value = button_texts.size() - 1;
+ }
+ if (value < button_texts.size()) {
+ value = 0;
+ }
+
button_group->button(value)->setChecked(true);
}
@@ -357,6 +365,7 @@ private:
std::string key;
Params params;
QButtonGroup *button_group;
+ std::vector button_texts;
bool button_group_enabled = true;
};