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><b>__NAME__</b></td>"
" <td>__VALUE__</td>" " <td>__VALUE__</td>"
"</tr>" ); "</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 class FOOTPRINT_INFO_GENERATOR
@ -183,7 +183,7 @@ protected:
} }
else else
{ {
wxString datasheetlink = DatasheetLinkFormat; wxString datasheetlink = LinkFormat;
datasheetlink.Replace( wxS( "__HREF__" ), EscapeHTML( text ) ); datasheetlink.Replace( wxS( "__HREF__" ), EscapeHTML( text ) );
if( text.Length() > 75 ) if( text.Length() > 75 )
@ -207,7 +207,23 @@ protected:
default: default:
text = aField.GetShownText( false ); text = aField.GetShownText( false );
fieldhtml.Replace( wxS( "__VALUE__" ), EscapeHTML( text ) );
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; 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 void SCH_FIELD::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const
{ {
constexpr int START_ID = 1; constexpr int START_ID = 1;
@ -1056,7 +1068,7 @@ void SCH_FIELD::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const
else if( sel == 999 ) else if( sel == 999 )
href = SCH_NAVIGATE_TOOL::g_BackLink; 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 ); href = GetShownText( false );
} }

View File

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