Add action info to Undo/Redo menus.
Note that this only works where a BOARD_COMMIT or SCHEMATIC_COMMIT is used. (BOARD_COMMIT is used almost universally in PCBNew, but SCHEMATIC_COMMIT has very little adoption in EEschema so far.)
This commit is contained in:
parent
30cbfc794f
commit
d5b5a3eaf4
|
@ -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;
|
||||
|
|
|
@ -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<SCH_EDIT_FRAME*>( m_toolMgr->GetToolHolder() )->Schematic();
|
||||
std::vector<SCH_ITEM*> bulkAddedItems;
|
||||
std::vector<SCH_ITEM*> bulkRemovedItems;
|
||||
|
|
|
@ -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() )
|
||||
|
|
|
@ -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; }
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <eda_item_flags.h>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <wx/string.h>
|
||||
|
||||
class EDA_ITEM;
|
||||
class PICKED_ITEMS_LIST;
|
||||
|
@ -132,9 +133,6 @@ private:
|
|||
*/
|
||||
class PICKED_ITEMS_LIST
|
||||
{
|
||||
private:
|
||||
std::vector <ITEM_PICKER> 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<ITEM_PICKER> m_ItemsList;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -245,6 +245,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
|
|||
if( Empty() )
|
||||
return;
|
||||
|
||||
undoList.SetDescription( aMessage );
|
||||
|
||||
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
|
||||
|
||||
// Note:
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue