@@ -75,7 +75,7 @@ def __init__(self) -> None:
7575 pass
7676
7777 @classmethod
78- def _get_settings_defaults (cls ) -> dict [str , Union [int , bool , str , float , dict ]]:
78+ def _get_settings_defaults (cls ) -> dict [str , Union [int , bool , str , float , dict , list ]]:
7979 """
8080 Get the default settings dictionary with dynamically computed paths.
8181
@@ -89,6 +89,7 @@ def _get_settings_defaults(cls) -> dict[str, Union[int, bool, str, float, dict]]
8989 return {
9090 "Format version" : 1 ,
9191 "display_usage_popup" : dict .fromkeys (USAGE_POPUP_WINDOWS , True ),
92+ "connection_history" : [], # New Connection list
9293 "directory_selection" : {
9394 "template_dir" : os_path .join (cls .get_templates_base_dir (), "ArduCopter" , "empty_4.6.x" ),
9495 "new_base_dir" : os_path .join (settings_directory , "vehicles" ),
@@ -455,3 +456,34 @@ def motor_diagram_exists(frame_class: int, frame_type: int) -> bool:
455456 """
456457 filepath , _error_msg = ProgramSettings .motor_diagram_filepath (frame_class , frame_type )
457458 return filepath != "" and os_path .exists (filepath )
459+
460+ @staticmethod
461+ def get_connection_history () -> list [str ]:
462+ """Get the list of previously used connection strings."""
463+ settings = ProgramSettings ._get_settings_as_dict ()
464+ history = settings .get ("connection_history" )
465+
466+ if history is None :
467+ return []
468+
469+ return history
470+
471+ @staticmethod
472+ def store_connection (connection_string : str ) -> None :
473+ """Save a new connection string to history."""
474+ if not connection_string :
475+ return
476+
477+ settings = ProgramSettings ._get_settings_as_dict ()
478+ history = settings .get ("connection_history" , [])
479+
480+ if connection_string in history :
481+ history .remove (connection_string )
482+
483+ history .insert (0 , connection_string )
484+
485+ if len (history ) > 10 :
486+ history = history [:10 ]
487+
488+ settings ["connection_history" ] = history
489+ ProgramSettings ._set_settings_from_dict (settings )
0 commit comments