Improve document file handling.
Fixes: lp:1779512 * https://bugs.launchpad.net/kicad/+bug/1779512
This commit is contained in:
parent
3c455949fc
commit
122d7ed3b3
|
@ -372,9 +372,8 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxASSERT( m_tool ); // without tool & tool manager we cannot handle events
|
|
||||||
|
|
||||||
// forward the action/update event to the TOOL_MANAGER
|
// forward the action/update event to the TOOL_MANAGER
|
||||||
|
// clients that don't supply a tool will have to check GetSelected() themselves
|
||||||
if( evt && m_tool )
|
if( evt && m_tool )
|
||||||
{
|
{
|
||||||
//aEvent.StopPropagation();
|
//aEvent.StopPropagation();
|
||||||
|
|
|
@ -208,8 +208,13 @@ protected:
|
||||||
|
|
||||||
void OnButtonClick() override
|
void OnButtonClick() override
|
||||||
{
|
{
|
||||||
wxString uri = ResolveUriByEnvVars( GetValue() );
|
wxString filename = GetValue();
|
||||||
GetAssociatedDocument( m_dlg, uri );
|
|
||||||
|
if( !filename.IsEmpty() && filename != wxT( "~" ) )
|
||||||
|
{
|
||||||
|
wxString uri = ResolveUriByEnvVars( GetValue() );
|
||||||
|
GetAssociatedDocument( m_dlg, uri );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DIALOG_SHIM* m_dlg;
|
DIALOG_SHIM* m_dlg;
|
||||||
|
|
|
@ -170,21 +170,31 @@ protected:
|
||||||
{
|
{
|
||||||
case DATASHEET:
|
case DATASHEET:
|
||||||
{
|
{
|
||||||
if( text.IsEmpty() )
|
text = m_module->GetDocFileName();
|
||||||
text = m_module->GetDocFileName();
|
|
||||||
|
|
||||||
wxString datasheetlink = DatasheetLinkFormat;
|
if( text.IsEmpty() || text == wxT( "~" ) )
|
||||||
datasheetlink.Replace( "__HREF__", EscapedHTML( text ) );
|
{
|
||||||
|
fieldhtml.Replace( "__VALUE__", text );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString datasheetlink = DatasheetLinkFormat;
|
||||||
|
datasheetlink.Replace( "__HREF__", EscapedHTML( text ) );
|
||||||
|
|
||||||
if( text.Length() > 75 )
|
if( text.Length() > 75 )
|
||||||
text = text.Left( 72 ) + wxT( "..." );
|
text = text.Left( 72 ) + wxT( "..." );
|
||||||
|
|
||||||
datasheetlink.Replace( "__TEXT__", EscapedHTML( text ) );
|
datasheetlink.Replace( "__TEXT__", EscapedHTML( text ) );
|
||||||
|
|
||||||
fieldhtml.Replace( "__VALUE__", datasheetlink );
|
fieldhtml.Replace( "__VALUE__", datasheetlink );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VALUE:
|
||||||
|
// showing the value just repeats the name, so that's not much use...
|
||||||
|
return wxEmptyString;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fieldhtml.Replace( "__VALUE__", EscapedHTML( text ) );
|
fieldhtml.Replace( "__VALUE__", EscapedHTML( text ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
#include <menus_helpers.h>
|
#include <menus_helpers.h>
|
||||||
#include <wx/progdlg.h>
|
#include <wx/progdlg.h>
|
||||||
|
#include <tool/context_menu.h>
|
||||||
|
|
||||||
int LIB_EDIT_FRAME:: m_unit = 1;
|
int LIB_EDIT_FRAME:: m_unit = 1;
|
||||||
int LIB_EDIT_FRAME:: m_convert = 1;
|
int LIB_EDIT_FRAME:: m_convert = 1;
|
||||||
|
@ -570,18 +570,32 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
|
||||||
if( !part )
|
if( !part )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString fileName;
|
wxString filename;
|
||||||
|
|
||||||
// TODO: it would be nice to offer a menu here of aliases....
|
if( part->GetAliasCount() > 1 )
|
||||||
LIB_ALIAS* alias = part->GetAlias( part->GetName() );
|
{
|
||||||
|
CONTEXT_MENU popup;
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
fileName = alias->GetDocFileName();
|
for( LIB_ALIAS* alias : part->GetAliases() )
|
||||||
|
{
|
||||||
|
msg.Printf( wxT( "%s (%s)" ), alias->GetName(), alias->GetDocFileName() );
|
||||||
|
popup.Append( wxID_ANY, msg );
|
||||||
|
}
|
||||||
|
|
||||||
if( !fileName.IsEmpty() )
|
PopupMenu( &popup );
|
||||||
|
|
||||||
|
if( popup.GetSelected() >= 0 )
|
||||||
|
filename = part->GetAlias( (unsigned) popup.GetSelected() )->GetDocFileName();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
filename = part->GetAlias( 0 )->GetDocFileName();
|
||||||
|
|
||||||
|
if( !filename.IsEmpty() && filename != wxT( "~" ) )
|
||||||
{
|
{
|
||||||
SEARCH_STACK* lib_search = Prj().SchSearchS();
|
SEARCH_STACK* lib_search = Prj().SchSearchS();
|
||||||
|
|
||||||
GetAssociatedDocument( this, fileName, lib_search );
|
GetAssociatedDocument( this, filename, lib_search );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue