diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 7abdf93f8a..38fb7778d5 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -887,13 +888,21 @@ wxString EDA_DRAW_FRAME::GetScreenDesc() const bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename, const wxString& wildcard, const wxString& ext, - bool isDirectory ) + bool isDirectory, bool aIsGlobal ) { wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" ); aFilename.SetExt( ext ); + wxString dir = PATHS::GetDefaultUserSymbolsPath(); + + if( isDirectory && doOpen ) { + if( !aIsGlobal ) + { + dir = Prj().GetProjectPath(); + } + wxDirDialog dlg( this, prompt, Prj().GetProjectPath(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); @@ -909,7 +918,10 @@ bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename, if( aFilename.GetName().empty() ) aFilename.SetName( "Library" ); - wxString dir = Prj().IsNullProject() ? aFilename.GetFullPath() : Prj().GetProjectPath(); + if( !aIsGlobal ) + { + dir = Prj().IsNullProject() ? aFilename.GetFullPath() : Prj().GetProjectPath(); + } wxFileDialog dlg( this, prompt, dir, aFilename.GetFullName(), wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 1627b7222e..c188c7439b 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -793,10 +793,17 @@ bool SYMBOL_EDIT_FRAME::SynchronizePins() bool SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew ) { + // Select the target library table (global/project) + SYMBOL_LIB_TABLE* libTable = selectSymLibTable(); + + if( !libTable ) + return false; + wxFileName fn = m_libMgr->GetUniqueLibraryName(); if( !LibraryFileBrowser( !aCreateNew, fn, KiCadSymbolLibFileWildcard(), - KiCadSymbolLibFileExtension, false ) ) + KiCadSymbolLibFileExtension, false, + ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ) ) ) { return false; } @@ -812,12 +819,6 @@ bool SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew ) return false; } - // Select the target library table (global/project) - SYMBOL_LIB_TABLE* libTable = selectSymLibTable(); - - if( !libTable ) - return false; - if( aCreateNew ) { if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) ) diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 438a7605b5..9fadcf59b6 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -166,7 +166,8 @@ public: * @return true for OK; false for Cancel. */ bool LibraryFileBrowser( bool doOpen, wxFileName& aFilename, const wxString& wildcard, - const wxString& ext, bool isDirectory = false ); + const wxString& ext, bool isDirectory = false, + bool aIsGlobal = false ); void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;