mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-21 07:13:53 +08:00
* new scroller and widget start heck yeah fix that clean up * fuck yeah * line sep * fix that * fix clicking on action * no custom width * move all over * clean up * more clean up * rm custom visible too * more clean up * lint * dont use enabled generically yet * ??
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
from openpilot.common.params import Params
|
|
from openpilot.system.ui.lib.application import gui_app
|
|
from openpilot.system.ui.lib.list_view import button_item, text_item
|
|
from openpilot.system.ui.lib.scroller import Scroller
|
|
from openpilot.system.ui.lib.widget import Widget, DialogResult
|
|
from openpilot.system.ui.widgets.confirm_dialog import confirm_dialog
|
|
|
|
|
|
class SoftwareLayout(Widget):
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
self._params = Params()
|
|
items = self._init_items()
|
|
self._scroller = Scroller(items, line_separator=True, spacing=0)
|
|
|
|
def _init_items(self):
|
|
items = [
|
|
text_item("Current Version", ""),
|
|
button_item("Download", "CHECK", callback=self._on_download_update),
|
|
button_item("Install Update", "INSTALL", callback=self._on_install_update),
|
|
button_item("Target Branch", "SELECT", callback=self._on_select_branch),
|
|
button_item("Uninstall", "UNINSTALL", callback=self._on_uninstall),
|
|
]
|
|
return items
|
|
|
|
def _render(self, rect):
|
|
self._scroller.render(rect)
|
|
|
|
def _on_download_update(self): pass
|
|
def _on_install_update(self): pass
|
|
def _on_select_branch(self): pass
|
|
|
|
def _on_uninstall(self):
|
|
def handle_uninstall_confirmation(result):
|
|
if result == DialogResult.CONFIRM:
|
|
self._params.put_bool("DoUninstall", True)
|
|
|
|
gui_app.set_modal_overlay(
|
|
lambda: confirm_dialog("Are you sure you want to uninstall?", "Uninstall"),
|
|
callback=handle_uninstall_confirmation,
|
|
)
|