Invert the new symbol library flow to push users to default to a different folder for global symbols
This commit is contained in:
parent
77bb36a482
commit
a373abd68a
|
@ -35,6 +35,7 @@
|
||||||
#include <lockfile.h>
|
#include <lockfile.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
#include <page_info.h>
|
#include <page_info.h>
|
||||||
|
#include <paths.h>
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <render_settings.h>
|
#include <render_settings.h>
|
||||||
#include <settings/app_settings.h>
|
#include <settings/app_settings.h>
|
||||||
|
@ -887,13 +888,21 @@ wxString EDA_DRAW_FRAME::GetScreenDesc() const
|
||||||
|
|
||||||
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 )
|
bool isDirectory, bool aIsGlobal )
|
||||||
{
|
{
|
||||||
wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
|
wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
|
||||||
aFilename.SetExt( ext );
|
aFilename.SetExt( ext );
|
||||||
|
|
||||||
|
wxString dir = PATHS::GetDefaultUserSymbolsPath();
|
||||||
|
|
||||||
|
|
||||||
if( isDirectory && doOpen )
|
if( isDirectory && doOpen )
|
||||||
{
|
{
|
||||||
|
if( !aIsGlobal )
|
||||||
|
{
|
||||||
|
dir = Prj().GetProjectPath();
|
||||||
|
}
|
||||||
|
|
||||||
wxDirDialog dlg( this, prompt, Prj().GetProjectPath(),
|
wxDirDialog dlg( this, prompt, Prj().GetProjectPath(),
|
||||||
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
|
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
|
||||||
|
|
||||||
|
@ -909,7 +918,10 @@ bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
|
||||||
if( aFilename.GetName().empty() )
|
if( aFilename.GetName().empty() )
|
||||||
aFilename.SetName( "Library" );
|
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(),
|
wxFileDialog dlg( this, prompt, dir, aFilename.GetFullName(),
|
||||||
wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
|
wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
|
||||||
|
|
|
@ -793,10 +793,17 @@ bool SYMBOL_EDIT_FRAME::SynchronizePins()
|
||||||
|
|
||||||
bool SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
|
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();
|
wxFileName fn = m_libMgr->GetUniqueLibraryName();
|
||||||
|
|
||||||
if( !LibraryFileBrowser( !aCreateNew, fn, KiCadSymbolLibFileWildcard(),
|
if( !LibraryFileBrowser( !aCreateNew, fn, KiCadSymbolLibFileWildcard(),
|
||||||
KiCadSymbolLibFileExtension, false ) )
|
KiCadSymbolLibFileExtension, false,
|
||||||
|
( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ) ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -812,12 +819,6 @@ bool SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select the target library table (global/project)
|
|
||||||
SYMBOL_LIB_TABLE* libTable = selectSymLibTable();
|
|
||||||
|
|
||||||
if( !libTable )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if( aCreateNew )
|
if( aCreateNew )
|
||||||
{
|
{
|
||||||
if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) )
|
if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) )
|
||||||
|
|
|
@ -166,7 +166,8 @@ public:
|
||||||
* @return true for OK; false for Cancel.
|
* @return true for OK; false for Cancel.
|
||||||
*/
|
*/
|
||||||
bool LibraryFileBrowser( bool doOpen, wxFileName& aFilename, const wxString& wildcard,
|
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;
|
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue