diff --git a/kicad/dialogs/dialog_template_selector_base.cpp b/kicad/dialogs/dialog_template_selector_base.cpp index 9c90efdb82..88cf2eb785 100644 --- a/kicad/dialogs/dialog_template_selector_base.cpp +++ b/kicad/dialogs/dialog_template_selector_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -21,26 +21,26 @@ DIALOG_TEMPLATE_SELECTOR_BASE::DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, bmainSizer->Add( m_notebook, 0, wxEXPAND | wxALL, 3 ); m_htmlWin = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxHW_SCROLLBAR_AUTO ); - bmainSizer->Add( m_htmlWin, 1, wxALL|wxEXPAND, 3 ); - - m_staticTextTpath = new wxStaticText( this, wxID_ANY, _("Template path:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextTpath->Wrap( -1 ); - bmainSizer->Add( m_staticTextTpath, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + bmainSizer->Add( m_htmlWin, 1, wxALL|wxEXPAND, 10 ); wxBoxSizer* bsizerTemplateSelector; bsizerTemplateSelector = new wxBoxSizer( wxHORIZONTAL ); + m_staticTextTpath = new wxStaticText( this, wxID_ANY, _("Folder:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextTpath->Wrap( -1 ); + bsizerTemplateSelector->Add( m_staticTextTpath, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + m_tcTemplatePath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); - bsizerTemplateSelector->Add( m_tcTemplatePath, 1, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + bsizerTemplateSelector->Add( m_tcTemplatePath, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_buttonBrowse = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); - bsizerTemplateSelector->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + bsizerTemplateSelector->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); m_buttonValidate = new wxButton( this, wxID_ANY, _("Validate"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); - bsizerTemplateSelector->Add( m_buttonValidate, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + bsizerTemplateSelector->Add( m_buttonValidate, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - bmainSizer->Add( bsizerTemplateSelector, 0, wxEXPAND, 5 ); + bmainSizer->Add( bsizerTemplateSelector, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bmainSizer->Add( m_staticline, 0, wxEXPAND | wxALL, 5 ); diff --git a/kicad/dialogs/dialog_template_selector_base.fbp b/kicad/dialogs/dialog_template_selector_base.fbp index 888bacd79c..40169da4d1 100644 --- a/kicad/dialogs/dialog_template_selector_base.fbp +++ b/kicad/dialogs/dialog_template_selector_base.fbp @@ -119,7 +119,7 @@ - 3 + 10 wxALL|wxEXPAND 1 @@ -179,68 +179,7 @@ 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Template path: - 0 - - 0 - - - 0 - - 1 - m_staticTextTpath - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxEXPAND + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 @@ -249,7 +188,68 @@ none 5 - wxBOTTOM|wxLEFT|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Folder: + 0 + + 0 + + + 0 + + 1 + m_staticTextTpath + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT 1 1 @@ -313,7 +313,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -386,7 +386,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 diff --git a/kicad/dialogs/dialog_template_selector_base.h b/kicad/dialogs/dialog_template_selector_base.h index e65fe6bd9e..66b46c85d8 100644 --- a/kicad/dialogs/dialog_template_selector_base.h +++ b/kicad/dialogs/dialog_template_selector_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! diff --git a/kicad/project_template.cpp b/kicad/project_template.cpp index 5d7dca232d..c8e22f2c96 100644 --- a/kicad/project_template.cpp +++ b/kicad/project_template.cpp @@ -125,18 +125,20 @@ size_t PROJECT_TEMPLATE::GetDestinationFiles( const wxFileName& aNewProjectPath, // Find the template file name base. this is the name of the .pro template file wxString basename; - int projectCount = 0; + bool multipleProjectFilesFound = false; for( wxFileName& file : srcFiles ) { if( file.GetExt() == ProjectFileExtension || file.GetExt() == LegacyProjectFileExtension ) { + if( !basename.IsEmpty() && basename != file.GetName() ) + multipleProjectFilesFound = true; + basename = file.GetName(); - projectCount++; } } - if( projectCount != 1 ) + if( multipleProjectFilesFound ) basename = GetPrjDirName(); for( wxFileName& srcFile : srcFiles ) @@ -163,26 +165,29 @@ size_t PROJECT_TEMPLATE::GetDestinationFiles( const wxFileName& aNewProjectPath, bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath, wxString* aErrorMsg ) { - // CreateProject copy the files from template to the new project folder - // and rename files which have the same name as the template .pro file + // CreateProject copy the files from template to the new project folder and renames files + // which have the same name as the template .kicad_pro file bool result = true; std::vector srcFiles = GetFileList(); - // Find the template file name base. this is the name of the .pro template file + // Find the template file name base. this is the name of the .kicad_pro (or .pro) template + // file wxString basename; - int projectCount = 0; + bool multipleProjectFilesFound = false; for( wxFileName& file : srcFiles ) { if( file.GetExt() == ProjectFileExtension || file.GetExt() == LegacyProjectFileExtension ) { + if( !basename.IsEmpty() && basename != file.GetName() ) + multipleProjectFilesFound = true; + basename = file.GetName(); - projectCount++; } } - if( projectCount != 1 ) + if( multipleProjectFilesFound ) basename = GetPrjDirName(); for( wxFileName& srcFile : srcFiles ) @@ -193,10 +198,20 @@ bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath, wxString* aEr // Replace the template filename with the project filename for the new project creation wxString currname = destFile.GetName(); - // Do not rename project specific symbol libraries. This will break the symbol library - // table which will cause broken symbol library links in the schematic. - if( !( destFile.GetExt() == DrawingSheetFileExtension ) && !( destFile.GetExt() == "dcm" - || ( destFile.GetExt() == "lib" && !destFile.GetName().EndsWith( "-cache" ) ) ) ) + if( destFile.GetExt() == DrawingSheetFileExtension ) + { + // Skip these; they're often shared + } + if( destFile.GetName().EndsWith( "-cache" ) || destFile.GetName().EndsWith( "-rescue" ) ) + { + currname.Replace( basename, aNewProjectPath.GetName() ); + } + else if( destFile.GetExt() == "dcm" || destFile.GetExt() == "lib" ) + { + // Don't rename project-specific symbol libraries. This will break the symbol library + // table which will cause broken symbol library links in the schematic. + } + else { currname.Replace( basename, aNewProjectPath.GetName() ); } @@ -208,8 +223,7 @@ bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath, wxString* aEr wxString destpath = destFile.GetPathWithSep(); destpath.Replace( m_basePath.GetPathWithSep(), aNewProjectPath.GetPathWithSep() ); - // Check to see if the path already exists, if not attempt to create it here. Don't worry - // about error checking, if the path isn't created the file copy will fail anyway + // Check to see if the path already exists, if not attempt to create it here. if( !wxFileName::DirExists( destpath ) ) { if( !wxFileName::Mkdir( destpath, 0777, wxPATH_MKDIR_FULL ) ) @@ -221,7 +235,7 @@ bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath, wxString* aEr wxString msg; - msg.Printf( _( "Cannot create folder \"%s\"." ), destpath ); + msg.Printf( _( "Cannot create folder '%s'." ), destpath ); *aErrorMsg += msg; } @@ -240,7 +254,7 @@ bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath, wxString* aEr wxString msg; - msg.Printf( _( "Cannot copy file \"%s\"." ), destFile.GetFullPath() ); + msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() ); *aErrorMsg += msg; } diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp index 56ad82d292..ec6cb74850 100644 --- a/kicad/tools/kicad_manager_control.cpp +++ b/kicad/tools/kicad_manager_control.cpp @@ -42,8 +42,7 @@ public: DIR_CHECKBOX( wxWindow* aParent ) : wxPanel( aParent ) { - m_cbCreateDir = new wxCheckBox( this, wxID_ANY, - _( "Create a new directory for the project" ) ); + m_cbCreateDir = new wxCheckBox( this, wxID_ANY, _( "Create a new folder for the project" ) ); m_cbCreateDir->SetValue( true ); wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL ); @@ -116,8 +115,8 @@ int KICAD_MANAGER_CONTROL::NewProject( const TOOL_EVENT& aEvent ) if( !pro.Mkdir() ) { wxString msg; - msg.Printf( _( "Directory \"%s\" could not be created.\n\n" - "Please make sure you have write permissions and try again." ), + msg.Printf( _( "Folder '%s' could not be created.\n\n" + "Make sure you have write permissions and try again." ), pro.GetPath() ); DisplayErrorMessage( m_frame, msg ); return -1; @@ -125,9 +124,9 @@ int KICAD_MANAGER_CONTROL::NewProject( const TOOL_EVENT& aEvent ) } else if( directory.HasFiles() ) { - wxString msg = _( "The selected directory is not empty. It is recommended that you " - "create projects in their own empty directory.\n\nDo you " - "want to continue?" ); + wxString msg = _( "The selected folder is not empty. It is recommended that you " + "create projects in their own empty folder.\n\n" + "Do you want to continue?" ); if( !IsOK( m_frame, msg ) ) return -1; @@ -191,8 +190,8 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent ) wxFileName fn( dlg.GetPath() ); - // wxFileName automatically extracts an extension. But if it isn't - // a .pro extension, we should keep it as part of the filename + // wxFileName automatically extracts an extension. But if it isn't a .kicad_pro extension, + // we should keep it as part of the filename if( !fn.GetExt().IsEmpty() && fn.GetExt().ToStdString() != ProjectFileExtension ) fn.SetName( fn.GetName() + wxT( "." ) + fn.GetExt() ); @@ -213,8 +212,8 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent ) if( !fn.Mkdir() ) { wxString msg; - msg.Printf( _( "Directory \"%s\" could not be created.\n\n" - "Please make sure you have write permissions and try again." ), + msg.Printf( _( "Folder '%s' could not be created.\n\n" + "Make sure you have write permissions and try again." ), fn.GetPath() ); DisplayErrorMessage( m_frame, msg ); return -1; @@ -225,10 +224,9 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent ) { wxString msg; - msg.Printf( _( "Cannot write to folder \"%s\"." ), fn.GetPath() ); - wxMessageDialog msgDlg( m_frame, msg, _( "Error!" ), wxICON_ERROR | wxOK | wxCENTER ); - msgDlg.SetExtendedMessage( _( "Please check your access permissions to this folder " - "and try again." ) ); + msg.Printf( _( "Cannot write to folder '%s'." ), fn.GetPath() ); + wxMessageDialog msgDlg( m_frame, msg, _( "Error" ), wxICON_ERROR | wxOK | wxCENTER ); + msgDlg.SetExtendedMessage( _( "Make sure you have write permissions and try again." ) ); msgDlg.ShowModal(); return -1; } @@ -271,8 +269,8 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent ) if( !ps->GetSelectedTemplate()->CreateProject( fn, &errorMsg ) ) { wxMessageDialog createDlg( m_frame, - _( "A problem occurred creating new project from template!" ), - _( "Template Error" ), + _( "A problem occurred creating new project from template." ), + _( "Error" ), wxOK | wxICON_ERROR ); if( !errorMsg.empty() )