From c19804bb958c774e107a766ff9cbee3b3f0a7103 Mon Sep 17 00:00:00 2001 From: Josue Huaroto Date: Wed, 23 Aug 2023 22:05:44 +0000 Subject: [PATCH] Replace DisplayError to an infobar for missing footprint library --- pcbnew/footprint_viewer_frame.cpp | 52 +++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 4902806f52..3628eb1dea 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -65,6 +65,9 @@ #include #include #include +#include + +#include "invoke_pcb_dialog.h" using namespace std::placeholders; @@ -1059,21 +1062,52 @@ bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent if( fpid.IsValid() ) { - wxString libraryName = fpid.GetLibNickname(); + wxString libraryName = fpid.GetLibNickname(); + WX_INFOBAR* infobar; + wxHyperlinkCtrl* button; + bool hasInfobar = false; + + if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) + || !fpTable->HasLibrary( fpid.GetLibNickname(), true ) ) + { + CreateInfoBar(); + if( infobar = GetInfoBar() ) + { + hasInfobar = true; + button = new wxHyperlinkCtrl( infobar, wxID_ANY, + _( "Manage symol libraries" ), + wxEmptyString ); + button->Bind( wxEVT_COMMAND_HYPERLINK, std::function( + [=]( wxHyperlinkEvent& aEvent ) + { + InvokePcbLibTableEditor( &Kiway(), this ); + } ) ); + } + } if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) ) { - msg.sprintf( _( "The current configuration does not include library '%s'. Use " - "Manage Footprint Libraries to edit the configuration." ), - libraryName ); - DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg ); + if( hasInfobar ) + { + msg.Printf( _( "Footprint library not found. The current configuration does " + "not include library '%s'." ), libraryName ); + infobar->RemoveAllButtons(); + infobar->AddButton( button ); + infobar->AddCloseButton(); + infobar->ShowMessage( msg, wxICON_INFORMATION ); + } } else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) ) { - msg.sprintf( _( "Library '%s' is not enabled in the current configuration. Use " - "Manage Footprint Libraries to edit the configuration." ), - libraryName ); - DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg ); + if( hasInfobar ) + { + msg.Printf( _( "Footprint library not enabled. Library '%s' is not enabled " + "in the current configuration." ), libraryName ); + infobar->RemoveAllButtons(); + infobar->AddButton( button ); + infobar->AddCloseButton(); + infobar->ShowMessage( msg, wxICON_INFORMATION ); + } } else {