MSW and GTK need a separate dialog for opening/saving directories.
Fixes: lp:1801528 * https://bugs.launchpad.net/kicad/+bug/1801528
This commit is contained in:
parent
68b07d1aff
commit
589e1f6a96
|
@ -1738,28 +1738,40 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
|
|||
|
||||
wxString EDA_DRAW_FRAME::GetScreenDesc() const
|
||||
{
|
||||
// Virtual function. In basic class, returns
|
||||
// an empty string.
|
||||
// Virtual function. Base class implementation returns an empty string.
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
|
||||
const wxString& wildcard, const wxString& ext )
|
||||
const wxString& wildcard, const wxString& ext,
|
||||
bool isDirectory )
|
||||
{
|
||||
wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
|
||||
aFilename.SetExt( ext );
|
||||
|
||||
wxFileDialog dlg( this,
|
||||
doOpen ? _( "Select Library" ) : _( "New Library" ),
|
||||
Prj().GetProjectPath(),
|
||||
doOpen ? wxString( wxEmptyString ) : aFilename.GetFullName() ,
|
||||
wildcard,
|
||||
doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
|
||||
if( isDirectory )
|
||||
{
|
||||
wxDirDialog dlg( this, prompt, Prj().GetProjectPath(),
|
||||
doOpen ? wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST : wxDD_DEFAULT_STYLE );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
||||
aFilename = dlg.GetPath();
|
||||
aFilename.SetExt( ext );
|
||||
aFilename = dlg.GetPath();
|
||||
aFilename.SetExt( ext );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFileDialog dlg( this, prompt, Prj().GetProjectPath(), aFilename.GetFullName() ,
|
||||
wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
|
||||
: wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
||||
aFilename = dlg.GetPath();
|
||||
aFilename.SetExt( ext );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1416,22 +1416,37 @@ void EDA_DRAW_FRAME::RefreshCrossHair( const wxPoint &aOldPos, const wxPoint &aE
|
|||
|
||||
|
||||
bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
|
||||
const wxString& wildcard, const wxString& ext )
|
||||
const wxString& wildcard, const wxString& ext,
|
||||
bool isDirectory )
|
||||
{
|
||||
wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
|
||||
aFilename.SetExt( ext );
|
||||
|
||||
wxFileDialog dlg( this,
|
||||
doOpen ? _( "Select Library" ) : _( "New Library" ),
|
||||
Prj().GetProjectPath(),
|
||||
doOpen ? wxString( wxEmptyString ) : aFilename.GetFullName() ,
|
||||
wildcard,
|
||||
doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
|
||||
#ifndef __WXMAC__
|
||||
if( isDirectory )
|
||||
{
|
||||
wxDirDialog dlg( this, prompt, Prj().GetProjectPath(),
|
||||
doOpen ? wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST : wxDD_DEFAULT_STYLE );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
||||
aFilename = dlg.GetPath();
|
||||
aFilename.SetExt( ext );
|
||||
aFilename = dlg.GetPath();
|
||||
aFilename.SetExt( ext );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
wxFileDialog dlg( this, prompt, Prj().GetProjectPath(), aFilename.GetFullName() ,
|
||||
wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
|
||||
: wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
||||
aFilename = dlg.GetPath();
|
||||
aFilename.SetExt( ext );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1501,8 +1501,12 @@ bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
|
|||
{
|
||||
wxFileName fn = m_libMgr->GetUniqueLibraryName();
|
||||
|
||||
if( !LibraryFileBrowser( !aCreateNew, fn, SchematicLibraryFileWildcard(), SchematicLibraryFileExtension) )
|
||||
if( !LibraryFileBrowser( !aCreateNew, fn,
|
||||
SchematicLibraryFileWildcard(), SchematicLibraryFileExtension,
|
||||
false ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
wxString libName = fn.GetName();
|
||||
|
||||
|
|
|
@ -199,10 +199,13 @@ protected:
|
|||
* @param doOpen if true runs an Open Library browser, otherwise New Library
|
||||
* @param aFilename for New may contain a default name; in both cases return the chosen
|
||||
* filename.
|
||||
* @param wildcard a wildcard to filter the displayed files
|
||||
* @param ext the library file extension
|
||||
* @param isDirectory indicates the library files are directories
|
||||
* @return true for OK; false for Cancel.
|
||||
*/
|
||||
bool LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
|
||||
const wxString& wildcard, const wxString& ext );
|
||||
const wxString& wildcard, const wxString& ext, bool isDirectory );
|
||||
|
||||
/**
|
||||
* Function GeneralControlKeyMovement
|
||||
|
|
|
@ -428,8 +428,12 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary(const wxString& aLibName )
|
|||
{
|
||||
fn = initialPath;
|
||||
|
||||
if( !LibraryFileBrowser( false, fn, KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension ) )
|
||||
if( !LibraryFileBrowser( false, fn,
|
||||
KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension,
|
||||
true ) )
|
||||
{
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
doAdd = true;
|
||||
}
|
||||
|
@ -509,8 +513,12 @@ bool PCB_BASE_EDIT_FRAME::AddLibrary( const wxString& aFilename )
|
|||
|
||||
if( aFilename.IsEmpty() )
|
||||
{
|
||||
if( !LibraryFileBrowser( true, fn, KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension ) )
|
||||
if( !LibraryFileBrowser( true, fn,
|
||||
KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension,
|
||||
true ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
wxString libPath = fn.GetFullPath();
|
||||
|
|
Loading…
Reference in New Issue