From 4f7430f47629fffe346a2e7805cf855e3a014bc4 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 19 Dec 2019 15:35:11 +0000 Subject: [PATCH] Add save item to cvpcb toolbar and make it conditional ADD: Save icon to cvpcb toolbar and make it conditional --- cvpcb/menubar.cpp | 7 ++++++- cvpcb/toolbars_cvpcb.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index c0d9e90886..89e86221ef 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -45,7 +45,12 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() // CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, tool ); - fileMenu->AddItem( CVPCB_ACTIONS::saveAssociations, SELECTION_CONDITIONS::ShowAlways ); + auto enableSaveCondition = [ this ] ( const SELECTION& sel ) + { + return IsContentModified(); + }; + + fileMenu->AddItem( CVPCB_ACTIONS::saveAssociations, enableSaveCondition ); fileMenu->AddSeparator(); fileMenu->AddClose( _( "Assign Footprints" ) ); diff --git a/cvpcb/toolbars_cvpcb.cpp b/cvpcb/toolbars_cvpcb.cpp index 36a25c7dc8..870a4a2339 100644 --- a/cvpcb/toolbars_cvpcb.cpp +++ b/cvpcb/toolbars_cvpcb.cpp @@ -40,6 +40,9 @@ void CVPCB_MAINFRAME::ReCreateHToolbar() m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize, KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT ); + m_mainToolBar->Add( CVPCB_ACTIONS::saveAssociations ); + + KiScaledSeparator( m_mainToolBar, this ); m_mainToolBar->Add( ACTIONS::showFootprintLibTable ); KiScaledSeparator( m_mainToolBar, this ); @@ -85,8 +88,9 @@ void CVPCB_MAINFRAME::SyncToolbars() { #define filterActive( filter ) ( m_filteringOptions & filter ) - m_mainToolBar->Toggle( ACTIONS::undo, m_undoList.size() > 0 ); - m_mainToolBar->Toggle( ACTIONS::redo, m_redoList.size() > 0 ); + m_mainToolBar->Toggle( CVPCB_ACTIONS::saveAssociations, IsContentModified() ); + m_mainToolBar->Toggle( ACTIONS::undo, m_undoList.size() > 0 ); + m_mainToolBar->Toggle( ACTIONS::redo, m_redoList.size() > 0 ); m_mainToolBar->Toggle( CVPCB_ACTIONS::FilterFPbyFPFilters, filterActive( FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_FP_FILTERS ) );