diff --git a/eeschema/lib_edit_frame.cpp b/eeschema/lib_edit_frame.cpp index 45754fc33d..055cf67bf1 100644 --- a/eeschema/lib_edit_frame.cpp +++ b/eeschema/lib_edit_frame.cpp @@ -186,6 +186,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY, LIB_EDIT_FRAME::OnUpdateSaveLib ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY_AS, LIB_EDIT_FRAME::OnUpdateSaveLibAs ) + EVT_UPDATE_UI( ID_LIBEDIT_SAVE_ALL_LIBS, LIB_EDIT_FRAME::OnUpdateSaveAll ) EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnUpdateViewDoc ) EVT_UPDATE_UI( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnUpdateSyncPinEdit ) EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnUpdatePinTable ) @@ -571,6 +572,24 @@ void LIB_EDIT_FRAME::OnUpdateSaveLibAs( wxUpdateUIEvent& event ) } +void LIB_EDIT_FRAME::OnUpdateSaveAll( wxUpdateUIEvent& event ) +{ + int modified = 0; + + for( const auto& lib : m_libMgr->GetLibraryNames() ) + { + if( m_libMgr->IsLibraryModified( lib ) ) + modified++; + + if( modified > 1 ) + break; + } + + event.SetText( modified > 1 ? _( "Save All &Libraries..." ) : _( "Save All &Libraries" ) ); + event.Enable( modified > 0 ); +} + + void LIB_EDIT_FRAME::OnUpdateViewDoc( wxUpdateUIEvent& event ) { bool enable = false; @@ -1612,27 +1631,19 @@ LIB_PART* LIB_EDIT_FRAME::getTargetPart() const LIB_ID LIB_EDIT_FRAME::getTargetLibId() const { - if( m_treePane->GetCmpTree()->IsMenuActive() ) - return m_treePane->GetCmpTree()->GetSelectedLibId(); + LIB_ID id = m_treePane->GetCmpTree()->GetSelectedLibId(); + wxString nickname = id.GetLibNickname(); - if( LIB_PART* part = GetCurPart() ) - return part->GetLibId(); + if( nickname.IsEmpty() && GetCurPart() ) + id = GetCurPart()->GetLibId(); - return LIB_ID(); + return id; } wxString LIB_EDIT_FRAME::getTargetLib() const { - if( m_treePane->GetCmpTree()->IsMenuActive() ) - { - LIB_ID libId = m_treePane->GetCmpTree()->GetSelectedLibId(); - return libId.GetLibNickname(); - } - else - { - return GetCurLib(); - } + return getTargetLibId().GetLibNickname(); } diff --git a/eeschema/lib_edit_frame.h b/eeschema/lib_edit_frame.h index 44331d76d6..eb27bf7053 100644 --- a/eeschema/lib_edit_frame.h +++ b/eeschema/lib_edit_frame.h @@ -342,6 +342,7 @@ public: void OnUpdateRedo( wxUpdateUIEvent& event ); void OnUpdateSaveLib( wxUpdateUIEvent& event ); void OnUpdateSaveLibAs( wxUpdateUIEvent& event ); + void OnUpdateSaveAll( wxUpdateUIEvent& event ); void OnUpdateViewDoc( wxUpdateUIEvent& event ); void OnUpdateSyncPinEdit( wxUpdateUIEvent& event ); void OnUpdatePinTable( wxUpdateUIEvent& event ); diff --git a/eeschema/menubar_libedit.cpp b/eeschema/menubar_libedit.cpp index ccb11ca3a3..f2350c4343 100644 --- a/eeschema/menubar_libedit.cpp +++ b/eeschema/menubar_libedit.cpp @@ -74,7 +74,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() AddMenuItem( fileMenu, ID_LIBEDIT_SAVE_LIBRARY, _( "&Save Library" ), - _( "Save the current active library" ), + _( "Save the current library" ), KiBitmap( save_library_xpm ) ); AddMenuItem( fileMenu, diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index 1b449ba1ba..c867ec8178 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -119,9 +119,9 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() KiScaledBitmap( add_library_xpm, this ), _( "Add an existing library" ) ); - m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_LIBRARY, wxEmptyString, + m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_ALL_LIBS, wxEmptyString, KiScaledBitmap( save_library_xpm, this ), - _( "Save current library" ) ); + _( "Save all libraries" ) ); KiScaledSeparator( m_mainToolBar, this );