Formatting.
This commit is contained in:
parent
d9d906e652
commit
d4e68a985c
149
pcbnew/files.cpp
149
pcbnew/files.cpp
|
@ -306,66 +306,71 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id )
|
||||||
switch( id )
|
switch( id )
|
||||||
{
|
{
|
||||||
case ID_LOAD_FILE:
|
case ID_LOAD_FILE:
|
||||||
{
|
{
|
||||||
int open_ctl = 0;
|
int open_ctl = 0;
|
||||||
wxString fileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
wxString fileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
||||||
|
|
||||||
return AskLoadBoardFileName( this, &open_ctl, &fileName, true )
|
return AskLoadBoardFileName( this, &open_ctl, &fileName, true )
|
||||||
&& OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
|
&& OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
|
||||||
}
|
}
|
||||||
|
|
||||||
case ID_IMPORT_NON_KICAD_BOARD:
|
case ID_IMPORT_NON_KICAD_BOARD:
|
||||||
{
|
{
|
||||||
int open_ctl = 1;
|
int open_ctl = 1;
|
||||||
wxString fileName; // = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
wxString fileName; // = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
||||||
|
|
||||||
return AskLoadBoardFileName( this, &open_ctl, &fileName, false )
|
return AskLoadBoardFileName( this, &open_ctl, &fileName, false )
|
||||||
&& OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
|
&& OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
|
||||||
}
|
}
|
||||||
|
|
||||||
case ID_MENU_RECOVER_BOARD_AUTOSAVE:
|
case ID_MENU_RECOVER_BOARD_AUTOSAVE:
|
||||||
|
{
|
||||||
|
wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
||||||
|
wxFileName fn = currfn;
|
||||||
|
|
||||||
|
wxString rec_name = GetAutoSaveFilePrefix() + fn.GetName();
|
||||||
|
fn.SetName( rec_name );
|
||||||
|
|
||||||
|
if( !fn.FileExists() )
|
||||||
{
|
{
|
||||||
wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
msg.Printf( _( "Recovery file \"%s\" not found." ), fn.GetFullPath() );
|
||||||
wxFileName fn = currfn;
|
DisplayInfoMessage( this, msg );
|
||||||
|
|
||||||
wxString rec_name = GetAutoSaveFilePrefix() + fn.GetName();
|
|
||||||
fn.SetName( rec_name );
|
|
||||||
|
|
||||||
if( !fn.FileExists() )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Recovery file \"%s\" not found." ), fn.GetFullPath() );
|
|
||||||
DisplayInfoMessage( this, msg );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.Printf( _( "OK to load recovery file \"%s\"" ), fn.GetFullPath() );
|
|
||||||
|
|
||||||
if( !IsOK( this, msg ) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
GetScreen()->ClrModify(); // do not prompt the user for changes
|
|
||||||
|
|
||||||
if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
|
|
||||||
{
|
|
||||||
// Re-set the name since name or extension was changed
|
|
||||||
GetBoard()->SetFileName( currfn.GetFullPath() );
|
|
||||||
UpdateTitle();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg.Printf( _( "OK to load recovery file \"%s\"" ), fn.GetFullPath() );
|
||||||
|
|
||||||
|
if( !IsOK( this, msg ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GetScreen()->ClrModify(); // do not prompt the user for changes
|
||||||
|
|
||||||
|
if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
|
||||||
|
{
|
||||||
|
// Re-set the name since name or extension was changed
|
||||||
|
GetBoard()->SetFileName( currfn.GetFullPath() );
|
||||||
|
UpdateTitle();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
case ID_NEW_BOARD:
|
case ID_NEW_BOARD:
|
||||||
{
|
{
|
||||||
if( IsContentModified() )
|
if( IsContentModified() )
|
||||||
{
|
{
|
||||||
wxFileName fileName = GetBoard()->GetFileName();
|
wxFileName fileName = GetBoard()->GetFileName();
|
||||||
wxString saveMsg =
|
wxString saveMsg = _( "Current board will be closed, save changes to '%s' before "
|
||||||
_( "Current board will be closed, save changes to \"%s\" before continuing?" );
|
"continuing?" );
|
||||||
|
|
||||||
if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ),
|
if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ),
|
||||||
[&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) )
|
[&]()->bool
|
||||||
|
{
|
||||||
|
return Files_io_from_id( ID_SAVE_BOARD );
|
||||||
|
} ) )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( !GetBoard()->IsEmpty() )
|
else if( !GetBoard()->IsEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -401,43 +406,43 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id )
|
||||||
|
|
||||||
case ID_COPY_BOARD_AS:
|
case ID_COPY_BOARD_AS:
|
||||||
case ID_SAVE_BOARD_AS:
|
case ID_SAVE_BOARD_AS:
|
||||||
|
{
|
||||||
|
bool addToHistory = false;
|
||||||
|
wxString orig_name;
|
||||||
|
wxFileName::SplitPath( GetBoard()->GetFileName(), nullptr, nullptr, &orig_name, nullptr );
|
||||||
|
|
||||||
|
if( orig_name.IsEmpty() )
|
||||||
{
|
{
|
||||||
bool addToHistory = false;
|
addToHistory = true;
|
||||||
wxString orig_name;
|
orig_name = _( "noname" );
|
||||||
wxFileName::SplitPath( GetBoard()->GetFileName(), nullptr, nullptr, &orig_name,
|
}
|
||||||
nullptr );
|
|
||||||
|
|
||||||
if( orig_name.IsEmpty() )
|
wxFileName savePath( Prj().GetProjectFullName() );
|
||||||
{
|
|
||||||
addToHistory = true;
|
|
||||||
orig_name = _( "noname" );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFileName savePath( Prj().GetProjectFullName() );
|
if( !savePath.IsOk() || !savePath.IsDirWritable() )
|
||||||
|
{
|
||||||
|
savePath = GetMruPath();
|
||||||
|
|
||||||
if( !savePath.IsOk() || !savePath.IsDirWritable() )
|
if( !savePath.IsOk() || !savePath.IsDirWritable() )
|
||||||
{
|
savePath = PATHS::GetDefaultUserProjectsPath();
|
||||||
savePath = GetMruPath();
|
|
||||||
|
|
||||||
if( !savePath.IsOk() || !savePath.IsDirWritable() )
|
|
||||||
savePath = PATHS::GetDefaultUserProjectsPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFileName fn( savePath.GetPath(), orig_name, KiCadPcbFileExtension );
|
|
||||||
wxString filename = fn.GetFullPath();
|
|
||||||
|
|
||||||
bool createProject = false;
|
|
||||||
|
|
||||||
if( AskSaveBoardFileName( this, &filename, &createProject ) )
|
|
||||||
{
|
|
||||||
if( id == ID_COPY_BOARD_AS )
|
|
||||||
return SavePcbCopy( filename, createProject );
|
|
||||||
else
|
|
||||||
return SavePcbFile( filename, addToHistory, createProject );
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxFileName fn( savePath.GetPath(), orig_name, KiCadPcbFileExtension );
|
||||||
|
wxString filename = fn.GetFullPath();
|
||||||
|
|
||||||
|
bool createProject = false;
|
||||||
|
|
||||||
|
if( AskSaveBoardFileName( this, &filename, &createProject ) )
|
||||||
|
{
|
||||||
|
if( id == ID_COPY_BOARD_AS )
|
||||||
|
return SavePcbCopy( filename, createProject );
|
||||||
|
else
|
||||||
|
return SavePcbFile( filename, addToHistory, createProject );
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -756,7 +756,9 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprint( FOOTPRINT* aFootprint )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( libraryName.IsEmpty() || footprintName.IsEmpty() )
|
else if( libraryName.IsEmpty() || footprintName.IsEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -767,7 +769,9 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprint( FOOTPRINT* aFootprint )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
||||||
|
|
Loading…
Reference in New Issue