Make sure dir case can handle multiple selection too.

Files case already can.

Fixes https://gitlab.com/kicad/code/kicad/issues/8465
This commit is contained in:
Jeff Young 2021-05-22 20:38:36 +01:00
parent a06f965ffa
commit ee00d8386f
1 changed files with 18 additions and 16 deletions

View File

@ -798,10 +798,9 @@ void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
title.Printf( _( "Select %s Library" ), fileType.m_Description ); title.Printf( _( "Select %s Library" ), fileType.m_Description );
wxString openDir = cfg->m_lastFootprintLibDir; wxString openDir = cfg->m_lastFootprintLibDir;
if( m_cur_grid == m_project_grid ) if( m_cur_grid == m_project_grid )
{
openDir = m_lastProjectLibDir; openDir = m_lastProjectLibDir;
}
if( fileType.m_IsFile ) if( fileType.m_IsFile )
{ {
@ -816,22 +815,28 @@ void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
dlg.GetPaths( files ); dlg.GetPaths( files );
if( m_cur_grid == m_global_grid )
cfg->m_lastFootprintLibDir = dlg.GetDirectory(); cfg->m_lastFootprintLibDir = dlg.GetDirectory();
else
m_lastProjectLibDir = dlg.GetDirectory();
} }
else else
{ {
wxDirDialog dlg( nullptr, title, openDir, wxDirDialog dlg( nullptr, title, openDir,
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_MULTIPLE );
int result = dlg.ShowModal(); int result = dlg.ShowModal();
if( result == wxID_CANCEL ) if( result == wxID_CANCEL )
return; return;
dlg.GetPaths( files );
// is there a file extension configured to hunt out their containing folders? // is there a file extension configured to hunt out their containing folders?
if( fileType.m_FolderSearchExtension != "" ) if( files.GetCount() == 1 && fileType.m_FolderSearchExtension != "" )
{ {
wxDir rootDir( dlg.GetPath() ); wxDir rootDir( files.front() );
files.clear();
LIBRARY_TRAVERSER traverser( fileType.m_FolderSearchExtension, rootDir.GetName() ); LIBRARY_TRAVERSER traverser( fileType.m_FolderSearchExtension, rootDir.GetName() );
rootDir.Traverse( traverser ); rootDir.Traverse( traverser );
@ -851,18 +856,15 @@ void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
detailedMsg ); detailedMsg );
} }
} }
else
if( !files.IsEmpty() )
{ {
files.Add( dlg.GetPath() ); wxFileName first( files.front() );
}
if( m_cur_grid == m_global_grid ) if( m_cur_grid == m_global_grid )
{ cfg->m_lastFootprintLibDir = first.GetPath();
cfg->m_lastFootprintLibDir = dlg.GetPath();
}
else else
{ m_lastProjectLibDir = first.GetPath();
m_lastProjectLibDir = dlg.GetPath();
} }
} }