From d5abbd0d14689aaac69c91cf05385e6fc729796b Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 28 Jul 2021 09:30:25 -0700 Subject: [PATCH] Allow overwriting existing symbols This allows the workflow: 1) Edit symbol in schematic 2) Save As to original library Also allows the user to quickly overwrite a symbol they don't want, either by importing over the existing symbol or creating a new one. --- eeschema/symbol_editor/symbol_editor.cpp | 18 ++++++++++++++---- .../symbol_editor_import_export.cpp | 9 +++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index fa21646e0e..5ec3d538cd 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -421,8 +421,13 @@ void SYMBOL_EDIT_FRAME::CreateNewSymbol() wxString msg = wxString::Format( _( "Symbol '%s' already exists in library '%s'." ), name, lib ); - DisplayError( this, msg ); - return; + + KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); + errorDlg.SetOKLabel( _( "Overwrite" ) ); + errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ ); + + if( errorDlg.ShowModal() == wxID_CANCEL ) + return; } LIB_SYMBOL new_symbol( name ); // do not create symbol on the heap, it will be buffered soon @@ -673,8 +678,13 @@ void SYMBOL_EDIT_FRAME::saveSymbolAs() wxString msg = wxString::Format( _( "Symbol '%s' already exists in library '%s'" ), new_name, new_lib ); - DisplayError( this, msg ); - return; + + KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); + errorDlg.SetOKLabel( _( "Overwrite" ) ); + errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ ); + + if( errorDlg.ShowModal() == wxID_CANCEL ) + return; } LIB_SYMBOL new_symbol( *symbol ); diff --git a/eeschema/symbol_editor/symbol_editor_import_export.cpp b/eeschema/symbol_editor/symbol_editor_import_export.cpp index f7f836b99f..65aa1051a6 100644 --- a/eeschema/symbol_editor/symbol_editor_import_export.cpp +++ b/eeschema/symbol_editor/symbol_editor_import_export.cpp @@ -94,8 +94,13 @@ void SYMBOL_EDIT_FRAME::ImportSymbol() if( m_libMgr->SymbolExists( symbols[0], libName ) ) { msg.Printf( _( "Symbol %s already exists in library '%s'." ), symbolName, libName ); - DisplayError( this, msg ); - return; + + KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); + errorDlg.SetOKLabel( _( "Overwrite" ) ); + errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ ); + + if( errorDlg.ShowModal() == wxID_CANCEL ) + return; } m_libMgr->UpdateSymbol( entry, libName );