Commit 143debdd authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Rework on recovery files menu

parent bde103f5
......@@ -85,12 +85,21 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
LoadOnePcbFile( GetBoard()->GetFileName(), false, true );
break;
case ID_MENU_READ_LAST_SAVED_VERSION_BOARD:
case ID_MENU_READ_BOARD_BACKUP_FILE:
case ID_MENU_RECOVER_BOARD_AUTOSAVE:
{
wxFileName fn;
fn = GetBoard()->GetFileName();
wxString backup_ext = fn.GetExt()+ backupFileExtensionSuffix;
fn.SetExt( backup_ext );
wxFileName currfn = GetBoard()->GetFileName();
wxFileName fn = currfn;
if( id == ID_MENU_RECOVER_BOARD_AUTOSAVE )
{
wxString rec_name = wxT("$") + fn.GetName();
fn.SetName( rec_name );
}
else
{
wxString backup_ext = fn.GetExt()+ backupFileExtensionSuffix;
fn.SetExt( backup_ext );
}
if( !fn.FileExists() )
{
......@@ -99,19 +108,18 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
DisplayInfoMessage( this, msg );
break;
}
else
{
msg.Printf( _( "OK to load recovery file <%s>" ), GetChars(fn.GetFullPath() ) );
if( !IsOK( this, msg ) )
break;
}
msg.Printf( _( "OK to load recovery or backup file <%s>" ),
GetChars(fn.GetFullPath() ) );
if( !IsOK( this, msg ) )
break;
GetScreen()->ClrModify(); // do not prompt the user for changes
LoadOnePcbFile( fn.GetFullPath(), false );
fn.SetExt( PcbFileExtension );
// Re-set the name since extension changed
GetBoard()->SetFileName( fn.GetFullPath() );
// Re-set the name since name or extension was changed
GetBoard()->SetFileName( currfn.GetFullPath() );
UpdateTitle();
}
break;
......
......@@ -112,9 +112,14 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
filesMenu->AppendSeparator();
// Revert
AddMenuItem( filesMenu, ID_MENU_READ_LAST_SAVED_VERSION_BOARD,
_( "Revert" ),
_( "Clear board and get previous saved version of board" ),
AddMenuItem( filesMenu, ID_MENU_READ_BOARD_BACKUP_FILE,
_( "Revert to Last" ),
_( "Clear board and get previous backup version of board" ),
KiBitmap( help_xpm ) );
// Rescue
AddMenuItem( filesMenu, ID_MENU_RECOVER_BOARD_AUTOSAVE, _( "Rescue" ),
_( "Clear board and get last rescue file automatically saved by Pcbnew" ),
KiBitmap( help_xpm ) );
filesMenu->AppendSeparator();
......
......@@ -77,7 +77,8 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_SIZE( PCB_EDIT_FRAME::OnSize )
EVT_TOOL( ID_LOAD_FILE, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_MENU_READ_LAST_SAVED_VERSION_BOARD, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_MENU_READ_BOARD_BACKUP_FILE, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_MENU_RECOVER_BOARD_AUTOSAVE, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_NEW_BOARD, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_SAVE_BOARD, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_OPEN_MODULE_EDITOR, PCB_EDIT_FRAME::Process_Special_Functions )
......
......@@ -231,7 +231,8 @@ enum pcbnew_ids
ID_POPUP_PCB_REORIENT_ALL_MODULES,
ID_MENU_READ_LAST_SAVED_VERSION_BOARD,
ID_MENU_READ_BOARD_BACKUP_FILE,
ID_MENU_RECOVER_BOARD_AUTOSAVE,
ID_MENU_ARCHIVE_MODULES,
ID_MENU_ARCHIVE_NEW_MODULES,
ID_MENU_ARCHIVE_ALL_MODULES,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment