ADDED revert for pcbnew and eeschema.
Fixes https://gitlab.com/kicad/code/kicad/issues/6802
This commit is contained in:
parent
9b087a3c25
commit
71c2cb3180
|
@ -91,6 +91,8 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
|
|||
else
|
||||
fileMenu->Add( EE_ACTIONS::saveCurrSheetCopyAs );
|
||||
|
||||
fileMenu->Add( ACTIONS::revert );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
fileMenu->Add( _( "Insert Schematic Sheet Content..." ),
|
||||
|
|
|
@ -113,6 +113,45 @@ int SCH_EDITOR_CONTROL::SaveCurrSheetCopyAs( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCHEMATIC& schematic = m_frame->Schematic();
|
||||
SCH_SHEET& root = schematic.Root();
|
||||
|
||||
if( m_frame->GetCurrentSheet().Last() != &root )
|
||||
{
|
||||
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
// Store the current zoom level into the current screen before switching
|
||||
m_frame->GetScreen()->m_LastZoomLevel = m_frame->GetCanvas()->GetView()->GetScale();
|
||||
|
||||
SCH_SHEET_PATH rootSheetPath;
|
||||
rootSheetPath.push_back( &root );
|
||||
m_frame->SetCurrentSheet( rootSheetPath );
|
||||
m_frame->DisplayCurrentSheet();
|
||||
|
||||
wxSafeYield();
|
||||
}
|
||||
|
||||
wxString msg;
|
||||
msg.Printf( _( "Revert '%s' (and all sub-sheets) to last version saved?" ),
|
||||
schematic.GetFileName() );
|
||||
|
||||
if( !IsOK( m_frame, msg ) )
|
||||
return false;
|
||||
|
||||
SCH_SCREENS screenList( schematic.Root() );
|
||||
|
||||
for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
|
||||
screen->SetContentModified( false ); // do not prompt the user for changes
|
||||
|
||||
m_frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFileName() ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::ShowSchematicSetup( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->ShowSchematicSetupDialog();
|
||||
|
@ -2296,6 +2335,7 @@ void SCH_EDITOR_CONTROL::setTransitions()
|
|||
Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
|
||||
//Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveCopyAs.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::SaveCurrSheetCopyAs, EE_ACTIONS::saveCurrSheetCopyAs.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::Revert, ACTIONS::revert.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::ShowSchematicSetup, EE_ACTIONS::schematicSetup.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::PageSetup, ACTIONS::pageSettings.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
|
||||
|
|
|
@ -53,6 +53,9 @@ public:
|
|||
|
||||
/// Saves the currently-open schematic sheet to an other name
|
||||
int SaveCurrSheetCopyAs( const TOOL_EVENT& aEvent );
|
||||
|
||||
int Revert( const TOOL_EVENT& aEvent );
|
||||
|
||||
int ShowSchematicSetup( const TOOL_EVENT& aEvent );
|
||||
int PageSetup( const TOOL_EVENT& aEvent );
|
||||
int Print( const TOOL_EVENT& aEvent );
|
||||
|
|
|
@ -369,6 +369,20 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id )
|
|||
return false;
|
||||
}
|
||||
|
||||
case ID_REVERT_BOARD:
|
||||
{
|
||||
wxFileName fn = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
||||
|
||||
msg.Printf( _( "Revert '%s' to last version saved?" ), fn.GetFullPath() );
|
||||
|
||||
if( !IsOK( this, msg ) )
|
||||
return false;
|
||||
|
||||
GetScreen()->SetContentModified( false ); // do not prompt the user for changes
|
||||
|
||||
return OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
||||
}
|
||||
|
||||
case ID_NEW_BOARD:
|
||||
{
|
||||
if( IsContentModified() )
|
||||
|
|
|
@ -99,6 +99,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
|||
else
|
||||
fileMenu->Add( ACTIONS::saveCopyAs );
|
||||
|
||||
fileMenu->Add( ACTIONS::revert );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
fileMenu->Add( _( "Resc&ue" ),
|
||||
_( "Clear board and get last rescue file automatically saved by PCB editor" ),
|
||||
|
|
|
@ -15,6 +15,7 @@ enum pcbnew_ids
|
|||
{
|
||||
ID_MAIN_MENUBAR = ID_END_LIST,
|
||||
ID_COPY_BOARD_AS,
|
||||
ID_REVERT_BOARD,
|
||||
ID_IMPORT_NON_KICAD_BOARD,
|
||||
|
||||
// Tracks and vias sizes general options
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 CERN
|
||||
* Copyright (C) 2014-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -325,6 +325,13 @@ int BOARD_EDITOR_CONTROL::SaveCopyAs( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int BOARD_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->Files_io_from_id( ID_REVERT_BOARD );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int BOARD_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
PICKED_ITEMS_LIST undoCmd;
|
||||
|
@ -1603,6 +1610,7 @@ void BOARD_EDITOR_CONTROL::setTransitions()
|
|||
Go( &BOARD_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
|
||||
Go( &BOARD_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
|
||||
Go( &BOARD_EDITOR_CONTROL::SaveCopyAs, ACTIONS::saveCopyAs.MakeEvent() );
|
||||
Go( &BOARD_EDITOR_CONTROL::Revert, ACTIONS::revert.MakeEvent() );
|
||||
Go( &BOARD_EDITOR_CONTROL::PageSettings, ACTIONS::pageSettings.MakeEvent() );
|
||||
Go( &BOARD_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 CERN
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -56,6 +56,7 @@ public:
|
|||
int Save( const TOOL_EVENT& aEvent );
|
||||
int SaveAs( const TOOL_EVENT& aEvent );
|
||||
int SaveCopyAs( const TOOL_EVENT& aEvent );
|
||||
int Revert( const TOOL_EVENT& aEvent );
|
||||
int PageSettings( const TOOL_EVENT& aEvent );
|
||||
int Plot( const TOOL_EVENT& aEvent );
|
||||
|
||||
|
|
Loading…
Reference in New Issue