Don't infer two projects when we find both .kicad_pro and .pro.
Also makes the terminology around folder/directory consistent in the error messages and dialogs. Fixes https://gitlab.com/kicad/code/kicad/issues/8481
This commit is contained in:
parent
75ce97e260
commit
b00d01dcc4
|
@ -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 );
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">3</property>
|
||||
<property name="border">10</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxHtmlWindow" expanded="1">
|
||||
|
@ -179,7 +179,16 @@
|
|||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
|
||||
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bsizerTemplateSelector</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
@ -209,7 +218,7 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Template path:</property>
|
||||
<property name="label">Folder:</property>
|
||||
<property name="markup">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
|
@ -240,16 +249,7 @@
|
|||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bsizerTemplateSelector</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxBOTTOM|wxLEFT|wxRIGHT</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxTextCtrl" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
@ -313,7 +313,7 @@
|
|||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
@ -386,7 +386,7 @@
|
|||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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<wxFileName> 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
|
||||
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.
|
||||
if( !( destFile.GetExt() == DrawingSheetFileExtension ) && !( destFile.GetExt() == "dcm"
|
||||
|| ( destFile.GetExt() == "lib" && !destFile.GetName().EndsWith( "-cache" ) ) ) )
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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() )
|
||||
|
|
Loading…
Reference in New Issue