Use schematic symbol field to show documentation link.
This instead of using the library alias property. But to not break any library. When adding new components to the schematic, copy the value from the library into the Field variable only if the field variable would otherwise be empty. This way, the context menu for showing the docs is more understandable for users, and is also changeable from the schematic without having to modify the actual libraries. Fixed: lp:1723104
This commit is contained in:
parent
788972554b
commit
a562525ec9
|
@ -54,6 +54,7 @@
|
|||
#endif /* KICAD_SPICE */
|
||||
|
||||
#include "common.h"
|
||||
#include "eda_doc.h"
|
||||
#include <list>
|
||||
|
||||
|
||||
|
@ -590,7 +591,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& even
|
|||
{
|
||||
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
|
||||
datasheet_uri = resolveUriByEnvVars( datasheet_uri );
|
||||
::wxLaunchDefaultBrowser( datasheet_uri );
|
||||
GetAssociatedDocument( this, datasheet_uri );
|
||||
}
|
||||
else if( fieldNdx == FOOTPRINT )
|
||||
{
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <sch_validators.h>
|
||||
|
||||
#include <bitmaps.h>
|
||||
#include "eda_doc.h"
|
||||
|
||||
#include <dialog_edit_libentry_fields_in_lib_base.h>
|
||||
#ifdef KICAD_SPICE
|
||||
|
@ -501,7 +502,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::showButtonHandler( wxCommandEvent& even
|
|||
if( fieldNdx == DATASHEET )
|
||||
{
|
||||
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
|
||||
::wxLaunchDefaultBrowser( datasheet_uri );
|
||||
GetAssociatedDocument( this, datasheet_uri );
|
||||
}
|
||||
else if( fieldNdx == FOOTPRINT )
|
||||
{
|
||||
|
|
|
@ -254,6 +254,18 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component(
|
|||
// Set the component value that can differ from component name in lib, for aliases
|
||||
component->GetField( VALUE )->SetText( sel.Name );
|
||||
|
||||
// If there is no field defined in the component, copy one over from the library
|
||||
// ( from the .dcm file )
|
||||
// This way the Datasheet field will not be empty and can be changed from the schematic
|
||||
auto libs = Prj().SchLibs();
|
||||
if( component->GetField( DATASHEET )->GetText().IsEmpty() )
|
||||
{
|
||||
LIB_ALIAS* entry = libs->FindLibraryAlias( component->GetLibId() );
|
||||
|
||||
if( entry && !!entry->GetDocFileName() )
|
||||
component->GetField( DATASHEET )->SetText( entry->GetDocFileName() );
|
||||
}
|
||||
|
||||
MSG_PANEL_ITEMS items;
|
||||
|
||||
component->SetCurrentSheetPath( &GetCurrentSheet() );
|
||||
|
|
|
@ -397,7 +397,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, PART_LIBS*
|
|||
msg = AddHotkeyName( _( "Autoplace Fields" ), g_Schematic_Hokeys_Descr, HK_AUTOPLACE_FIELDS );
|
||||
AddMenuItem( PopMenu, ID_AUTOPLACE_FIELDS, msg, KiBitmap( autoplace_fields_xpm ) );
|
||||
|
||||
if( libEntry && !libEntry->GetDocFileName().IsEmpty() )
|
||||
if( !Component->GetFieldText("Datasheet").IsEmpty() )
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Open Documentation" ), KiBitmap( datasheet_xpm ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -302,16 +302,11 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
// Ensure the struct is a component (could be a piece of a component, like Field, text..)
|
||||
if( item && item->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
if( PART_LIBS* libs = Prj().SchLibs() )
|
||||
auto text = static_cast<SCH_COMPONENT*>( item )->GetFieldText( "Datasheet" );
|
||||
|
||||
if( !text.IsEmpty() )
|
||||
{
|
||||
LIB_ALIAS* entry = libs->FindLibraryAlias( ( (SCH_COMPONENT*) item )->GetLibId() );
|
||||
|
||||
if( entry && !!entry->GetDocFileName() )
|
||||
{
|
||||
SEARCH_STACK* lib_search = Prj().SchSearchS();
|
||||
|
||||
GetAssociatedDocument( this, entry->GetDocFileName(), lib_search );
|
||||
}
|
||||
GetAssociatedDocument( this, text );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue