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
|
wxString EDA_DRAW_FRAME::GetScreenDesc() const
|
||||||
{
|
{
|
||||||
// Virtual function. In basic class, returns
|
// Virtual function. Base class implementation returns an empty string.
|
||||||
// an empty string.
|
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
|
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 );
|
aFilename.SetExt( ext );
|
||||||
|
|
||||||
wxFileDialog dlg( this,
|
if( isDirectory )
|
||||||
doOpen ? _( "Select Library" ) : _( "New Library" ),
|
{
|
||||||
Prj().GetProjectPath(),
|
wxDirDialog dlg( this, prompt, Prj().GetProjectPath(),
|
||||||
doOpen ? wxString( wxEmptyString ) : aFilename.GetFullName() ,
|
doOpen ? wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST : wxDD_DEFAULT_STYLE );
|
||||||
wildcard,
|
|
||||||
doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
|
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_CANCEL )
|
if( dlg.ShowModal() == wxID_CANCEL )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
aFilename = dlg.GetPath();
|
aFilename = dlg.GetPath();
|
||||||
aFilename.SetExt( ext );
|
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;
|
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,
|
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 );
|
aFilename.SetExt( ext );
|
||||||
|
|
||||||
wxFileDialog dlg( this,
|
#ifndef __WXMAC__
|
||||||
doOpen ? _( "Select Library" ) : _( "New Library" ),
|
if( isDirectory )
|
||||||
Prj().GetProjectPath(),
|
{
|
||||||
doOpen ? wxString( wxEmptyString ) : aFilename.GetFullName() ,
|
wxDirDialog dlg( this, prompt, Prj().GetProjectPath(),
|
||||||
wildcard,
|
doOpen ? wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST : wxDD_DEFAULT_STYLE );
|
||||||
doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
|
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_CANCEL )
|
if( dlg.ShowModal() == wxID_CANCEL )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
aFilename = dlg.GetPath();
|
aFilename = dlg.GetPath();
|
||||||
aFilename.SetExt( ext );
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1501,8 +1501,12 @@ bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
|
||||||
{
|
{
|
||||||
wxFileName fn = m_libMgr->GetUniqueLibraryName();
|
wxFileName fn = m_libMgr->GetUniqueLibraryName();
|
||||||
|
|
||||||
if( !LibraryFileBrowser( !aCreateNew, fn, SchematicLibraryFileWildcard(), SchematicLibraryFileExtension) )
|
if( !LibraryFileBrowser( !aCreateNew, fn,
|
||||||
|
SchematicLibraryFileWildcard(), SchematicLibraryFileExtension,
|
||||||
|
false ) )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
wxString libName = fn.GetName();
|
wxString libName = fn.GetName();
|
||||||
|
|
||||||
|
|
|
@ -199,10 +199,13 @@ protected:
|
||||||
* @param doOpen if true runs an Open Library browser, otherwise New Library
|
* @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
|
* @param aFilename for New may contain a default name; in both cases return the chosen
|
||||||
* filename.
|
* 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.
|
* @return true for OK; false for Cancel.
|
||||||
*/
|
*/
|
||||||
bool LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
|
bool LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
|
||||||
const wxString& wildcard, const wxString& ext );
|
const wxString& wildcard, const wxString& ext, bool isDirectory );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GeneralControlKeyMovement
|
* Function GeneralControlKeyMovement
|
||||||
|
|
|
@ -428,8 +428,12 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary(const wxString& aLibName )
|
||||||
{
|
{
|
||||||
fn = initialPath;
|
fn = initialPath;
|
||||||
|
|
||||||
if( !LibraryFileBrowser( false, fn, KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension ) )
|
if( !LibraryFileBrowser( false, fn,
|
||||||
|
KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension,
|
||||||
|
true ) )
|
||||||
|
{
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
doAdd = true;
|
doAdd = true;
|
||||||
}
|
}
|
||||||
|
@ -509,8 +513,12 @@ bool PCB_BASE_EDIT_FRAME::AddLibrary( const wxString& aFilename )
|
||||||
|
|
||||||
if( aFilename.IsEmpty() )
|
if( aFilename.IsEmpty() )
|
||||||
{
|
{
|
||||||
if( !LibraryFileBrowser( true, fn, KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension ) )
|
if( !LibraryFileBrowser( true, fn,
|
||||||
|
KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension,
|
||||||
|
true ) )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString libPath = fn.GetFullPath();
|
wxString libPath = fn.GetFullPath();
|
||||||
|
|
Loading…
Reference in New Issue