From b5fb7b7ace14964d270d9b07154bab437651835f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 28 Apr 2024 22:05:51 +0100 Subject: [PATCH] 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 --- .../symbol_editor/menubar_symbol_editor.cpp | 1 - .../symbol_editor_import_export.cpp | 112 ------------------ eeschema/tools/ee_actions.cpp | 7 -- eeschema/tools/symbol_editor_control.cpp | 11 -- 4 files changed, 131 deletions(-) diff --git a/eeschema/symbol_editor/menubar_symbol_editor.cpp b/eeschema/symbol_editor/menubar_symbol_editor.cpp index 2fdcaa759f..ee2933c6a0 100644 --- a/eeschema/symbol_editor/menubar_symbol_editor.cpp +++ b/eeschema/symbol_editor/menubar_symbol_editor.cpp @@ -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 ); diff --git a/eeschema/symbol_editor/symbol_editor_import_export.cpp b/eeschema/symbol_editor/symbol_editor_import_export.cpp index d6e1005f73..726a137170 100644 --- a/eeschema/symbol_editor/symbol_editor_import_export.cpp +++ b/eeschema/symbol_editor/symbol_editor_import_export.cpp @@ -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 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 ); - } -} diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index c727c5eff7..22db126cec 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -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 ) diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index 3bc9cd045b..53681f7f0f 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -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( 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() );