From e7d98f89a1210c5d80b631e2ce269d597c345c66 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 15 Feb 2018 20:15:37 +0000 Subject: [PATCH] Fix display of datasheet URLs and shorten them if necessary. Fixes: lp:1676174 * https://bugs.launchpad.net/kicad/+bug/1676174 --- eeschema/dialogs/dialog_choose_component.cpp | 5 ++--- eeschema/generate_alias_info.cpp | 13 +++++++++++-- eeschema/widgets/component_tree.cpp | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp index a5f3cc8d6e..f14d818615 100644 --- a/eeschema/dialogs/dialog_choose_component.cpp +++ b/eeschema/dialogs/dialog_choose_component.cpp @@ -78,8 +78,7 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE | wxSP_3DSASH ); auto details = aShowFootprints ? nullptr : new wxHtmlWindow( - vsplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER ); + vsplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO ); m_tree = new COMPONENT_TREE( m_splitter_tree_canvas, Prj().SchSymbolLibTable(), aAdapter, COMPONENT_TREE::WIDGETS::ALL, details ); @@ -156,7 +155,7 @@ wxPanel* DIALOG_CHOOSE_COMPONENT::ConstructRightPanel( wxWindow* aParent ) auto sizer = new wxBoxSizer( wxVERTICAL ); m_sch_view_ctrl = new wxPanel( panel, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ), - wxFULL_REPAINT_ON_RESIZE | wxSUNKEN_BORDER | wxTAB_TRAVERSAL ); + wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL ); m_sch_view_ctrl->SetLayoutDirection( wxLayout_LeftToRight ); if( m_show_footprints ) diff --git a/eeschema/generate_alias_info.cpp b/eeschema/generate_alias_info.cpp index ea2eb8cc2b..7346c220f7 100644 --- a/eeschema/generate_alias_info.cpp +++ b/eeschema/generate_alias_info.cpp @@ -42,7 +42,7 @@ static const wxString FieldFormat = " __NAME__" " __VALUE__" ""; -static const wxString DatasheetLinkFormat = "__VALUE__"; +static const wxString DatasheetLinkFormat = "__TEXT__"; class ALIAS_INFO_GENERATOR @@ -170,8 +170,17 @@ protected: { case DATASHEET: { + if( text.IsEmpty() ) + text = m_alias->GetDocFileName(); + wxString datasheetlink = DatasheetLinkFormat; - datasheetlink.Replace( "__VALUE__", EscapedHTML( text ) ); + datasheetlink.Replace( "__HREF__", EscapedHTML( text ) ); + + if( text.Length() > 75 ) + text = text.Left( 72 ) + wxT( "..." ); + + datasheetlink.Replace( "__TEXT__", EscapedHTML( text ) ); + fieldhtml.Replace( "__VALUE__", datasheetlink ); } break; diff --git a/eeschema/widgets/component_tree.cpp b/eeschema/widgets/component_tree.cpp index 6e0a1c86e2..4035fdf42a 100644 --- a/eeschema/widgets/component_tree.cpp +++ b/eeschema/widgets/component_tree.cpp @@ -86,7 +86,7 @@ COMPONENT_TREE::COMPONENT_TREE( wxWindow* aParent, SYMBOL_LIB_TABLE* aSymLibTabl auto html_sz = ConvertDialogToPixels( wxPoint( 80, 80 ) ); m_details_ctrl = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxSize( html_sz.x, html_sz.y ), - wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER ); + wxHW_SCROLLBAR_AUTO ); sizer->Add( m_details_ctrl, 1, wxALL | wxEXPAND, 5 ); }