diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 153bb37ca2..de49d98d0b 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -407,6 +407,25 @@ void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAM return; } + if( showRes && aEvent.GetId() == ACTIONS::undo.GetUIId() ) + { + wxString msg = _( "Undo" ); + + if( enableRes ) + msg += wxS( " " ) + aFrame->GetUndoActionDescription(); + + aEvent.SetText( msg ); + } + else if( showRes && aEvent.GetId() == ACTIONS::redo.GetUIId() ) + { + wxString msg = _( "Redo" ); + + if( enableRes ) + msg += wxS( " " ) + aFrame->GetRedoActionDescription(); + + aEvent.SetText( msg ); + } + if( isCut || isCopy || isPaste ) { wxWindow* focus = wxWindow::FindFocus(); @@ -1394,6 +1413,24 @@ PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromRedoList( ) } +wxString EDA_BASE_FRAME::GetUndoActionDescription() const +{ + if( GetUndoCommandCount() > 0 ) + return m_undoList.m_CommandsList.back()->GetDescription(); + + return wxEmptyString; +} + + +wxString EDA_BASE_FRAME::GetRedoActionDescription() const +{ + if( GetRedoCommandCount() > 0 ) + return m_redoList.m_CommandsList.back()->GetDescription(); + + return wxEmptyString; +} + + void EDA_BASE_FRAME::OnModify() { m_autoSaveRequired = true; diff --git a/eeschema/schematic_commit.cpp b/eeschema/schematic_commit.cpp index 187e391da2..c5e8d05528 100644 --- a/eeschema/schematic_commit.cpp +++ b/eeschema/schematic_commit.cpp @@ -119,6 +119,8 @@ void SCHEMATIC_COMMIT::pushLibEdit( const wxString& aMessage, int aCommitFlags ) if( Empty() ) return; + undoList.SetDescription( aMessage ); + for( COMMIT_LINE& ent : m_changes ) { int changeType = ent.m_type & CHT_TYPE; @@ -249,6 +251,8 @@ void SCHEMATIC_COMMIT::pushSchEdit( const wxString& aMessage, int aCommitFlags ) if( Empty() ) return; + undoList.SetDescription( aMessage ); + SCHEMATIC& schematic = static_cast( m_toolMgr->GetToolHolder() )->Schematic(); std::vector bulkAddedItems; std::vector bulkRemovedItems; diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 8544994561..d6f31c1fa7 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -193,7 +193,10 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, } if( !commandToUndo ) + { commandToUndo = new PICKED_ITEMS_LIST(); + commandToUndo->SetDescription( aItemsList.GetDescription() ); + } // Copy picker list: if( !commandToUndo->GetCount() ) diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index e45b5566c8..11fd28cf26 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -575,6 +575,9 @@ public: virtual int GetUndoCommandCount() const { return m_undoList.m_CommandsList.size(); } virtual int GetRedoCommandCount() const { return m_redoList.m_CommandsList.size(); } + virtual wxString GetUndoActionDescription() const; + virtual wxString GetRedoActionDescription() const; + int GetMaxUndoItems() const { return m_undoRedoCountMax; } /** diff --git a/include/undo_redo_container.h b/include/undo_redo_container.h index f20d10feaf..cd1500b44e 100644 --- a/include/undo_redo_container.h +++ b/include/undo_redo_container.h @@ -30,6 +30,7 @@ #include #include #include +#include class EDA_ITEM; class PICKED_ITEMS_LIST; @@ -132,9 +133,6 @@ private: */ class PICKED_ITEMS_LIST { -private: - std::vector m_ItemsList; - public: PICKED_ITEMS_LIST(); ~PICKED_ITEMS_LIST(); @@ -288,6 +286,13 @@ public: * @param aSource The list of items to copy to the list. */ void CopyList( const PICKED_ITEMS_LIST& aSource ); + + wxString GetDescription() const { return m_description; } + void SetDescription( const wxString& aDescription ) { m_description = aDescription; } + +private: + wxString m_description; + std::vector m_ItemsList; }; diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 670ca26aba..c070ed7fa1 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -245,6 +245,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags ) if( Empty() ) return; + undoList.SetDescription( aMessage ); + std::shared_ptr connectivity = board->GetConnectivity(); // Note: diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index 49049863ef..b112c3726e 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -293,6 +293,7 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis UNDO_REDO aCommandType ) { PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); + commandToUndo->SetDescription( aItemsList.GetDescription() ); saveCopyInUndoList( commandToUndo, aItemsList, aCommandType ); } @@ -304,7 +305,10 @@ void PCB_BASE_EDIT_FRAME::AppendCopyToUndoList( const PICKED_ITEMS_LIST& aItemsL PICKED_ITEMS_LIST* commandToUndo = PopCommandFromUndoList(); if( !commandToUndo ) + { commandToUndo = new PICKED_ITEMS_LIST(); + commandToUndo->SetDescription( aItemsList.GetDescription() ); + } saveCopyInUndoList( commandToUndo, aItemsList, aCommandType ); }