Support URLs in Symbol Chooser info panel.

Also adds support for sim library fields as URLs.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20811
This commit is contained in:
Jeff Young 2025-04-30 12:53:05 +01:00
parent b772960717
commit 34f2038a95
3 changed files with 33 additions and 11 deletions

View File

@ -43,7 +43,7 @@ static const wxString FieldFormat = wxS(
" <td><b>__NAME__</b></td>"
" <td>__VALUE__</td>"
"</tr>" );
static const wxString DatasheetLinkFormat = wxS( "<a href=\"__HREF__\">__TEXT__</a>" );
static const wxString LinkFormat = wxS( "<a href=\"__HREF__\">__TEXT__</a>" );
class FOOTPRINT_INFO_GENERATOR
@ -183,7 +183,7 @@ protected:
}
else
{
wxString datasheetlink = DatasheetLinkFormat;
wxString datasheetlink = LinkFormat;
datasheetlink.Replace( wxS( "__HREF__" ), EscapeHTML( text ) );
if( text.Length() > 75 )
@ -207,8 +207,24 @@ protected:
default:
text = aField.GetShownText( false );
if( aField.IsHypertext() )
{
wxString link = LinkFormat;
link.Replace( wxS( "__HREF__" ), EscapeHTML( text ) );
if( text.Length() > 75 )
text = text.Left( 72 ) + wxT( "..." );
link.Replace( wxS( "__TEXT__" ), EscapeHTML( text ) );
fieldhtml.Replace( wxS( "__VALUE__" ), link );
}
else
{
fieldhtml.Replace( wxS( "__VALUE__" ), EscapeHTML( text ) );
}
}
return fieldhtml;
}

View File

@ -1021,6 +1021,18 @@ void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
}
bool SCH_FIELD::IsHypertext() const
{
if( m_id == FIELD_T::INTERSHEET_REFS )
return true;
if( m_name == SIM_LIBRARY::LIBRARY_FIELD )
return true;
return IsURL( GetShownText( false ) );
}
void SCH_FIELD::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const
{
constexpr int START_ID = 1;
@ -1056,7 +1068,7 @@ void SCH_FIELD::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const
else if( sel == 999 )
href = SCH_NAVIGATE_TOOL::g_BackLink;
}
else if( IsURL( GetShownText( false ) ) )
else if( IsURL( GetShownText( false ) ) || m_name == SIM_LIBRARY::LIBRARY_FIELD )
{
href = GetShownText( false );
}

View File

@ -90,13 +90,7 @@ public:
return _( "Field" );
}
bool IsHypertext() const override
{
if( m_id == FIELD_T::INTERSHEET_REFS )
return true;
return IsURL( GetShownText( false ) );
}
bool IsHypertext() const override;
void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;