Get rid of Export Symbol.

It can be done with the "New Library" button when doing
a Save copy as (which doesn't lead the user down the
wrong path as Export Symbol can).

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17840
This commit is contained in:
Jeff Young 2024-04-28 22:05:51 +01:00
parent a5bd97da11
commit b5fb7b7ace
4 changed files with 0 additions and 131 deletions

View File

@ -74,7 +74,6 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar()
ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( BITMAPS::export_file );
submenuExport->Add( EE_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
submenuExport->Add( EE_ACTIONS::exportSymbolView, ACTION_MENU::NORMAL, _( "View as PNG..." ) );
submenuExport->Add( EE_ACTIONS::exportSymbolAsSVG, ACTION_MENU::NORMAL, _( "Symbol as SVG..." ) );
fileMenu->Add( submenuExport );

View File

@ -139,115 +139,3 @@ void SYMBOL_EDIT_FRAME::ImportSymbol()
LoadSymbol( entry->GetName(), libName, 1 );
}
void SYMBOL_EDIT_FRAME::ExportSymbol()
{
wxString msg;
LIB_SYMBOL* symbol = getTargetSymbol();
if( !symbol )
{
ShowInfoBarError( _( "There is no symbol selected to save." ) );
return;
}
wxFileName fn;
fn.SetName( symbol->GetName().Lower() );
fn.SetExt( FILEEXT::KiCadSymbolLibFileExtension );
wxFileDialog dlg( this, _( "Export Symbol" ), m_mruPath, fn.GetFullName(),
FILEEXT::KiCadSymbolLibFileWildcard(), wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
fn = dlg.GetPath();
fn.MakeAbsolute();
LIB_SYMBOL* old_symbol = nullptr;
SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() );
if( pluginType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
pluginType = SCH_IO_MGR::SCH_KICAD;
IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( pluginType ) );
if( fn.FileExists() )
{
try
{
old_symbol = pi->LoadSymbol( fn.GetFullPath(), symbol->GetName() );
}
catch( const IO_ERROR& ioe )
{
msg.Printf( _( "Error occurred attempting to load symbol library file '%s'." ),
fn.GetFullPath() );
DisplayErrorMessage( this, msg, ioe.What() );
return;
}
if( old_symbol )
{
msg.Printf( _( "Symbol %s already exists in library '%s'." ),
UnescapeString( symbol->GetName() ),
fn.GetFullName() );
KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
errorDlg.SetOKLabel( _( "Overwrite" ) );
errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( errorDlg.ShowModal() == wxID_CANCEL )
return;
}
}
if( fn.Exists() && !fn.IsDirWritable() )
{
msg.Printf( _( "Insufficient permissions to save library '%s'." ),
fn.GetFullPath() );
DisplayError( this, msg );
return;
}
try
{
if( !fn.FileExists() )
pi->CreateLibrary( fn.GetFullPath() );
// The flattened symbol is most likely what the user would want. As some point in
// the future as more of the symbol library inheritance is implemented, this may have
// to be changes to save symbols of inherited symbols.
pi->SaveSymbol( fn.GetFullPath(), symbol->Flatten().release() );
}
catch( const IO_ERROR& ioe )
{
msg.Printf( _( "Failed to create symbol library file '%s'." ), fn.GetFullPath() );
DisplayErrorMessage( this, msg, ioe.What() );
msg.Printf( _( "Error creating symbol library '%s'." ), fn.GetFullName() );
SetStatusText( msg );
return;
}
m_mruPath = fn.GetPath();
msg.Printf( _( "Symbol %s saved to library '%s'." ),
UnescapeString( symbol->GetName() ),
fn.GetFullPath() );
SetStatusText( msg );
// See if the user wants it added to a library table (global or project)
SYMBOL_LIB_TABLE* libTable = SelectSymLibTable( true );
if( libTable )
{
if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
{
DisplayError( this, _( "Could not open the library file." ) );
return;
}
bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
saveSymbolLibTables( globalTable, !globalTable );
}
}

View File

@ -236,13 +236,6 @@ TOOL_ACTION EE_ACTIONS::importSymbol( TOOL_ACTION_ARGS()
.Tooltip( _( "Import a symbol to the current library" ) )
.Icon( BITMAPS::import_part ) );
TOOL_ACTION EE_ACTIONS::exportSymbol( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.exportSymbol" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Export..." ) )
.Tooltip( _( "Export a symbol to a new library file" ) )
.Icon( BITMAPS::export_part ) );
TOOL_ACTION EE_ACTIONS::openWithTextEditor( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.openWithTextEditor" )
.Scope( AS_GLOBAL )

View File

@ -132,7 +132,6 @@ bool SYMBOL_EDITOR_CONTROL::Init()
ctxMenu.AddSeparator();
ctxMenu.AddItem( EE_ACTIONS::importSymbol, libInferredCondition );
ctxMenu.AddItem( EE_ACTIONS::exportSymbol, symbolSelectedCondition );
// If we've got nothing else to show, at least show a hide tree option
ctxMenu.AddSeparator();
@ -258,15 +257,6 @@ int SYMBOL_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent )
}
int SYMBOL_EDITOR_CONTROL::ExportSymbol( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->ExportSymbol();
return 0;
}
int SYMBOL_EDITOR_CONTROL::OpenWithTextEditor( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
@ -810,7 +800,6 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
Go( &SYMBOL_EDITOR_CONTROL::CutCopyDelete, EE_ACTIONS::cutSymbol.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::CutCopyDelete, EE_ACTIONS::copySymbol.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::DuplicateSymbol, EE_ACTIONS::pasteSymbol.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ExportSymbol, EE_ACTIONS::exportSymbol.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::OpenWithTextEditor, EE_ACTIONS::openWithTextEditor.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ExportView, EE_ACTIONS::exportSymbolView.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG, EE_ACTIONS::exportSymbolAsSVG.MakeEvent() );