Give user opportunity to add exported library to lib table.
Fixes: lp:1788490 * https://bugs.launchpad.net/kicad/+bug/1788490
This commit is contained in:
parent
a9c8a7b69c
commit
11f746b53e
|
@ -1565,15 +1565,25 @@ void LIB_EDIT_FRAME::SyncLibraries( bool aProgress )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SYMBOL_LIB_TABLE* LIB_EDIT_FRAME::selectSymLibTable()
|
SYMBOL_LIB_TABLE* LIB_EDIT_FRAME::selectSymLibTable( bool aOptional )
|
||||||
{
|
{
|
||||||
wxArrayString libTableNames;
|
wxArrayString libTableNames;
|
||||||
libTableNames.Add( _( "Global" ) );
|
libTableNames.Add( _( "Global" ) );
|
||||||
libTableNames.Add( _( "Project" ) );
|
libTableNames.Add( _( "Project" ) );
|
||||||
|
|
||||||
switch( SelectSingleOption( this, _( "Select Library Table" ),
|
wxSingleChoiceDialog dlg( this, _( "Choose the Library Table to add the library to:" ),
|
||||||
_( "Choose the Library Table to add the library to:" ),
|
_( "Add To Library Table" ), libTableNames );
|
||||||
libTableNames ) )
|
|
||||||
|
if( aOptional )
|
||||||
|
{
|
||||||
|
dlg.FindWindow( wxID_CANCEL )->SetLabel( _( "Skip" ) );
|
||||||
|
dlg.FindWindow( wxID_OK )->SetLabel( _( "Add" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
switch( dlg.GetSelection() )
|
||||||
{
|
{
|
||||||
case 0: return &SYMBOL_LIB_TABLE::GetGlobalLibTable();
|
case 0: return &SYMBOL_LIB_TABLE::GetGlobalLibTable();
|
||||||
case 1: return Prj().SchSymbolLibTable();
|
case 1: return Prj().SchSymbolLibTable();
|
||||||
|
|
|
@ -711,9 +711,10 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a dialog asking the user to select a symbol library table.
|
* Displays a dialog asking the user to select a symbol library table.
|
||||||
|
* @param aOptional if set the Cancel button will be relabelled "Skip".
|
||||||
* @return Pointer to the selected symbol library table or nullptr if cancelled.
|
* @return Pointer to the selected symbol library table or nullptr if cancelled.
|
||||||
*/
|
*/
|
||||||
SYMBOL_LIB_TABLE* selectSymLibTable();
|
SYMBOL_LIB_TABLE* selectSymLibTable( bool aOptional = false );
|
||||||
|
|
||||||
///> Creates a backup copy of a file with requested extension
|
///> Creates a backup copy of a file with requested extension
|
||||||
bool backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt );
|
bool backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt );
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -23,23 +23,16 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @file lib_export.cpp
|
|
||||||
* @brief Eeschema library maintenance routines to backup modified libraries and
|
|
||||||
* create, edit, and delete components.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <class_drawpanel.h>
|
#include <class_drawpanel.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
#include <symbol_lib_table.h>
|
||||||
#include <general.h>
|
#include <general.h>
|
||||||
#include <lib_edit_frame.h>
|
#include <lib_edit_frame.h>
|
||||||
#include <class_library.h>
|
#include <class_library.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <eeschema_id.h>
|
#include <eeschema_id.h>
|
||||||
#include <lib_manager.h>
|
#include <lib_manager.h>
|
||||||
|
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,4 +184,19 @@ void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event )
|
||||||
|
|
||||||
msg.Printf( _( "Symbol \"%s\" saved in library \"%s\"" ), part->GetName(), fn.GetFullPath() );
|
msg.Printf( _( "Symbol \"%s\" saved in library \"%s\"" ), part->GetName(), fn.GetFullPath() );
|
||||||
SetStatusText( msg );
|
SetStatusText( msg );
|
||||||
|
|
||||||
|
// See if the user wants it added to a library table (global or project)
|
||||||
|
SYMBOL_LIB_TABLE* libTable = selectSymLibTable( true );
|
||||||
|
|
||||||
|
if( libTable )
|
||||||
|
{
|
||||||
|
if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
|
||||||
|
{
|
||||||
|
DisplayError( this, _( "Could not open the library file." ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
|
||||||
|
saveSymbolLibTables( globalTable, !globalTable );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue