Commit 1a749130 authored by jean-pierre charras's avatar jean-pierre charras

Minor fixes: fix issue Bug #1420910 (Linux specific).

Rename eeschema/dialogs/dialog_sch_find.fbp to dialog_schematic_find_base.fbp, to be consistent with other dialogs. 
Pcbnew run from the project manager: add menu Save Copy As..., which is the same command as Save As ... in stand alone mode, but with the constraints of a project (no cwd change, no board filename change, and keep project settings)
parent 74e83e92
......@@ -81,7 +81,16 @@ void DIALOG_CHOOSE_COMPONENT::OnSearchBoxChange( wxCommandEvent& aEvent )
{
m_search_container->UpdateSearchTerm( m_searchBox->GetLineText( 0 ) );
updateSelection();
// On Windows, but not on Linux, the focus is given to
// the m_libraryComponentTree, after modificatuons.
// We want the focus for m_searchBox.
//
// We cannot call SetFocus on Linux because it changes the current text selection
// and the text edit cursor position.
#ifdef __WINDOWS__
m_searchBox->SetFocus();
#endif
}
......
......@@ -848,12 +848,14 @@ public:
/**
* Function AppendBoardFile
* appends a board file onto the current one, creating God knows what.
* the main purpose is only to allow panelizing boards.
*/
bool AppendBoardFile( const wxString& aFullFileName, int aCtl );
/**
* Function SavePcbFile
* writes the board data structures to \a a aFileName
* Creates backup when requested and update flags (modified and saved flgs)
*
* @param aFileName The file name to write or wxEmptyString to prompt user for
* file name.
......@@ -864,8 +866,18 @@ public:
*/
bool SavePcbFile( const wxString& aFileName, bool aCreateBackupFile = CREATE_BACKUP_FILE );
int SavePcbFormatAscii( FILE* File );
bool WriteGeneralDescrPcb( FILE* File );
/**
* Function SavePcbCopy
* writes the board data structures to \a a aFileName
* but unlike SavePcbFile, does not make anything else
* (no backup, borad fliename change, no flag changes ...)
* Used under a project mgr to save under a new name the current board
*
* When not under a project mgr, the full SavePcbFile is used.
* @param aFileName The file name to write.
* @return True if file was saved successfully.
*/
bool SavePcbCopy( const wxString& aFileName );
// BOARD handling
......
......@@ -327,14 +327,20 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
break;
}
// Fall through
case ID_SAVE_BOARD_AS:
case ID_COPY_BOARD_AS:
case ID_SAVE_BOARD_AS:
{
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
wxFileName fn( pro_dir, _( "noname" ), KiCadPcbFileExtension );
wxString filename = fn.GetFullPath();
if( AskSaveBoardFileName( this, &filename ) )
SavePcbFile( filename, true );
{
if( id == ID_COPY_BOARD_AS )
SavePcbCopy( filename );
else
SavePcbFile( filename, NO_BACKUP_FILE );
}
}
break;
......@@ -412,7 +418,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
if( response == wxID_CANCEL )
return false;
else if( response == wxID_YES )
SavePcbFile( GetBoard()->GetFileName(), true );
SavePcbFile( GetBoard()->GetFileName(), CREATE_BACKUP_FILE );
else
{
// response == wxID_NO, fall thru
......@@ -660,6 +666,8 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
wxString backupFileName;
// aCreateBackupFile == false is mainly used to write autosave files
// or new files in save as... command
if( aCreateBackupFile )
{
backupFileName = create_backup_file( aFileName );
......@@ -733,6 +741,58 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
}
bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName )
{
wxFileName pcbFileName = aFileName;
// Ensure the file ext is the right ext:
pcbFileName.SetExt( KiCadPcbFileExtension );
if( !IsWritable( pcbFileName ) )
{
wxString msg = wxString::Format( _(
"No access rights to write to file '%s'" ),
GetChars( pcbFileName.GetFullPath() )
);
DisplayError( this, msg );
return false;
}
GetBoard()->m_Status_Pcb &= ~CONNEXION_OK;
GetBoard()->SynchronizeNetsAndNetClasses();
// Select default Netclass before writing file.
// Useful to save default values in headers
SetCurrentNetClass( NETCLASS::Default );
try
{
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::KICAD ) );
wxASSERT( pcbFileName.IsAbsolute() );
pi->Save( pcbFileName.GetFullPath(), GetBoard(), NULL );
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _(
"Error saving board file '%s'.\n%s" ),
GetChars( pcbFileName.GetFullPath() ),
GetChars( ioe.errorText )
);
DisplayError( this, msg );
return false;
}
DisplayInfoMessage( this, wxString::Format( _( "Board copied to:\n'%s'" ),
GetChars( pcbFileName.GetFullPath() ) ) );
return true;
}
bool PCB_EDIT_FRAME::doAutoSave()
{
wxFileName tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
......
......@@ -111,14 +111,29 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
_( "Save current board" ),
KiBitmap( save_xpm ) );
if( Kiface().IsSingle() ) // not when under a project mgr
// Save as menu:
// under a project mgr we do not want to modify the board filename
// to keep consistency with the project mgr which expects files names same as prj name
// for main files
// when not under a project mgr, we are free to change filenames, cwd ...
if( Kiface().IsSingle() ) // not when under a project mgr (pcbnew is run as stand alone)
{
text = AddHotkeyName( _( "Sa&ve As..." ), g_Board_Editor_Hokeys_Descr, HK_SAVE_BOARD_AS );
AddMenuItem( filesMenu, ID_SAVE_BOARD_AS, text,
_( "Save the current board as..." ),
KiBitmap( save_as_xpm ) );
filesMenu->AppendSeparator();
}
// under a project mgr, we can save a copy of the board,
// but do not change the current board file name
else
{
text = AddHotkeyName( _( "Sa&ve Copy As..." ), g_Board_Editor_Hokeys_Descr, HK_SAVE_BOARD_AS );
AddMenuItem( filesMenu, ID_COPY_BOARD_AS, text,
_( "Save a copy of the current board as..." ),
KiBitmap( save_as_xpm ) );
}
filesMenu->AppendSeparator();
AddMenuItem( filesMenu, ID_MENU_READ_BOARD_BACKUP_FILE,
_( "Revert to Last" ),
......
......@@ -120,6 +120,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_APPEND_FILE, PCB_EDIT_FRAME::Files_io )
EVT_MENU( ID_SAVE_BOARD_AS, PCB_EDIT_FRAME::Files_io )
EVT_MENU( ID_COPY_BOARD_AS, PCB_EDIT_FRAME::Files_io )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, PCB_EDIT_FRAME::OnFileHistory )
EVT_MENU( ID_GEN_PLOT, PCB_EDIT_FRAME::ToPlotter )
......
......@@ -21,6 +21,7 @@ enum pcbnew_ids
ID_OPEN_MODULE_VIEWER,
ID_READ_NETLIST,
ID_SET_RELATIVE_OFFSET,
ID_COPY_BOARD_AS,
// Right vertical tool bar command IDs.
ID_PCB_HIGHLIGHT_BUTT,
......
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