@@ -553,32 +553,7 @@ def _connect_text(widget, handler) -> None:
553553 _connect_text (self .file_filter_input , self .apply_file_filter )
554554
555555 if self .btn_bc_loader :
556- try :
557- from importlib import import_module
558-
559- def _open_bc ():
560- try :
561- # Preferred rich BCASL dialog (plugin config tabs).
562- mod = import_module ("bcasl.Loader" )
563- fn = getattr (mod , "open_bc_loader_dialog" , None )
564- if callable (fn ):
565- fn (self )
566- return
567- except Exception :
568- pass
569- try :
570- # Fallback to exported API loader.
571- import bcasl
572-
573- fn2 = getattr (bcasl , "open_api_loader_dialog" , None )
574- if callable (fn2 ):
575- fn2 (self )
576- except Exception :
577- pass
578-
579- self .btn_bc_loader .clicked .connect (_open_bc )
580- except Exception :
581- pass
556+ _connect_clicked (self .btn_bc_loader , lambda : _open_bcasl_loader_dialog (self ))
582557
583558 _connect_clicked (self .btn_help , self .show_help_dialog )
584559
@@ -615,6 +590,68 @@ def update_compiler_options_enabled() -> None:
615590 _connect_clicked (self .btn_suggest_deps , self .suggest_missing_dependencies )
616591
617592
593+ def _open_bcasl_loader_dialog (self ) -> None :
594+ """Open BCASL loader with robust import fallbacks and visible diagnostics."""
595+ fn = None
596+ import_errors : list [str ] = []
597+ try :
598+ if getattr (self , "log" , None ):
599+ self .log .append (self .tr ("Ouverture BCASL..." , "Opening BCASL..." ))
600+ except Exception :
601+ pass
602+
603+ try :
604+ from bcasl .Loader import open_bc_loader_dialog as fn # type: ignore
605+ except Exception as e :
606+ import_errors .append (f"bcasl.Loader.open_bc_loader_dialog: { e } " )
607+ fn = None
608+
609+ if fn is None :
610+ try :
611+ from bcasl import open_api_loader_dialog as fn # type: ignore
612+ except Exception as e :
613+ import_errors .append (f"bcasl.open_api_loader_dialog: { e } " )
614+ fn = None
615+
616+ if fn is None :
617+ try :
618+ from bcasl .bcasl_loader import open_api_loader_dialog as fn # type: ignore
619+ except Exception as e :
620+ import_errors .append (f"bcasl.bcasl_loader.open_api_loader_dialog: { e } " )
621+ fn = None
622+
623+ if fn is None :
624+ try :
625+ if getattr (self , "log" , None ):
626+ self .log .append (
627+ self .tr (
628+ "BCASL indisponible: impossible de charger le dialogue." ,
629+ "BCASL unavailable: failed to load dialog." ,
630+ )
631+ )
632+ for err in import_errors :
633+ self .log .append (f" - { err } " )
634+ except Exception :
635+ pass
636+ return
637+
638+ try :
639+ fn (self )
640+ except Exception as e :
641+ try :
642+ if getattr (self , "log" , None ):
643+ self .log .append (
644+ self .tr (
645+ f"Erreur BCASL: { e } " ,
646+ f"BCASL error: { e } " ,
647+ )
648+ )
649+ for err in import_errors :
650+ self .log .append (f" - { err } " )
651+ except Exception :
652+ pass
653+
654+
618655def _show_initial_help_message (self ) -> None :
619656 """Affiche un message d'aide si aucun workspace n'est sélectionné."""
620657 # Désactivé à la demande : pas de message d'astuce par défaut dans le log.
0 commit comments