This commit is contained in:
royjr
2026-09-06 21:26:26 -04:00
parent 6135084c94
commit a26939ea86
@@ -4,6 +4,8 @@ Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
from collections.abc import Callable
from openpilot.selfdrive.ui.mici.layouts.settings import settings as OP
from openpilot.selfdrive.ui.mici.layouts.settings.settings import SettingsBigButton
from openpilot.selfdrive.ui.mici.layouts.settings.device import DeviceLayoutMici
@@ -29,6 +31,17 @@ class SunnylinkBigButton(SettingsBigButton):
return 56
class AlwaysOffroadDisengageDialog(BigDialog):
def __init__(self, callback: Callable[[], None]):
super().__init__(tr("disengage to enable always offroad"), "")
self._disengaged_callback = callback
def _update_state(self):
super()._update_state()
if not ui_state.engaged and not self.is_dismissing:
self.dismiss(self._disengaged_callback)
class SettingsLayoutSP(OP.SettingsLayout):
def __init__(self):
OP.SettingsLayout.__init__(self)
@@ -94,7 +107,7 @@ class SettingsLayoutSP(OP.SettingsLayout):
confirm_callback=lambda: _set_offroad_status(False))
else:
if ui_state.engaged:
gui_app.push_widget(BigDialog(tr("disengage to enable always offroad"), "", ))
gui_app.push_widget(AlwaysOffroadDisengageDialog(lambda: self._handle_always_offroad(True)))
return
dlg = BigConfirmationDialog(tr("slide to force offroad"), self.icon_offroad_slider, red=True,