mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-30 19:12:07 +08:00
BigUI WIP: Fix callbacks
This commit is contained in:
@@ -111,7 +111,7 @@ class StarPilotAdvancedLateralLayout(StarPilotPanel):
|
||||
self._params.put_bool(key, state)
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
if ui_state.started:
|
||||
dialog = ConfirmDialog(tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), on_close=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None)
|
||||
dialog = ConfirmDialog(tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), callback=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
class StarPilotAlwaysOnLateralLayout(StarPilotPanel):
|
||||
@@ -135,7 +135,7 @@ class StarPilotAlwaysOnLateralLayout(StarPilotPanel):
|
||||
self._params.put_bool(key, state)
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
if ui_state.started:
|
||||
gui_app.push_widget(ConfirmDialog(tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), on_close=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), callback=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None))
|
||||
|
||||
class StarPilotLaneChangesLayout(StarPilotPanel):
|
||||
def __init__(self):
|
||||
@@ -201,7 +201,7 @@ class StarPilotLateralTuneLayout(StarPilotPanel):
|
||||
self._params.put_bool(key, state)
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
if ui_state.started:
|
||||
gui_app.push_widget(ConfirmDialog(tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), on_close=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), callback=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None))
|
||||
|
||||
class StarPilotLateralQOLLayout(StarPilotPanel):
|
||||
def __init__(self):
|
||||
|
||||
@@ -441,7 +441,7 @@ class StarPilotCurveSpeedLayout(StarPilotPanel):
|
||||
self._params.remove("CurvatureData")
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(ConfirmDialog(tr("Reset Curve Data?"), tr("Confirm"), on_close=on_close))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Reset Curve Data?"), tr("Confirm"), callback=on_close))
|
||||
|
||||
|
||||
class StarPilotPersonalitiesLayout(StarPilotPanel):
|
||||
@@ -537,7 +537,7 @@ class StarPilotPersonalityProfileLayout(StarPilotPanel):
|
||||
self._params.remove(self._profile + key)
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(ConfirmDialog(tr("Reset to Defaults?"), tr("Confirm"), on_close=on_close))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Reset to Defaults?"), tr("Confirm"), callback=on_close))
|
||||
|
||||
def _show_float_selector(self, key, min_v, max_v, step, unit=""):
|
||||
def on_close(res, val):
|
||||
@@ -662,14 +662,14 @@ class StarPilotLongitudinalTuneLayout(StarPilotPanel):
|
||||
option_labels = [tr(option_label) for _, option_label in options]
|
||||
label_to_value = {tr(option_label): option_value for option_value, option_label in options}
|
||||
default_option = next((tr(option_label) for option_value, option_label in options if option_value == current_value), option_labels[0])
|
||||
dialog = MultiOptionDialog(tr(title), option_labels, default_option)
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
self._params.put_int(key, label_to_value[dialog.selection])
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr(title), option_labels, default_option, callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _show_int_selector(self, key, min_v, max_v, unit=""):
|
||||
def on_close(res, val):
|
||||
@@ -874,10 +874,8 @@ class StarPilotSpeedLimitControllerLayout(StarPilotPanel):
|
||||
def show_secondary_dialog(primary):
|
||||
secondary_options = ["None"] + [option for option in ("Dashboard", "Map Data", "Vision") if option != primary]
|
||||
selected_secondary = current_secondary if current_secondary in secondary_options else "None"
|
||||
secondary_dialog = MultiOptionDialog(tr("SLC Secondary Priority"), secondary_options, selected_secondary)
|
||||
gui_app.push_widget(secondary_dialog, callback=lambda res: on_secondary_select(primary, secondary_dialog, res))
|
||||
|
||||
primary_dialog = MultiOptionDialog(tr("SLC Primary Priority"), primary_options, current_primary)
|
||||
secondary_dialog = MultiOptionDialog(tr("SLC Secondary Priority"), secondary_options, selected_secondary, callback=lambda res: on_secondary_select(primary, secondary_dialog, res))
|
||||
gui_app.push_widget(secondary_dialog)
|
||||
|
||||
def on_primary_select(res):
|
||||
if res != DialogResult.CONFIRM or not primary_dialog.selection:
|
||||
@@ -889,18 +887,19 @@ class StarPilotSpeedLimitControllerLayout(StarPilotPanel):
|
||||
return
|
||||
show_secondary_dialog(primary_dialog.selection)
|
||||
|
||||
gui_app.push_widget(primary_dialog, callback=on_primary_select)
|
||||
primary_dialog = MultiOptionDialog(tr("SLC Primary Priority"), primary_options, current_primary, callback=on_primary_select)
|
||||
gui_app.push_widget(primary_dialog)
|
||||
|
||||
def _show_selection(self, key, options):
|
||||
current = self._params.get(key, encoding='utf-8') or "None"
|
||||
dialog = MultiOptionDialog(tr(key), options, current)
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
self._params.put(key, dialog.selection)
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr(key), options, current, callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
|
||||
class StarPilotSLCOffsetsLayout(StarPilotPanel):
|
||||
@@ -1050,7 +1049,6 @@ class StarPilotWeatherLayout(StarPilotPanel):
|
||||
|
||||
def _set_weather_key(self):
|
||||
options = ["ADD", "REMOVE"]
|
||||
dialog = MultiOptionDialog(tr("Weather API Key"), options, "ADD")
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
@@ -1073,9 +1071,10 @@ class StarPilotWeatherLayout(StarPilotPanel):
|
||||
self._params.remove("WeatherAPIKey")
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(ConfirmDialog(tr("Remove API Key?"), tr("Confirm"), on_close=on_confirm))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Remove API Key?"), tr("Confirm"), callback=on_confirm))
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr("Weather API Key"), options, "ADD", callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
|
||||
class StarPilotWeatherBase(StarPilotPanel):
|
||||
|
||||
@@ -40,9 +40,9 @@ from openpilot.starpilot.common.maps_catalog import (
|
||||
MAPS_CATALOG,
|
||||
MAP_SCHEDULE_LABELS,
|
||||
get_selected_map_entries,
|
||||
normalize_schedule_value,
|
||||
sanitize_selected_locations_csv,
|
||||
schedule_label,
|
||||
schedule_param_value,
|
||||
)
|
||||
from openpilot.starpilot.common.maps_selection import COUNTRY_PREFIX
|
||||
|
||||
@@ -904,13 +904,13 @@ class StarPilotMapsLayout(StarPilotPanel):
|
||||
def _on_schedule(self):
|
||||
options = list(MAP_SCHEDULE_LABELS.values())
|
||||
current = schedule_label(self._params.get("PreferredSchedule"))
|
||||
dialog = MultiOptionDialog(tr("Auto Update Schedule"), options, current)
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
self._params.put("PreferredSchedule", schedule_param_value(dialog.selection))
|
||||
self._params.put_int("PreferredSchedule", normalize_schedule_value(dialog.selection))
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr("Auto Update Schedule"), options, current, callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _on_download(self):
|
||||
gate_reason = self._download_gate_reason()
|
||||
@@ -932,7 +932,7 @@ class StarPilotMapsLayout(StarPilotPanel):
|
||||
self._params_memory.remove("CancelDownloadMaps")
|
||||
self._download_started_at = rl.get_time()
|
||||
|
||||
gui_app.push_widget(ConfirmDialog(tr("Start downloading offline maps for the selected regions?"), tr("Download"), on_close=on_confirm))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Start downloading offline maps for the selected regions?"), tr("Download"), callback=on_confirm))
|
||||
|
||||
def _on_cancel(self):
|
||||
def on_confirm(res):
|
||||
@@ -942,7 +942,7 @@ class StarPilotMapsLayout(StarPilotPanel):
|
||||
self._cancel_requested_at = rl.get_time()
|
||||
self._cancel_visual_until = rl.get_time() + 2.5
|
||||
|
||||
gui_app.push_widget(ConfirmDialog(tr("Cancel the current map download?"), tr("Cancel Download"), on_close=on_confirm))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Cancel the current map download?"), tr("Cancel Download"), callback=on_confirm))
|
||||
|
||||
def _has_downloaded_maps(self) -> bool:
|
||||
return self._has_downloaded_data
|
||||
@@ -961,7 +961,7 @@ class StarPilotMapsLayout(StarPilotPanel):
|
||||
threading.Thread(target=remove_worker, daemon=True).start()
|
||||
gui_app.push_widget(alert_dialog(tr("Offline maps removed.")))
|
||||
|
||||
gui_app.push_widget(ConfirmDialog(tr("Delete all downloaded offline map data?"), tr("Remove Maps"), on_close=on_confirm))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Delete all downloaded offline map data?"), tr("Remove Maps"), callback=on_confirm))
|
||||
|
||||
def _last_updated_text(self) -> str:
|
||||
last_update = self._worker_params.get("LastMapsUpdate", encoding="utf-8")
|
||||
|
||||
@@ -481,7 +481,7 @@ class StarPilotSystemLayout(StarPilotPanel):
|
||||
if ui_state.started:
|
||||
gui_app.push_widget(
|
||||
ConfirmDialog(
|
||||
tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), on_close=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None
|
||||
tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), callback=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None
|
||||
)
|
||||
)
|
||||
|
||||
@@ -497,7 +497,7 @@ class StarPilotSystemLayout(StarPilotPanel):
|
||||
if ui_state.started:
|
||||
gui_app.push_widget(
|
||||
ConfirmDialog(
|
||||
tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), on_close=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None
|
||||
tr("Reboot required. Reboot now?"), tr("Reboot"), tr("Cancel"), callback=lambda res: HARDWARE.reboot() if res == DialogResult.CONFIRM else None
|
||||
)
|
||||
)
|
||||
|
||||
@@ -526,7 +526,7 @@ class StarPilotSystemLayout(StarPilotPanel):
|
||||
shutil.rmtree(entry, ignore_errors=True)
|
||||
threading.Thread(target=_task, daemon=True).start()
|
||||
gui_app.push_widget(alert_dialog(tr("Driving data deletion started.")))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Delete all driving data and footage?"), tr("Delete"), on_close=_do_delete))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Delete all driving data and footage?"), tr("Delete"), callback=_do_delete))
|
||||
|
||||
def _on_delete_error_logs(self):
|
||||
def _do_delete(res):
|
||||
@@ -534,7 +534,7 @@ class StarPilotSystemLayout(StarPilotPanel):
|
||||
shutil.rmtree("/data/error_logs", ignore_errors=True)
|
||||
os.makedirs("/data/error_logs", exist_ok=True)
|
||||
gui_app.push_widget(alert_dialog(tr("Error logs deleted.")))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Delete all error logs?"), tr("Delete"), on_close=_do_delete))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Delete all error logs?"), tr("Delete"), callback=_do_delete))
|
||||
|
||||
def _get_backups(self, folder="backups"):
|
||||
b_dir = Path(f"/data/{folder}")
|
||||
@@ -568,7 +568,7 @@ class StarPilotSystemLayout(StarPilotPanel):
|
||||
if not backups:
|
||||
gui_app.push_widget(alert_dialog(tr("No backups found.")))
|
||||
return
|
||||
dialog = MultiOptionDialog(tr("Select Backup"), backups)
|
||||
|
||||
def _on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
gui_app.push_widget(alert_dialog(tr("Restoring... device will reboot.")))
|
||||
@@ -577,18 +577,22 @@ class StarPilotSystemLayout(StarPilotPanel):
|
||||
subprocess.run(["tar", "--use-compress-program=zstd", "-xf", f"/data/backups/{dialog.selection}", "-C", "/"])
|
||||
os.system("reboot")
|
||||
threading.Thread(target=_task, daemon=True).start()
|
||||
gui_app.push_widget(dialog, callback=_on_select)
|
||||
|
||||
dialog = MultiOptionDialog(tr("Select Backup"), backups, callback=_on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _on_delete_backup(self):
|
||||
backups = self._get_backups("backups")
|
||||
if not backups:
|
||||
gui_app.push_widget(alert_dialog(tr("No backups found.")))
|
||||
return
|
||||
dialog = MultiOptionDialog(tr("Delete Backup"), backups)
|
||||
|
||||
def _on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
os.remove(f"/data/backups/{dialog.selection}")
|
||||
gui_app.push_widget(dialog, callback=_on_select)
|
||||
|
||||
dialog = MultiOptionDialog(tr("Delete Backup"), backups, callback=_on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _on_create_toggle_backup(self):
|
||||
def on_name(res, name):
|
||||
@@ -612,7 +616,7 @@ class StarPilotSystemLayout(StarPilotPanel):
|
||||
if not backups:
|
||||
gui_app.push_widget(alert_dialog(tr("No toggle backups found.")))
|
||||
return
|
||||
dialog = MultiOptionDialog(tr("Select Toggle Backup"), backups)
|
||||
|
||||
def _on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
def on_confirm(r2):
|
||||
@@ -629,19 +633,23 @@ class StarPilotSystemLayout(StarPilotPanel):
|
||||
if old_path.exists():
|
||||
old_path.replace(new_path)
|
||||
gui_app.push_widget(alert_dialog(tr("Toggles restored.")))
|
||||
gui_app.push_widget(ConfirmDialog(tr("This will overwrite your current toggles."), tr("Restore"), on_close=on_confirm))
|
||||
gui_app.push_widget(dialog, callback=_on_select)
|
||||
gui_app.push_widget(ConfirmDialog(tr("This will overwrite your current toggles."), tr("Restore"), callback=on_confirm))
|
||||
|
||||
dialog = MultiOptionDialog(tr("Select Toggle Backup"), backups, callback=_on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _on_delete_toggle_backup(self):
|
||||
backups = self._get_backups("toggle_backups")
|
||||
if not backups:
|
||||
gui_app.push_widget(alert_dialog(tr("No toggle backups found.")))
|
||||
return
|
||||
dialog = MultiOptionDialog(tr("Delete Toggle Backup"), backups)
|
||||
|
||||
def _on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
shutil.rmtree(f"/data/toggle_backups/{dialog.selection}", ignore_errors=True)
|
||||
gui_app.push_widget(dialog, callback=_on_select)
|
||||
|
||||
dialog = MultiOptionDialog(tr("Delete Toggle Backup"), backups, callback=_on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _get_force_drive_state(self):
|
||||
if self._params.get_bool("ForceOnroad"):
|
||||
|
||||
@@ -161,8 +161,6 @@ class StarPilotThemesLayout(StarPilotPanel):
|
||||
else:
|
||||
current = "Clear"
|
||||
|
||||
dialog = MultiOptionDialog(tr("Startup Alert"), options, current)
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
if dialog.selection == "Stock":
|
||||
@@ -175,7 +173,8 @@ class StarPilotThemesLayout(StarPilotPanel):
|
||||
self._params.remove("StartupMessageTop")
|
||||
self._params.remove("StartupMessageBottom")
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr("Startup Alert"), options, current, callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
|
||||
class StarPilotPersonalizeLayout(StarPilotPanel):
|
||||
@@ -319,8 +318,6 @@ class StarPilotPersonalizeLayout(StarPilotPanel):
|
||||
if not themes:
|
||||
return
|
||||
|
||||
dialog = MultiOptionDialog(tr(key), themes, current)
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
selected_slug = option_map.get(dialog.selection)
|
||||
@@ -329,4 +326,5 @@ class StarPilotPersonalizeLayout(StarPilotPanel):
|
||||
self._params.put(key, selected_slug)
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr(key), themes, current, callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
@@ -167,14 +167,12 @@ class StarPilotVehicleSettingsLayout(StarPilotPanel):
|
||||
def _on_select_make(self):
|
||||
makes = list(self._make_options)
|
||||
if not makes:
|
||||
gui_app.push_widget(ConfirmDialog(tr("No fingerprint list available."), tr("OK"), on_close=lambda r: None))
|
||||
gui_app.push_widget(ConfirmDialog(tr("No fingerprint list available."), tr("OK")))
|
||||
return
|
||||
|
||||
current_make = self._params.get("CarMake", encoding='utf-8') or ""
|
||||
default_make = current_make if current_make in makes else makes[0]
|
||||
|
||||
dialog = MultiOptionDialog(tr("Select Make"), makes, default_make)
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
self._params.put("CarMake", dialog.selection)
|
||||
@@ -185,17 +183,18 @@ class StarPilotVehicleSettingsLayout(StarPilotPanel):
|
||||
self._params.remove("CarModelName")
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr("Select Make"), makes, default_make, callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _on_select_model(self):
|
||||
make = self._params.get("CarMake", encoding='utf-8') or ""
|
||||
if not make:
|
||||
gui_app.push_widget(ConfirmDialog(tr("Please select a Car Make first!"), tr("OK"), on_close=lambda r: None))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Please select a Car Make first!"), tr("OK")))
|
||||
return
|
||||
|
||||
model_options = self._models_by_make.get(make, ())
|
||||
if not model_options:
|
||||
gui_app.push_widget(ConfirmDialog(tr("No models available for this make."), tr("OK"), on_close=lambda r: None))
|
||||
gui_app.push_widget(ConfirmDialog(tr("No models available for this make."), tr("OK")))
|
||||
return
|
||||
|
||||
option_labels = [option.option_label for option in model_options]
|
||||
@@ -206,8 +205,6 @@ class StarPilotVehicleSettingsLayout(StarPilotPanel):
|
||||
if default_option is None:
|
||||
default_option = next((option.option_label for option in model_options if option.value == current_model), option_labels[0])
|
||||
|
||||
dialog = MultiOptionDialog(tr("Select Model"), option_labels, default_option)
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
selected_option = selected_by_label[dialog.selection]
|
||||
@@ -216,7 +213,8 @@ class StarPilotVehicleSettingsLayout(StarPilotPanel):
|
||||
self._params.put("CarMake", make)
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr("Select Model"), option_labels, default_option, callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _on_disable_long(self, state):
|
||||
if state:
|
||||
@@ -230,7 +228,7 @@ class StarPilotVehicleSettingsLayout(StarPilotPanel):
|
||||
HARDWARE.reboot()
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(ConfirmDialog(tr("Disable openpilot longitudinal control?"), tr("Disable"), on_close=on_confirm))
|
||||
gui_app.push_widget(ConfirmDialog(tr("Disable openpilot longitudinal control?"), tr("Disable"), callback=on_confirm))
|
||||
else:
|
||||
self._params.put_bool("DisableOpenpilotLongitudinal", False)
|
||||
self._rebuild_grid()
|
||||
|
||||
@@ -466,8 +466,6 @@ class StarPilotModelUILayout(StarPilotPanel):
|
||||
presets = ["Stock", "#FFFFFF", "#178644", "#3B82F6", "#E63956", "#8B5CF6", "#F59E0B"]
|
||||
current = self._params.get(key, encoding='utf-8') or "Stock"
|
||||
|
||||
dialog = MultiOptionDialog(tr(key), presets, current)
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
if dialog.selection == "Stock":
|
||||
@@ -476,7 +474,8 @@ class StarPilotModelUILayout(StarPilotPanel):
|
||||
self._params.put(key, dialog.selection)
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr(key), presets, current, callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
|
||||
class StarPilotNavigationVisualsLayout(StarPilotPanel):
|
||||
@@ -569,12 +568,11 @@ class StarPilotVisualQOLLayout(StarPilotPanel):
|
||||
def _show_camera_view_selector(self):
|
||||
current = self._params.get_int("CameraView")
|
||||
|
||||
dialog = MultiOptionDialog(tr("Camera View"), self.CAMERA_VIEWS, self.CAMERA_VIEWS[current])
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
idx = self.CAMERA_VIEWS.index(dialog.selection)
|
||||
self._params.put_int("CameraView", idx)
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr("Camera View"), self.CAMERA_VIEWS, self.CAMERA_VIEWS[current], callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
@@ -165,7 +165,6 @@ class StarPilotWheelLayout(StarPilotPanel):
|
||||
current = self._get_action_name(key)
|
||||
if current not in actions:
|
||||
current = actions[0]
|
||||
dialog = MultiOptionDialog(tr(key), actions, current)
|
||||
|
||||
def on_select(res):
|
||||
if res == DialogResult.CONFIRM and dialog.selection:
|
||||
@@ -173,7 +172,8 @@ class StarPilotWheelLayout(StarPilotPanel):
|
||||
self._params_memory.put_bool("StarPilotTogglesUpdated", True)
|
||||
self._rebuild_grid()
|
||||
|
||||
gui_app.push_widget(dialog, callback=on_select)
|
||||
dialog = MultiOptionDialog(tr(key), actions, current, callback=on_select)
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _rebuild_grid(self):
|
||||
if not self.CATEGORIES:
|
||||
|
||||
Reference in New Issue
Block a user