Replaced footprint library wizard with a common file browser
As of v5 footprint library reorganization (one repo per library concept is replaced with a common repo for all libraries), the Footprint Library Wizard may handle only the old libraries. It has been replaced with a file browser to select only local files. Fixes: lp:1772209 * https://bugs.launchpad.net/kicad/+bug/1772209
This commit is contained in:
parent
adc61024d3
commit
145835661b
|
@ -29,8 +29,6 @@ set( CVPCB_DIALOGS
|
|||
../pcbnew/dialogs/dialog_fp_lib_table_base.cpp
|
||||
../pcbnew/dialogs/dialog_fp_plugin_options.cpp
|
||||
../pcbnew/dialogs/dialog_fp_plugin_options_base.cpp
|
||||
../pcbnew/dialogs/wizard_add_fplib_base.cpp
|
||||
../pcbnew/dialogs/wizard_add_fplib.cpp
|
||||
)
|
||||
|
||||
set( CVPCB_SRCS
|
||||
|
|
|
@ -162,8 +162,6 @@ set( PCBNEW_DIALOGS
|
|||
dialogs/dialog_track_via_size_base.cpp
|
||||
dialogs/dialog_update_pcb.cpp
|
||||
dialogs/dialog_update_pcb_base.cpp
|
||||
dialogs/wizard_add_fplib.cpp
|
||||
dialogs/wizard_add_fplib_base.cpp
|
||||
footprint_wizard.cpp
|
||||
footprint_wizard_frame.cpp
|
||||
footprint_wizard_frame_functions.cpp
|
||||
|
|
|
@ -44,8 +44,52 @@
|
|||
#include <invoke_pcb_dialog.h>
|
||||
#include <grid_tricks.h>
|
||||
#include <confirm.h>
|
||||
#include <wizard_add_fplib.h>
|
||||
#include <lib_table_grid.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <pgm_base.h>
|
||||
#include <env_paths.h>
|
||||
#include <dialogs/dialog_file_dir_picker.h>
|
||||
|
||||
// Filters for the file picker
|
||||
static constexpr int FILTER_COUNT = 4;
|
||||
static const struct
|
||||
{
|
||||
wxString m_Description; ///< Description shown in the file picker dialog
|
||||
wxString m_Extension; ///< In case of folders it stands for extensions of files stored inside
|
||||
bool m_IsFile; ///< Whether the library is a folder or a file
|
||||
IO_MGR::PCB_FILE_T m_Plugin;
|
||||
} fileFilters[FILTER_COUNT] =
|
||||
{
|
||||
// wxGenericDirCtrl does not handle regexes in wildcards
|
||||
{ "KiCad (folder with .kicad_mod files)", "kicad_mod", false, IO_MGR::KICAD_SEXP },
|
||||
{ "Eagle 6.x (*.lbr)", "lbr", true, IO_MGR::EAGLE },
|
||||
{ "KiCad legacy (*.mod)", "mod", true, IO_MGR::LEGACY },
|
||||
{ "Geda (folder with *.fp files)", "fp", false, IO_MGR::GEDA_PCB },
|
||||
};
|
||||
|
||||
|
||||
// Returns the filter string for the file picker
|
||||
static wxString getFilterString()
|
||||
{
|
||||
wxString filterAll = _( "All supported library formats|" );
|
||||
wxString filter;
|
||||
|
||||
for( int i = 0; i < FILTER_COUNT; ++i )
|
||||
{
|
||||
// "All supported formats" filter
|
||||
if( i != 0 )
|
||||
filterAll += ";";
|
||||
|
||||
filterAll += "*." + fileFilters[i].m_Extension;
|
||||
|
||||
|
||||
// Rest of the filter string
|
||||
filter += "|" + fileFilters[i].m_Description +
|
||||
"|" + ( fileFilters[i].m_IsFile ? "*." + fileFilters[i].m_Extension : "" );
|
||||
}
|
||||
|
||||
return filterAll + filter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -568,7 +612,74 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void OnClickLibraryWizard( wxCommandEvent& event ) override;
|
||||
void browseLibrariesHandler( wxCommandEvent& event ) override
|
||||
{
|
||||
if( m_lastBrowseDir.IsEmpty() )
|
||||
m_lastBrowseDir = Prj().GetProjectPath();
|
||||
|
||||
DIALOG_FILE_DIR_PICKER dlg( this, _( "Select Library" ), m_lastBrowseDir,
|
||||
getFilterString(), FD_MULTIPLE );
|
||||
|
||||
auto result = dlg.ShowModal();
|
||||
|
||||
if( result == wxID_CANCEL )
|
||||
return;
|
||||
|
||||
m_lastBrowseDir = dlg.GetDirectory();
|
||||
|
||||
// Drop the last directory if the path is a .pretty folder
|
||||
if( m_lastBrowseDir.EndsWith( KiCadFootprintLibPathExtension ) )
|
||||
m_lastBrowseDir = m_lastBrowseDir.BeforeLast( wxFileName::GetPathSeparator() );
|
||||
|
||||
bool skipRemainingDuplicates = false;
|
||||
wxArrayString files;
|
||||
dlg.GetFilenames( files );
|
||||
|
||||
for( const auto& filePath : files )
|
||||
{
|
||||
wxFileName fn( filePath );
|
||||
wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), LIB_ID::ID_PCB );
|
||||
|
||||
if( cur_model()->ContainsNickname( nickname ) )
|
||||
{
|
||||
if( skipRemainingDuplicates )
|
||||
continue;
|
||||
|
||||
int ret = YesNoCancelDialog( this,
|
||||
_( "Warning: Duplicate Nickname" ),
|
||||
wxString::Format( _( "A library nicknamed \"%s\" already exists." ), nickname ),
|
||||
_( "Skip" ),
|
||||
_( "Skip All Remaining Duplicates" ),
|
||||
_( "Add Anyway" ) );
|
||||
|
||||
if( ret == wxID_YES )
|
||||
continue;
|
||||
else if ( ret == wxID_NO )
|
||||
{
|
||||
skipRemainingDuplicates = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( m_cur_grid->AppendRows( 1 ) )
|
||||
{
|
||||
int last_row = m_cur_grid->GetNumberRows() - 1;
|
||||
|
||||
m_cur_grid->SetCellValue( last_row, COL_NICKNAME, nickname );
|
||||
|
||||
auto type = IO_MGR::GuessPluginTypeFromLibPath( filePath );
|
||||
m_cur_grid->SetCellValue( last_row, COL_TYPE, IO_MGR::ShowType( type ) );
|
||||
|
||||
// try to use path normalized to an environmental variable or project path
|
||||
wxString normalizedPath = NormalizePath( filePath, &Pgm().GetLocalEnvVariables(), &Prj() );
|
||||
m_cur_grid->SetCellValue( last_row, COL_URI,
|
||||
normalizedPath.IsEmpty() ? fn.GetFullPath() : normalizedPath );
|
||||
}
|
||||
}
|
||||
|
||||
if( !files.IsEmpty() )
|
||||
scrollToRow( m_cur_grid->GetNumberRows() - 1 ); // scroll to the new libraries
|
||||
}
|
||||
|
||||
void onCancelButtonClick( wxCommandEvent& event ) override
|
||||
{
|
||||
|
@ -676,6 +787,15 @@ private:
|
|||
m_path_subs_grid->AutoSizeColumns();
|
||||
}
|
||||
|
||||
/// Makes a specific row visible
|
||||
void scrollToRow( int aRowNumber )
|
||||
{
|
||||
// wx documentation is wrong, SetGridCursor does not make visible.
|
||||
m_cur_grid->MakeCellVisible( aRowNumber, 0 );
|
||||
m_cur_grid->SetGridCursor( aRowNumber, 0 );
|
||||
m_cur_grid->SelectRow( m_cur_grid->GetGridCursorRow() );
|
||||
}
|
||||
|
||||
//-----</event handlers>---------------------------------
|
||||
|
||||
// caller's tables are modified only on OK button and successful verification.
|
||||
|
@ -699,82 +819,14 @@ private:
|
|||
|
||||
wxGrid* m_cur_grid; ///< changed based on tab choice
|
||||
static int m_pageNdx; ///< Remember the last notebook page selected during a session
|
||||
|
||||
wxString m_lastBrowseDir; ///< last browsed directory
|
||||
};
|
||||
|
||||
|
||||
int DIALOG_FP_LIB_TABLE::m_pageNdx = 0;
|
||||
|
||||
|
||||
void DIALOG_FP_LIB_TABLE::OnClickLibraryWizard( wxCommandEvent& event )
|
||||
{
|
||||
WIZARD_FPLIB_TABLE dlg( this );
|
||||
|
||||
if( !dlg.RunWizard( dlg.GetFirstPage() ) )
|
||||
return; // Aborted by user
|
||||
|
||||
const std::vector<WIZARD_FPLIB_TABLE::LIBRARY>& libs = dlg.GetLibraries();
|
||||
bool global_scope = dlg.GetLibScope() == WIZARD_FPLIB_TABLE::GLOBAL;
|
||||
wxGrid* libgrid = global_scope ? m_global_grid : m_project_grid;
|
||||
FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) libgrid->GetTable();
|
||||
bool skipRemainingDuplicates = false;
|
||||
|
||||
for( std::vector<WIZARD_FPLIB_TABLE::LIBRARY>::const_iterator it = libs.begin();
|
||||
it != libs.end(); ++it )
|
||||
{
|
||||
if( it->GetStatus() == WIZARD_FPLIB_TABLE::LIBRARY::INVALID )
|
||||
continue;
|
||||
|
||||
wxString nickname = LIB_ID::FixIllegalChars( it->GetDescription(), LIB_ID::ID_PCB );
|
||||
|
||||
if( tbl->ContainsNickname( nickname ) )
|
||||
{
|
||||
if( skipRemainingDuplicates )
|
||||
continue;
|
||||
|
||||
int ret = YesNoCancelDialog( this,
|
||||
_( "Warning: Duplicate Nickname" ),
|
||||
wxString::Format( _( "A library nicknamed \"%s\" already exists." ), nickname ),
|
||||
_( "Skip" ),
|
||||
_( "Skip All Remaining Duplicates" ),
|
||||
_( "Add Anyway" ) );
|
||||
|
||||
if( ret == wxID_YES )
|
||||
continue;
|
||||
else if ( ret == wxID_NO )
|
||||
{
|
||||
skipRemainingDuplicates = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( libgrid->AppendRows( 1 ) )
|
||||
{
|
||||
int last_row = libgrid->GetNumberRows() - 1;
|
||||
|
||||
// Add the nickname: currently make it from filename
|
||||
tbl->SetValue( last_row, COL_NICKNAME, nickname );
|
||||
|
||||
// Add the path:
|
||||
tbl->SetValue( last_row, COL_URI, it->GetAutoPath( dlg.GetLibScope() ) );
|
||||
|
||||
// Add the plugin name:
|
||||
tbl->SetValue( last_row, COL_TYPE, it->GetPluginName() );
|
||||
|
||||
libgrid->MakeCellVisible( last_row, 0 );
|
||||
libgrid->SetGridCursor( last_row, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
// Switch to the current scope tab
|
||||
if( global_scope )
|
||||
m_auinotebook->SetSelection( 0 );
|
||||
else
|
||||
m_auinotebook->SetSelection( 1 );
|
||||
|
||||
libgrid->SelectRow( libgrid->GetGridCursorRow() );
|
||||
}
|
||||
|
||||
|
||||
int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal,
|
||||
FP_LIB_TABLE* aProject )
|
||||
{
|
||||
|
@ -784,35 +836,3 @@ int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal,
|
|||
|
||||
return dialogRet;
|
||||
}
|
||||
|
||||
|
||||
int InvokeFootprintWizard( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal,
|
||||
FP_LIB_TABLE* aProject )
|
||||
{
|
||||
WIZARD_FPLIB_TABLE dlg( aParent );
|
||||
|
||||
if( !dlg.RunWizard( dlg.GetFirstPage() ) )
|
||||
return 0; // Aborted by user
|
||||
|
||||
const std::vector<WIZARD_FPLIB_TABLE::LIBRARY>& libs = dlg.GetLibraries();
|
||||
WIZARD_FPLIB_TABLE::LIB_SCOPE scope = dlg.GetLibScope();
|
||||
FP_LIB_TABLE* fp_tbl = ( scope == WIZARD_FPLIB_TABLE::GLOBAL ? aGlobal : aProject );
|
||||
|
||||
if( fp_tbl )
|
||||
{
|
||||
for( std::vector<WIZARD_FPLIB_TABLE::LIBRARY>::const_iterator it = libs.begin();
|
||||
it != libs.end(); ++it )
|
||||
{
|
||||
if( it->GetStatus() == WIZARD_FPLIB_TABLE::LIBRARY::INVALID )
|
||||
continue;
|
||||
|
||||
FP_LIB_TABLE_ROW* row = new FP_LIB_TABLE_ROW( it->GetDescription(),
|
||||
it->GetAutoPath( scope ),
|
||||
it->GetPluginName(),
|
||||
wxEmptyString ); // options
|
||||
fp_tbl->InsertRow( row );
|
||||
}
|
||||
}
|
||||
|
||||
return scope;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Apr 19 2018)
|
||||
// C++ code generated with wxFormBuilder (version Jul 17 2016)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dialog_fp_lib_table_base.h"
|
||||
|
@ -130,8 +130,8 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID
|
|||
wxBoxSizer* bSizer51;
|
||||
bSizer51 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_buttonWizard = new wxButton( m_top_sizer->GetStaticBox(), wxID_ANY, _("Append with Wizard"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer51->Add( m_buttonWizard, 0, wxALL, 5 );
|
||||
m_browseButton = new wxButton( m_top_sizer->GetStaticBox(), wxID_ANY, _("Browse Libraries..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer51->Add( m_browseButton, 0, wxALL, 5 );
|
||||
|
||||
m_append_button = new wxButton( m_top_sizer->GetStaticBox(), wxID_ANY, _("Append Library"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_append_button->SetToolTip( _("Add a PCB library row to this table") );
|
||||
|
@ -228,7 +228,7 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID
|
|||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelCaptionButtonClick ) );
|
||||
this->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) );
|
||||
m_auinotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this );
|
||||
m_buttonWizard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::OnClickLibraryWizard ), NULL, this );
|
||||
m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::browseLibrariesHandler ), NULL, this );
|
||||
m_append_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this );
|
||||
m_delete_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this );
|
||||
m_move_up_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this );
|
||||
|
@ -244,7 +244,7 @@ DIALOG_FP_LIB_TABLE_BASE::~DIALOG_FP_LIB_TABLE_BASE()
|
|||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelCaptionButtonClick ) );
|
||||
this->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) );
|
||||
m_auinotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this );
|
||||
m_buttonWizard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::OnClickLibraryWizard ), NULL, this );
|
||||
m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::browseLibrariesHandler ), NULL, this );
|
||||
m_append_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this );
|
||||
m_delete_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this );
|
||||
m_move_up_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this );
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
<property name="file">dialog_fp_lib_table_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">MyProject1</property>
|
||||
<property name="namespace"></property>
|
||||
|
@ -1067,7 +1066,7 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Append with Wizard</property>
|
||||
<property name="label">Browse Libraries...</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -1075,7 +1074,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_buttonWizard</property>
|
||||
<property name="name">m_browseButton</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -1096,7 +1095,7 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnButtonClick">OnClickLibraryWizard</event>
|
||||
<event name="OnButtonClick">browseLibrariesHandler</event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Apr 19 2018)
|
||||
// C++ code generated with wxFormBuilder (version Jul 17 2016)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __DIALOG_FP_LIB_TABLE_BASE_H__
|
||||
|
@ -11,6 +11,8 @@
|
|||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
class DIALOG_SHIM;
|
||||
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
|
@ -49,7 +51,7 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM
|
|||
wxStaticText* m_staticText4;
|
||||
wxStaticText* m_PrjTableFilename;
|
||||
wxGrid* m_project_grid;
|
||||
wxButton* m_buttonWizard;
|
||||
wxButton* m_browseButton;
|
||||
wxButton* m_append_button;
|
||||
wxButton* m_delete_button;
|
||||
wxButton* m_move_up_button;
|
||||
|
@ -64,7 +66,7 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM
|
|||
virtual void onCancelCaptionButtonClick( wxCloseEvent& event ) = 0;
|
||||
virtual void onKeyDown( wxKeyEvent& event ) = 0;
|
||||
virtual void pageChangedHandler( wxAuiNotebookEvent& event ) = 0;
|
||||
virtual void OnClickLibraryWizard( wxCommandEvent& event ) = 0;
|
||||
virtual void browseLibrariesHandler( wxCommandEvent& event ) = 0;
|
||||
virtual void appendRowHandler( wxCommandEvent& event ) = 0;
|
||||
virtual void deleteRowHandler( wxCommandEvent& event ) = 0;
|
||||
virtual void moveUpHandler( wxCommandEvent& event ) = 0;
|
||||
|
|
|
@ -1,857 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 CERN
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
* Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Wizard for selecting footprint libraries consisting of 4 steps:
|
||||
* - select source (Github/local files)
|
||||
* - pick libraries
|
||||
* - present a review of libraries (including validation)
|
||||
* - select scope (global/project)
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <wx/wx.h>
|
||||
#include <wx/uri.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/progdlg.h>
|
||||
|
||||
#include <pgm_base.h>
|
||||
#include <project.h>
|
||||
#include <wizard_add_fplib.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <confirm.h>
|
||||
#include <bitmaps.h>
|
||||
|
||||
#include <class_module.h>
|
||||
#include <env_paths.h>
|
||||
|
||||
#ifdef BUILD_GITHUB_PLUGIN
|
||||
#include <../github/github_getliblist.h>
|
||||
#endif
|
||||
|
||||
// a key to store the default Kicad Github libs URL
|
||||
#define KICAD_FPLIBS_URL_KEY wxT( "kicad_fplib_url" )
|
||||
#define KICAD_FPLIBS_LAST_DIR wxT( "kicad_fplib_last_download_dir" )
|
||||
|
||||
// Filters for the file picker
|
||||
static const int FILTER_COUNT = 4;
|
||||
static const struct
|
||||
{
|
||||
wxString m_Description; ///< Description shown in the file picker dialog
|
||||
wxString m_Extension; ///< In case of folders it stands for extensions of files stored inside
|
||||
bool m_IsFile; ///< Whether it is a folder or a file
|
||||
IO_MGR::PCB_FILE_T m_Plugin;
|
||||
} fileFilters[FILTER_COUNT] =
|
||||
{
|
||||
{ "KiCad (folder with .kicad_mod files)", "kicad_mod", false, IO_MGR::KICAD_SEXP },
|
||||
{ "Eagle 6.x (*.lbr)", "lbr", true, IO_MGR::EAGLE },
|
||||
{ "KiCad legacy (*.mod)", "mod", true, IO_MGR::LEGACY },
|
||||
{ "Geda (folder with *.fp files)", "fp", false, IO_MGR::GEDA_PCB },
|
||||
};
|
||||
|
||||
|
||||
// Returns the filter string for the file picker
|
||||
static wxString getFilterString()
|
||||
{
|
||||
wxString filterInit = _( "All supported library formats|" );
|
||||
wxString filter;
|
||||
|
||||
for( int i = 0; i < FILTER_COUNT; ++i )
|
||||
{
|
||||
// Init part
|
||||
if( i != 0 )
|
||||
filterInit += ";";
|
||||
|
||||
filterInit += "*." + fileFilters[i].m_Extension;
|
||||
|
||||
// Rest of the filter string
|
||||
filter += "|" + fileFilters[i].m_Description +
|
||||
"|" + ( fileFilters[i].m_IsFile ? "*." + fileFilters[i].m_Extension : "" );
|
||||
}
|
||||
|
||||
return filterInit + filter;
|
||||
}
|
||||
|
||||
|
||||
// Tries to guess the plugin type basing on the path
|
||||
static OPT<IO_MGR::PCB_FILE_T> getPluginType( const wxString& aPath )
|
||||
{
|
||||
if( ( aPath.StartsWith( "http://" ) || aPath.StartsWith( "https://" ) ) )
|
||||
return OPT<IO_MGR::PCB_FILE_T>( IO_MGR::GITHUB );
|
||||
|
||||
wxFileName path( aPath );
|
||||
|
||||
for( int i = 0; i < FILTER_COUNT; ++i )
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
if( fileFilters[i].m_IsFile )
|
||||
{
|
||||
ok = path.IsFileReadable() && path.GetExt() == fileFilters[i].m_Extension;
|
||||
}
|
||||
else if( path.IsDirReadable() )
|
||||
{
|
||||
// Plugin expects a directory containing files with a specific extension
|
||||
wxDir dir( aPath );
|
||||
|
||||
if( dir.IsOpened() )
|
||||
{
|
||||
wxString filename;
|
||||
|
||||
dir.GetFirst( &filename, "*." + fileFilters[i].m_Extension, wxDIR_FILES );
|
||||
|
||||
ok = !filename.IsEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
if( ok )
|
||||
return OPT<IO_MGR::PCB_FILE_T>( fileFilters[i].m_Plugin );
|
||||
}
|
||||
|
||||
return NULLOPT;
|
||||
}
|
||||
|
||||
|
||||
// Checks if a filename fits specific filter
|
||||
static bool passesFilter( const wxString& aFileName, int aFilterIndex )
|
||||
{
|
||||
wxASSERT( aFilterIndex <= FILTER_COUNT );
|
||||
wxFileName file( aFileName );
|
||||
OPT<IO_MGR::PCB_FILE_T> result = getPluginType( aFileName );
|
||||
|
||||
if( !result ) // does not match any supported plugin
|
||||
return false;
|
||||
|
||||
if( aFilterIndex == 0 ) // any plugin will do
|
||||
return true;
|
||||
|
||||
return ( fileFilters[aFilterIndex - 1].m_Plugin == *result );
|
||||
}
|
||||
|
||||
|
||||
WIZARD_FPLIB_TABLE::LIBRARY::LIBRARY( const wxString& aPath, const wxString& aDescription ) :
|
||||
m_path( aPath ), m_description( aDescription ), m_status( NOT_CHECKED )
|
||||
{
|
||||
m_plugin = getPluginType( aPath );
|
||||
}
|
||||
|
||||
|
||||
bool WIZARD_FPLIB_TABLE::LIBRARY::Test()
|
||||
{
|
||||
if( !m_plugin )
|
||||
{
|
||||
m_status = LIBRARY::INVALID;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<PLUGIN> p( IO_MGR::PluginFind( *m_plugin ) );
|
||||
wxArrayString footprints;
|
||||
|
||||
if( !p )
|
||||
{
|
||||
m_status = LIBRARY::INVALID;
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
p->FootprintEnumerate( footprints, m_path );
|
||||
}
|
||||
catch( IO_ERROR& )
|
||||
{
|
||||
m_status = LIBRARY::INVALID;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( footprints.GetCount() == 0 )
|
||||
{
|
||||
m_status = LIBRARY::INVALID;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_status = LIBRARY::OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
wxString WIZARD_FPLIB_TABLE::LIBRARY::GetPluginName() const
|
||||
{
|
||||
if( !m_plugin )
|
||||
return _( "UNKNOWN" );
|
||||
|
||||
return IO_MGR::ShowType( *m_plugin );
|
||||
}
|
||||
|
||||
|
||||
wxString WIZARD_FPLIB_TABLE::LIBRARY::GetRelativePath( const wxString& aBase, const wxString& aSubstitution ) const
|
||||
{
|
||||
wxFileName libPath( m_path );
|
||||
|
||||
// Check if the library path belongs to the project folder
|
||||
if( libPath.MakeRelativeTo( aBase ) && !libPath.GetFullPath().StartsWith( ".." ) )
|
||||
{
|
||||
return wxString( aSubstitution + "/" + libPath.GetFullPath() );
|
||||
}
|
||||
|
||||
// Probably on another drive, so the relative path will not work
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
wxString WIZARD_FPLIB_TABLE::LIBRARY::GetAutoPath( LIB_SCOPE aScope ) const
|
||||
{
|
||||
const wxString& project_env = PROJECT_VAR_NAME;
|
||||
const wxString& github_env( "KIGITHUB" );
|
||||
|
||||
wxString rel_path;
|
||||
|
||||
// The extra KIGITHUB and KIPRJCHECKS are still here since Pgm.GetLocalVariables() does not
|
||||
// contain the KIPRJMOD env var, and the KIGITHUB does not pass the IsAbsolutePath check
|
||||
// that happens in NormalizePath(...) since it starts with https://
|
||||
|
||||
// KIGITHUB check
|
||||
rel_path = replaceEnv( github_env, false );
|
||||
|
||||
if( !rel_path.IsEmpty() )
|
||||
return rel_path;
|
||||
|
||||
// KIPRJMOD check
|
||||
if( aScope == PROJECT )
|
||||
{
|
||||
rel_path = replaceEnv( project_env );
|
||||
|
||||
if( !rel_path.IsEmpty() )
|
||||
return rel_path;
|
||||
}
|
||||
|
||||
rel_path = NormalizePath( wxFileName( m_path ), &Pgm().GetLocalEnvVariables(), project_env );
|
||||
|
||||
// If normalizePath failed, then rel_path will be empty, m_path is the full path.
|
||||
if( rel_path.IsEmpty() )
|
||||
return m_path;
|
||||
|
||||
return rel_path;
|
||||
}
|
||||
|
||||
|
||||
wxString WIZARD_FPLIB_TABLE::LIBRARY::GetDescription() const
|
||||
{
|
||||
if( !m_description.IsEmpty() )
|
||||
return m_description;
|
||||
|
||||
wxFileName filename( m_path );
|
||||
return filename.GetName();
|
||||
}
|
||||
|
||||
|
||||
wxString WIZARD_FPLIB_TABLE::LIBRARY::replaceEnv( const wxString& aEnvVar, bool aFilePath ) const
|
||||
{
|
||||
wxString env_path;
|
||||
|
||||
if( !wxGetEnv( aEnvVar, &env_path ) )
|
||||
return wxEmptyString;
|
||||
|
||||
//return GetRelativePath( m_path, wxString( "$(" + aEnvVar + ")" ) );
|
||||
|
||||
wxString result( m_path );
|
||||
|
||||
if( result.Replace( env_path, wxString( "$(" + aEnvVar + ")" ) ) )
|
||||
return result;
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
WIZARD_FPLIB_TABLE::WIZARD_FPLIB_TABLE( wxWindow* aParent ) :
|
||||
WIZARD_FPLIB_TABLE_BASE( aParent ), m_welcomeDlg( m_pages[0] ),
|
||||
m_fileSelectDlg( m_pages[1] ), m_githubListDlg( m_pages[2] ),
|
||||
m_reviewDlg( m_pages[3] ), m_targetDlg( m_pages[4] ), m_selectedFilter( 0 )
|
||||
{
|
||||
m_filePicker->SetFilter( getFilterString() );
|
||||
|
||||
// Initialize default download dir
|
||||
wxString default_path;
|
||||
wxGetEnv( FP_LIB_TABLE::GlobalPathEnvVariableName(), &default_path );
|
||||
setDownloadDir( default_path );
|
||||
m_filePicker->SetPath( default_path );
|
||||
|
||||
// Restore the Github url
|
||||
wxString githubUrl;
|
||||
|
||||
wxConfigBase* cfg = Pgm().CommonSettings();
|
||||
cfg->Read( KICAD_FPLIBS_URL_KEY, &githubUrl );
|
||||
cfg->Read( KICAD_FPLIBS_LAST_DIR, &m_lastGithubDownloadDirectory );
|
||||
|
||||
|
||||
if( !m_lastGithubDownloadDirectory.IsEmpty() )
|
||||
{
|
||||
setDownloadDir( m_lastGithubDownloadDirectory );
|
||||
m_filePicker->SetPath( m_lastGithubDownloadDirectory );
|
||||
} else {
|
||||
m_lastGithubDownloadDirectory = default_path;
|
||||
}
|
||||
|
||||
if( githubUrl.IsEmpty() )
|
||||
githubUrl = wxT( "https://github.com/KiCad" );
|
||||
|
||||
SetGithubURL( githubUrl );
|
||||
|
||||
// Give the minimal size to the dialog, which allows displaying any page
|
||||
wxSize minsize;
|
||||
|
||||
for( unsigned ii = 0; ii < m_pages.size(); ii++ )
|
||||
{
|
||||
wxSize size = m_pages[ii]->GetSizer()->CalcMin();
|
||||
minsize.x = std::max( minsize.x, size.x );
|
||||
minsize.y = std::max( minsize.y, size.y );
|
||||
}
|
||||
|
||||
SetMinSize( minsize );
|
||||
SetPageSize( minsize );
|
||||
GetSizer()->SetSizeHints( this );
|
||||
Center();
|
||||
|
||||
if( !m_radioAddGithub->GetValue() && !m_radioAddLocal->GetValue() )
|
||||
m_radioAddLocal->SetValue( true );
|
||||
|
||||
setupDialogOrder();
|
||||
updateGithubControls();
|
||||
|
||||
Connect( wxEVT_RADIOBUTTON, wxCommandEventHandler( WIZARD_FPLIB_TABLE::OnSourceCheck ), NULL, this );
|
||||
Connect( wxEVT_DIRCTRL_SELECTIONCHANGED, wxCommandEventHandler( WIZARD_FPLIB_TABLE::OnSelectFiles ), NULL, this );
|
||||
Connect( wxEVT_CHECKLISTBOX, wxCommandEventHandler( WIZARD_FPLIB_TABLE::OnCheckGithubList ), NULL, this );
|
||||
}
|
||||
|
||||
|
||||
WIZARD_FPLIB_TABLE::~WIZARD_FPLIB_TABLE()
|
||||
{
|
||||
// Use this if you want to store kicad lib URL in pcbnew/cvpcb section config:
|
||||
// wxConfigBase* cfg = Kiface().KifaceSettings();
|
||||
|
||||
// Use this if you want to store kicad lib URL in common section config:
|
||||
wxConfigBase* cfg = Pgm().CommonSettings();
|
||||
cfg->Write( KICAD_FPLIBS_URL_KEY, GetGithubURL() );
|
||||
}
|
||||
|
||||
|
||||
WIZARD_FPLIB_TABLE::LIB_SOURCE WIZARD_FPLIB_TABLE::GetLibSource() const
|
||||
{
|
||||
if( m_radioAddGithub->GetValue() )
|
||||
return GITHUB;
|
||||
|
||||
wxASSERT( m_radioAddLocal->GetValue() );
|
||||
|
||||
return LOCAL;
|
||||
}
|
||||
|
||||
|
||||
WIZARD_FPLIB_TABLE::LIB_SCOPE WIZARD_FPLIB_TABLE::GetLibScope() const
|
||||
{
|
||||
if( m_radioGlobal->GetValue() )
|
||||
return GLOBAL;
|
||||
|
||||
wxASSERT( m_radioProject->GetValue() );
|
||||
|
||||
return PROJECT;
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnPageChanged( wxWizardEvent& aEvent )
|
||||
{
|
||||
SetBitmap( KiBitmap( wizard_add_fplib_icon_xpm ) );
|
||||
enableNext( true );
|
||||
|
||||
#ifdef BUILD_GITHUB_PLUGIN
|
||||
if( GetCurrentPage() == m_githubListDlg )
|
||||
setupGithubList();
|
||||
else
|
||||
#endif
|
||||
if( GetCurrentPage() == m_fileSelectDlg )
|
||||
setupFileSelect();
|
||||
else if( GetCurrentPage() == m_reviewDlg )
|
||||
setupReview();
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnSelectFiles( wxCommandEvent& aEvent )
|
||||
{
|
||||
int filterIdx = m_filePicker->GetFilterIndex();
|
||||
|
||||
if( m_selectedFilter != filterIdx )
|
||||
{
|
||||
m_selectedFilter = filterIdx;
|
||||
|
||||
// Process the event again, as in the first iteration we cannot get the list of selected items
|
||||
wxCommandEvent ev( wxEVT_DIRCTRL_SELECTIONCHANGED );
|
||||
AddPendingEvent( ev );
|
||||
return;
|
||||
}
|
||||
|
||||
enableNext( checkFiles() );
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnCheckGithubList( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxArrayInt dummy;
|
||||
|
||||
enableNext( m_checkListGH->GetCheckedItems( dummy ) > 0 );
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnSourceCheck( wxCommandEvent& aEvent )
|
||||
{
|
||||
updateGithubControls();
|
||||
setupDialogOrder();
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnSelectAllGH( wxCommandEvent& aEvent )
|
||||
{
|
||||
for( unsigned int i = 0; i < m_checkListGH->GetCount(); ++i )
|
||||
m_checkListGH->Check( i, true );
|
||||
|
||||
// The list might be empty, e.g. in case of download error
|
||||
wxArrayInt dummy;
|
||||
enableNext( m_checkListGH->GetCheckedItems( dummy ) > 0 );
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnUnselectAllGH( wxCommandEvent& aEvent )
|
||||
{
|
||||
for( unsigned int i = 0; i < m_checkListGH->GetCount(); ++i )
|
||||
m_checkListGH->Check( i, false );
|
||||
|
||||
enableNext( false );
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnChangeSearch( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxString searchPhrase = m_searchCtrlGH->GetValue().Lower();
|
||||
|
||||
// Store the current selection
|
||||
wxArrayInt checkedIndices;
|
||||
m_checkListGH->GetCheckedItems( checkedIndices );
|
||||
wxArrayString checkedStrings;
|
||||
|
||||
for( unsigned int i = 0; i < checkedIndices.GetCount(); ++i )
|
||||
checkedStrings.Add( m_checkListGH->GetString( checkedIndices[i] ).AfterLast( '/' ) );
|
||||
|
||||
m_checkListGH->Clear();
|
||||
|
||||
// Rebuild the list, putting the matching entries on the top
|
||||
int matching = 0; // number of entries matching the search phrase
|
||||
for( unsigned int i = 0; i < m_githubLibs.GetCount(); ++i )
|
||||
{
|
||||
const wxString& lib = m_githubLibs[i].AfterLast( '/' );
|
||||
bool wasChecked = ( checkedStrings.Index( lib ) != wxNOT_FOUND );
|
||||
int insertedIdx = -1;
|
||||
|
||||
if( !searchPhrase.IsEmpty() && lib.Lower().Contains( searchPhrase ) )
|
||||
{
|
||||
insertedIdx = m_checkListGH->Insert( lib, matching++ );
|
||||
m_checkListGH->SetSelection( insertedIdx );
|
||||
}
|
||||
else
|
||||
insertedIdx = m_checkListGH->Append( lib );
|
||||
|
||||
if( wasChecked )
|
||||
m_checkListGH->Check( insertedIdx );
|
||||
}
|
||||
|
||||
if( !m_checkListGH->IsEmpty() )
|
||||
m_checkListGH->EnsureVisible( 0 );
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnWizardFinished( wxWizardEvent& aEvent )
|
||||
{
|
||||
#ifdef BUILD_GITHUB_PLUGIN
|
||||
// Shall we download a localy copy of the libraries
|
||||
if( GetLibSource() == GITHUB && m_downloadGithub->GetValue() )
|
||||
{
|
||||
wxString error;
|
||||
wxArrayString libs;
|
||||
|
||||
// Prepare a list of libraries to download
|
||||
for( std::vector<LIBRARY>::const_iterator it = m_libraries.begin();
|
||||
it != m_libraries.end(); ++it )
|
||||
{
|
||||
wxASSERT( it->GetPluginType() == IO_MGR::GITHUB );
|
||||
|
||||
if( it->GetStatus() != LIBRARY::INVALID )
|
||||
libs.Add( it->GetAbsolutePath() );
|
||||
}
|
||||
|
||||
if( !downloadGithubLibsFromList( libs, &error ) )
|
||||
{
|
||||
DisplayError( this, error );
|
||||
m_libraries.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now libraries are stored locally, so update the paths to point to the download folder
|
||||
for( std::vector<LIBRARY>::iterator it = m_libraries.begin();
|
||||
it != m_libraries.end(); ++it )
|
||||
{
|
||||
wxString path = it->GetAbsolutePath();
|
||||
path.Replace( GetGithubURL(), getDownloadDir() );
|
||||
it->setPath( path );
|
||||
it->setPluginType( IO_MGR::KICAD_SEXP );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnBrowseButtonClick( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxString path = getDownloadDir();
|
||||
|
||||
path = wxDirSelector( _("Choose a folder to save the downloaded libraries" ),
|
||||
path, 0, wxDefaultPosition, this );
|
||||
|
||||
if( !path.IsEmpty() && wxDirExists( path ) )
|
||||
{
|
||||
setDownloadDir( path );
|
||||
|
||||
wxConfigBase* cfg = Pgm().CommonSettings();
|
||||
cfg->Write( KICAD_FPLIBS_LAST_DIR, path );
|
||||
|
||||
updateGithubControls();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnCheckSaveCopy( wxCommandEvent& aEvent )
|
||||
{
|
||||
updateGithubControls();
|
||||
}
|
||||
|
||||
|
||||
bool WIZARD_FPLIB_TABLE::checkFiles() const
|
||||
{
|
||||
// Get current selection (files & directories)
|
||||
wxArrayString candidates;
|
||||
m_filePicker->GetPaths( candidates );
|
||||
|
||||
// Workaround, when you change filters "/" is automatically selected
|
||||
int slash_index = candidates.Index( "/", true, true );
|
||||
if( slash_index != wxNOT_FOUND )
|
||||
candidates.RemoveAt( slash_index, 1 );
|
||||
|
||||
if( candidates.IsEmpty() )
|
||||
return false;
|
||||
|
||||
// Verify all the files/folders comply to the selected library type filter
|
||||
for( unsigned int i = 0; i < candidates.GetCount(); ++i )
|
||||
{
|
||||
if( !passesFilter( candidates[i], m_filePicker->GetFilterIndex() ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
wxConfigBase* cfg = Pgm().CommonSettings();
|
||||
cfg->Write( KICAD_FPLIBS_LAST_DIR, candidates[0] );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BUILD_GITHUB_PLUGIN
|
||||
void WIZARD_FPLIB_TABLE::getLibsListGithub( wxArrayString& aList )
|
||||
{
|
||||
wxBeginBusyCursor();
|
||||
|
||||
// Be sure there is no trailing '/' at the end of the repo name
|
||||
wxString git_url = m_textCtrlGithubURL->GetValue();
|
||||
|
||||
if( git_url.EndsWith( wxT( "/" ) ) )
|
||||
{
|
||||
git_url.RemoveLast();
|
||||
m_textCtrlGithubURL->SetValue( git_url );
|
||||
}
|
||||
|
||||
GITHUB_GETLIBLIST getter( git_url );
|
||||
getter.GetFootprintLibraryList( aList );
|
||||
|
||||
wxEndBusyCursor();
|
||||
}
|
||||
|
||||
|
||||
// Download the .pretty libraries found in aUrlLis and store them on disk
|
||||
// in a master folder
|
||||
bool WIZARD_FPLIB_TABLE::downloadGithubLibsFromList( wxArrayString& aUrlList,
|
||||
wxString* aErrorMessage )
|
||||
{
|
||||
// Display a progress bar to show the downlaod state
|
||||
// for OSX do not enable wPD_APP_MODAL, keep wxPD_AUTO_HIDE
|
||||
wxProgressDialog pdlg( _( "Downloading libraries" ), wxEmptyString, aUrlList.GetCount(),
|
||||
this,
|
||||
#ifndef __WXMAC__
|
||||
wxPD_APP_MODAL |
|
||||
#endif
|
||||
wxPD_CAN_ABORT | wxPD_AUTO_HIDE );
|
||||
|
||||
// Download libs:
|
||||
for( unsigned ii = 0; ii < aUrlList.GetCount(); ii++ )
|
||||
{
|
||||
wxString& libsrc_name = aUrlList[ii];
|
||||
wxString libdst_name;
|
||||
|
||||
// Extract the lib name from the full URL:
|
||||
wxURI url( libsrc_name );
|
||||
wxFileName fn( url.GetPath() );
|
||||
// Set our local path
|
||||
fn.SetPath( getDownloadDir() );
|
||||
libdst_name = fn.GetFullPath();
|
||||
|
||||
if( !wxDirExists( libdst_name ) )
|
||||
wxMkdir( libdst_name );
|
||||
|
||||
pdlg.Update( ii, libsrc_name );
|
||||
pdlg.Refresh();
|
||||
pdlg.Update();
|
||||
|
||||
try
|
||||
{
|
||||
PLUGIN::RELEASER src( IO_MGR::PluginFind( IO_MGR::GITHUB ) );
|
||||
PLUGIN::RELEASER dst( IO_MGR::PluginFind( IO_MGR::KICAD_SEXP ) );
|
||||
|
||||
wxArrayString footprints;
|
||||
|
||||
src->FootprintEnumerate( footprints, libsrc_name );
|
||||
|
||||
for( unsigned i = 0; i < footprints.size(); ++i )
|
||||
{
|
||||
std::unique_ptr<MODULE> m( src->FootprintLoad( libsrc_name, footprints[i] ) );
|
||||
dst->FootprintSave( libdst_name, m.get() );
|
||||
// m is deleted here by unique_ptr.
|
||||
}
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
if( aErrorMessage )
|
||||
aErrorMessage->Printf( _( "Error:\n\"%s\"\nwhile downloading library:\n\"%s\"" ),
|
||||
GetChars( ioe.What() ), GetChars( libsrc_name ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::setupGithubList()
|
||||
{
|
||||
// Enable 'Next' only if there is at least one library selected
|
||||
wxArrayInt checkedIndices;
|
||||
m_checkListGH->GetCheckedItems( checkedIndices );
|
||||
enableNext( checkedIndices.GetCount() > 0 );
|
||||
|
||||
// Update only if necessary
|
||||
if( m_githubLibs.GetCount() == 0 )
|
||||
getLibsListGithub( m_githubLibs );
|
||||
|
||||
m_searchCtrlGH->Clear();
|
||||
|
||||
// Clear the review list so it will be reloaded
|
||||
m_libraries.clear();
|
||||
m_listCtrlReview->DeleteAllItems();
|
||||
}
|
||||
#endif /* BUILD_GITHUB_PLUGIN */
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::updateGithubControls()
|
||||
{
|
||||
#ifndef BUILD_GITHUB_PLUGIN
|
||||
m_radioAddGithub->Enable( false );
|
||||
#endif
|
||||
|
||||
// Disable inputs that have no meaning for the selected source
|
||||
bool githubEnabled = ( GetLibSource() == GITHUB );
|
||||
m_textCtrlGithubURL->Enable( githubEnabled );
|
||||
m_downloadGithub->Enable( githubEnabled );
|
||||
m_downloadDir->Enable( githubEnabled && wantLocalCopy() );
|
||||
m_btnBrowse->Enable( githubEnabled && wantLocalCopy() );
|
||||
|
||||
bool valid = !( githubEnabled && wantLocalCopy() ) || wxFileName::IsDirWritable( getDownloadDir() );
|
||||
|
||||
// Do not allow to go further unless there is a valid directory selected
|
||||
m_invalidDir->Show( !valid );
|
||||
enableNext( valid );
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::updateLibraries()
|
||||
{
|
||||
// No need to update, the review list is ready
|
||||
if( m_listCtrlReview->GetItemCount() != 0 )
|
||||
return;
|
||||
|
||||
switch( GetLibSource() )
|
||||
{
|
||||
case LOCAL:
|
||||
{
|
||||
wxArrayString libs;
|
||||
m_filePicker->GetPaths( libs );
|
||||
|
||||
// Workaround, when you change filters "/" is automatically selected
|
||||
int slash_index = libs.Index( "/", true, true );
|
||||
if( slash_index != wxNOT_FOUND )
|
||||
libs.RemoveAt( slash_index, 1 );
|
||||
|
||||
m_libraries.reserve( libs.GetCount() );
|
||||
|
||||
for( unsigned int i = 0; i < libs.GetCount(); ++i )
|
||||
m_libraries.push_back( libs[i] );
|
||||
}
|
||||
break;
|
||||
|
||||
case GITHUB:
|
||||
{
|
||||
wxArrayInt checkedLibs;
|
||||
m_checkListGH->GetCheckedItems( checkedLibs );
|
||||
|
||||
m_libraries.reserve( checkedLibs.GetCount() );
|
||||
|
||||
for( unsigned int i = 0; i < checkedLibs.GetCount(); ++i )
|
||||
m_libraries.push_back( GetGithubURL() + "/" + m_checkListGH->GetString( checkedLibs[i] ) );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
wxASSERT( false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::setupDialogOrder()
|
||||
{
|
||||
// Alternate the wizard pages flow depending on the selected option
|
||||
switch( GetLibSource() )
|
||||
{
|
||||
case LOCAL:
|
||||
m_welcomeDlg->SetNext( m_fileSelectDlg );
|
||||
m_fileSelectDlg->SetPrev( m_welcomeDlg );
|
||||
|
||||
m_fileSelectDlg->SetNext( m_reviewDlg );
|
||||
m_reviewDlg->SetPrev( m_fileSelectDlg );
|
||||
break;
|
||||
|
||||
case GITHUB:
|
||||
m_welcomeDlg->SetNext( m_githubListDlg );
|
||||
m_githubListDlg->SetPrev( m_welcomeDlg );
|
||||
|
||||
m_githubListDlg->SetNext( m_reviewDlg );
|
||||
m_reviewDlg->SetPrev( m_githubListDlg );
|
||||
break;
|
||||
|
||||
default:
|
||||
wxASSERT( false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::setupFileSelect()
|
||||
{
|
||||
// Disable the button until something is selected
|
||||
enableNext( checkFiles() );
|
||||
|
||||
// Clear the review list so it will be reloaded
|
||||
m_libraries.clear();
|
||||
m_listCtrlReview->DeleteAllItems();
|
||||
}
|
||||
|
||||
|
||||
void WIZARD_FPLIB_TABLE::setupReview()
|
||||
{
|
||||
wxBeginBusyCursor();
|
||||
updateLibraries();
|
||||
|
||||
int libTotalCount = m_libraries.size();
|
||||
int libCount = 0;
|
||||
bool validate = true;
|
||||
// for OSX do not enable wPD_APP_MODAL, keep wxPD_AUTO_HIDE
|
||||
wxProgressDialog progressDlg( _( "Please wait..." ), _( "Validating libraries" ),
|
||||
libTotalCount, this,
|
||||
#ifndef __WXMAC__
|
||||
wxPD_APP_MODAL |
|
||||
#endif
|
||||
wxPD_CAN_ABORT | wxPD_AUTO_HIDE );
|
||||
|
||||
m_dvLibName->SetWidth( 280 );
|
||||
|
||||
// Prepare the review list
|
||||
m_listCtrlReview->DeleteAllItems();
|
||||
|
||||
for( std::vector<LIBRARY>::iterator it = m_libraries.begin(); it != m_libraries.end(); ++it )
|
||||
{
|
||||
wxVector<wxVariant> row;
|
||||
LIBRARY::STATUS status = it->GetStatus();
|
||||
|
||||
// Check if the library contents is valid
|
||||
if( status == LIBRARY::NOT_CHECKED && validate )
|
||||
{
|
||||
it->Test();
|
||||
status = it->GetStatus();
|
||||
}
|
||||
|
||||
row.push_back( wxVariant( it->GetDescription() ) );
|
||||
|
||||
switch( it->GetStatus() )
|
||||
{
|
||||
case LIBRARY::NOT_CHECKED:
|
||||
row.push_back( wxVariant( _( "NOT CHECKED" ) ) );
|
||||
break;
|
||||
|
||||
case LIBRARY::OK:
|
||||
row.push_back( wxVariant( _( "OK" ) ) );
|
||||
break;
|
||||
|
||||
case LIBRARY::INVALID:
|
||||
row.push_back( wxVariant( _( "INVALID" ) ) );
|
||||
break;
|
||||
}
|
||||
|
||||
row.push_back( wxVariant( it->GetPluginName() ) );
|
||||
|
||||
m_listCtrlReview->AppendItem( row );
|
||||
|
||||
++libCount;
|
||||
if( !progressDlg.Update( libCount, wxString::Format( _( "Validating libraries %d/%d" ),
|
||||
libCount, libTotalCount ) ) )
|
||||
validate = false;
|
||||
}
|
||||
|
||||
// The list should never be empty, but who knows?
|
||||
enableNext( m_listCtrlReview->GetItemCount() > 0 );
|
||||
|
||||
wxEndBusyCursor();
|
||||
}
|
|
@ -1,279 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 CERN
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
* Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <wizard_add_fplib_base.h>
|
||||
#include <io_mgr.h>
|
||||
#include <core/optional.h>
|
||||
|
||||
class KIWAY_PLAYER;
|
||||
|
||||
class WIZARD_FPLIB_TABLE : public WIZARD_FPLIB_TABLE_BASE
|
||||
{
|
||||
public:
|
||||
WIZARD_FPLIB_TABLE( wxWindow* aParent );
|
||||
~WIZARD_FPLIB_TABLE();
|
||||
|
||||
///> Source of the libraries (local files or Github)
|
||||
enum LIB_SOURCE { LOCAL, GITHUB };
|
||||
|
||||
///> Scope (global/project)
|
||||
enum LIB_SCOPE { GLOBAL = 1, PROJECT = 2 };
|
||||
|
||||
/**
|
||||
* Function GetFirstPage
|
||||
* Returns the welcoming page for the wizard.
|
||||
*/
|
||||
inline wxWizardPage* GetFirstPage() const
|
||||
{
|
||||
return m_welcomeDlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetGithubURL
|
||||
* Returns the current Github repository URL set in the wizard.
|
||||
*/
|
||||
inline wxString GetGithubURL() const
|
||||
{
|
||||
return m_textCtrlGithubURL->GetValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetGithubURL
|
||||
* Sets the current Github repository URL used by the wizard.
|
||||
* @param aUrl is the new URL to be applied.
|
||||
*/
|
||||
inline void SetGithubURL( const wxString& aUrl )
|
||||
{
|
||||
m_textCtrlGithubURL->SetValue( aUrl );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetLibSource
|
||||
* Returns the source of libraries (local / Github).
|
||||
*/
|
||||
LIB_SOURCE GetLibSource() const;
|
||||
|
||||
/**
|
||||
* Function GetLibScope
|
||||
* Returns the scope for the added libraries (global / project specific).
|
||||
*/
|
||||
LIB_SCOPE GetLibScope() const;
|
||||
|
||||
// Wizard event handlers
|
||||
void OnSourceCheck( wxCommandEvent& aEvent );
|
||||
void OnSelectFiles( wxCommandEvent& aEvent );
|
||||
void OnCheckGithubList( wxCommandEvent& aEvent );
|
||||
void OnPageChanged( wxWizardEvent& aEvent ) override;
|
||||
void OnSelectAllGH( wxCommandEvent& aEvent ) override;
|
||||
void OnUnselectAllGH( wxCommandEvent& aEvent ) override;
|
||||
void OnChangeSearch( wxCommandEvent& aEvent ) override;
|
||||
void OnWizardFinished( wxWizardEvent& aEvent ) override;
|
||||
void OnBrowseButtonClick( wxCommandEvent& aEvent ) override;
|
||||
void OnCheckSaveCopy( wxCommandEvent& aEvent ) override;
|
||||
|
||||
class LIBRARY
|
||||
{
|
||||
public:
|
||||
LIBRARY( const wxString& aPath, const wxString& aDescription = wxEmptyString );
|
||||
~LIBRARY()
|
||||
{
|
||||
}
|
||||
|
||||
///> Possible states of validation.
|
||||
enum STATUS { OK, INVALID, NOT_CHECKED };
|
||||
|
||||
/**
|
||||
* Function Test
|
||||
* Uses the associated plugin to validate the library contents.
|
||||
* @return True if the library and the matched plugin type are valid.
|
||||
*/
|
||||
bool Test();
|
||||
|
||||
/**
|
||||
* Function GetPluginType
|
||||
* Returns the plugin type, autodetected basing on the path.
|
||||
* @return Returns empty OPT if the type could not be autodetected.
|
||||
*/
|
||||
inline OPT<IO_MGR::PCB_FILE_T> GetPluginType() const
|
||||
{
|
||||
return m_plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetPluginName
|
||||
* Returns the plugin name, as used in the FPLIB table editor.
|
||||
*/
|
||||
wxString GetPluginName() const;
|
||||
|
||||
/**
|
||||
* Function GetAbsolutePath
|
||||
* Returns the absolute path for the library.
|
||||
*/
|
||||
inline const wxString& GetAbsolutePath() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetRelativePath
|
||||
* Returns the relative path, based on the input path with the base part replaced.
|
||||
* @param aBase is the base for the relative path.
|
||||
* @param aSubstitution is the string to be replace the base path.
|
||||
* @return Adjusted path if possible, or the absolute path when it is not possible.
|
||||
*/
|
||||
wxString GetRelativePath( const wxString& aBase, const wxString& aSubstitution = wxEmptyString ) const;
|
||||
|
||||
/**
|
||||
* Function GetAutoPath
|
||||
* Returns path that is either absolute or related to KISYSMOD/KIPRJMOD if the files
|
||||
* are stored within one of the mentioned paths.
|
||||
* @param aScope is the scope for the library. It determines the environmental variables
|
||||
* that are used to check the path (GLOBAL scope checks only KISYSMOD, while PROJECT
|
||||
* scope checks both KISYSMOD & KIPRJMOD).
|
||||
*/
|
||||
wxString GetAutoPath( LIB_SCOPE aScope ) const;
|
||||
|
||||
/**
|
||||
* Function GetDescription
|
||||
* Returns the description for the library. If it is not specified in the constructor,
|
||||
* it is just the filename.
|
||||
*/
|
||||
wxString GetDescription() const;
|
||||
|
||||
/**
|
||||
* Function GetStatus
|
||||
* Returns the validity status for the library. It requires running Test() before, to get
|
||||
* a result different than NOT_CHECKED.
|
||||
*/
|
||||
STATUS GetStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void setPath( const wxString& aPath )
|
||||
{
|
||||
m_path = aPath;
|
||||
}
|
||||
|
||||
inline void setPluginType( IO_MGR::PCB_FILE_T aType )
|
||||
{
|
||||
m_plugin = aType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function replaceEnv
|
||||
* replaces path with environmental variable if applicable.
|
||||
* @param aEnvVar is the environmental variable that should be substituted.
|
||||
* @param aFilePath determines if the path is a file path (contrary to e.g. http address).
|
||||
*/
|
||||
wxString replaceEnv( const wxString& aEnvVar, bool aFilePath = true ) const;
|
||||
|
||||
wxString m_path;
|
||||
wxString m_description;
|
||||
OPT<IO_MGR::PCB_FILE_T> m_plugin;
|
||||
STATUS m_status;
|
||||
|
||||
friend class WIZARD_FPLIB_TABLE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function GetLibraries
|
||||
* Returns libraries selected by the user.
|
||||
*/
|
||||
const std::vector<LIBRARY>& GetLibraries() const
|
||||
{
|
||||
return m_libraries;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
// Initialization of wizard pages
|
||||
void setupDialogOrder();
|
||||
void setupGithubList();
|
||||
void setupFileSelect();
|
||||
void setupReview();
|
||||
|
||||
///> Checks the selection in file picker
|
||||
bool checkFiles() const;
|
||||
|
||||
///> Sets the target directory for libraries downloaded from Github
|
||||
void setDownloadDir( const wxString& aDir )
|
||||
{
|
||||
m_downloadDir->SetLabel( aDir );
|
||||
}
|
||||
|
||||
///> Gets the current target for downloaded libraries
|
||||
inline wxString getDownloadDir()
|
||||
{
|
||||
return m_downloadDir->GetLabel();
|
||||
}
|
||||
|
||||
///> Downloads the list of Github libraries
|
||||
void getLibsListGithub( wxArrayString& aList );
|
||||
|
||||
///> Saves a list of Github libraries locally.
|
||||
bool downloadGithubLibsFromList( wxArrayString& aUrlList, wxString* aErrorMessage );
|
||||
|
||||
///> Does the user want a local copy of Github libraries?
|
||||
inline bool wantLocalCopy() const { return m_downloadGithub->GetValue(); }
|
||||
|
||||
///> Enables Github widgets depending on the selected options.
|
||||
void updateGithubControls();
|
||||
|
||||
///> Updates m_libraries basing on dialogs contents
|
||||
void updateLibraries();
|
||||
|
||||
///> Enables/disable 'Next' button
|
||||
inline void enableNext( bool aEnable )
|
||||
{
|
||||
wxWindow* nextBtn = FindWindowById( wxID_FORWARD );
|
||||
|
||||
if( nextBtn )
|
||||
nextBtn->Enable( aEnable );
|
||||
}
|
||||
|
||||
///> Cache for the downloaded Github library list
|
||||
wxArrayString m_githubLibs;
|
||||
|
||||
///> Libraries selected in the wizard
|
||||
std::vector<LIBRARY> m_libraries;
|
||||
|
||||
// Aliases for wizard pages to make code more readable
|
||||
wxWizardPageSimple* const m_welcomeDlg;
|
||||
wxWizardPageSimple* const m_fileSelectDlg;
|
||||
wxWizardPageSimple* const m_githubListDlg;
|
||||
wxWizardPageSimple* const m_reviewDlg;
|
||||
wxWizardPageSimple* const m_targetDlg;
|
||||
|
||||
// Since the same event is used for changing the selection/filter type, we need a way to
|
||||
// determine what's the real cause of the event. Therefore here we store the number of the
|
||||
// selected file type filter.
|
||||
int m_selectedFilter;
|
||||
|
||||
// path to the most recently used download directory from Github.
|
||||
wxString m_lastGithubDownloadDirectory;
|
||||
};
|
|
@ -1,247 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wizard_add_fplib_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
WIZARD_FPLIB_TABLE_BASE::WIZARD_FPLIB_TABLE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxBitmap& bitmap, const wxPoint& pos, long style )
|
||||
{
|
||||
this->Create( parent, id, title, bitmap, pos, style );
|
||||
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
|
||||
|
||||
wxWizardPageSimple* m_wizPage1 = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) );
|
||||
m_pages.Add( m_wizPage1 );
|
||||
|
||||
m_wizPage1->SetMinSize( wxSize( 720,480 ) );
|
||||
|
||||
wxBoxSizer* bSizer1;
|
||||
bSizer1 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxFlexGridSizer* fgSizer112;
|
||||
fgSizer112 = new wxFlexGridSizer( 3, 1, 0, 0 );
|
||||
fgSizer112->AddGrowableRow( 1 );
|
||||
fgSizer112->SetFlexibleDirection( wxBOTH );
|
||||
fgSizer112->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_staticText1 = new wxStaticText( m_wizPage1, wxID_ANY, _("Welcome to the Add Footprint Libraries Wizard!\n\nPlease select the source for the libraries to add:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText1->Wrap( -1 );
|
||||
fgSizer112->Add( m_staticText1, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer19;
|
||||
bSizer19 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_radioAddLocal = new wxRadioButton( m_wizPage1, wxID_ANY, _("Files on my computer"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer19->Add( m_radioAddLocal, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxFlexGridSizer* m_githubSizer;
|
||||
m_githubSizer = new wxFlexGridSizer( 0, 2, 0, 0 );
|
||||
m_githubSizer->SetFlexibleDirection( wxBOTH );
|
||||
m_githubSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_radioAddGithub = new wxRadioButton( m_wizPage1, wxID_ANY, _("Github repository"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_githubSizer->Add( m_radioAddGithub, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_textCtrlGithubURL = new wxTextCtrl( m_wizPage1, wxID_ANY, _("https://github.com/KiCad"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_textCtrlGithubURL->SetMinSize( wxSize( 300,-1 ) );
|
||||
|
||||
m_githubSizer->Add( m_textCtrlGithubURL, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_githubSizer->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
m_downloadGithub = new wxCheckBox( m_wizPage1, wxID_ANY, _("Save a local copy to:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_downloadGithub->SetValue(true);
|
||||
m_githubSizer->Add( m_downloadGithub, 0, wxALL, 5 );
|
||||
|
||||
|
||||
m_githubSizer->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer9;
|
||||
bSizer9 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_downloadDir = new wxStaticText( m_wizPage1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_downloadDir->Wrap( -1 );
|
||||
m_downloadDir->SetMinSize( wxSize( 300,-1 ) );
|
||||
|
||||
bSizer9->Add( m_downloadDir, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
m_btnBrowse = new wxButton( m_wizPage1, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer9->Add( m_btnBrowse, 0, wxALL, 5 );
|
||||
|
||||
|
||||
m_githubSizer->Add( bSizer9, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_githubSizer->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
m_invalidDir = new wxStaticText( m_wizPage1, wxID_ANY, _("It is not possible to write in the selected directory.\nPlease choose another one."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_invalidDir->Wrap( -1 );
|
||||
m_invalidDir->SetForegroundColour( wxColour( 255, 0, 0 ) );
|
||||
|
||||
m_githubSizer->Add( m_invalidDir, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bSizer19->Add( m_githubSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
fgSizer112->Add( bSizer19, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( fgSizer112, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizerOfficialRepo;
|
||||
bSizerOfficialRepo = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_bitmapRepo = new wxStaticBitmap( m_wizPage1, wxID_ANY, wxArtProvider::GetBitmap( wxART_INFORMATION, wxART_OTHER ), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerOfficialRepo->Add( m_bitmapRepo, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bSizerOfficialRepo->Add( 0, 0, 0, wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
m_hyperlinkGithubKicad = new wxHyperlinkCtrl( m_wizPage1, wxID_ANY, _("Visit our official Kicad repository on Github and get more libraries"), wxT("https://github.com/KiCad"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
|
||||
bSizerOfficialRepo->Add( m_hyperlinkGithubKicad, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( bSizerOfficialRepo, 0, wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_wizPage1->SetSizer( bSizer1 );
|
||||
m_wizPage1->Layout();
|
||||
wxWizardPageSimple* m_wizPage2_Local = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) );
|
||||
m_pages.Add( m_wizPage2_Local );
|
||||
|
||||
wxBoxSizer* bSizer8;
|
||||
bSizer8 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText7 = new wxStaticText( m_wizPage2_Local, wxID_ANY, _("Select files or folders to add:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText7->Wrap( -1 );
|
||||
bSizer8->Add( m_staticText7, 0, wxALL, 5 );
|
||||
|
||||
m_filePicker = new wxGenericDirCtrl( m_wizPage2_Local, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_MULTIPLE|wxDIRCTRL_SHOW_FILTERS|wxSUNKEN_BORDER, wxEmptyString, 0 );
|
||||
|
||||
m_filePicker->ShowHidden( false );
|
||||
bSizer8->Add( m_filePicker, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
||||
m_wizPage2_Local->SetSizer( bSizer8 );
|
||||
m_wizPage2_Local->Layout();
|
||||
bSizer8->Fit( m_wizPage2_Local );
|
||||
wxWizardPageSimple* m_wizPage2_Github = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) );
|
||||
m_pages.Add( m_wizPage2_Github );
|
||||
|
||||
wxBoxSizer* bSizer111;
|
||||
bSizer111 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText112 = new wxStaticText( m_wizPage2_Github, wxID_ANY, _("Select Github libraries to add:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText112->Wrap( -1 );
|
||||
bSizer111->Add( m_staticText112, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxArrayString m_checkListGHChoices;
|
||||
m_checkListGH = new wxCheckListBox( m_wizPage2_Github, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_checkListGHChoices, wxLB_MULTIPLE|wxLB_NEEDED_SB );
|
||||
bSizer111->Add( m_checkListGH, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer7;
|
||||
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_btnSelectAllGH = new wxButton( m_wizPage2_Github, wxID_ANY, _("Select all"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer7->Add( m_btnSelectAllGH, 1, wxALL, 5 );
|
||||
|
||||
m_btnUnselectAllGH = new wxButton( m_wizPage2_Github, wxID_ANY, _("Unselect all"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer7->Add( m_btnUnselectAllGH, 1, wxALL, 5 );
|
||||
|
||||
|
||||
bSizer7->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
m_searchCtrlGH = new wxSearchCtrl( m_wizPage2_Github, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
#ifndef __WXMAC__
|
||||
m_searchCtrlGH->ShowSearchButton( true );
|
||||
#endif
|
||||
m_searchCtrlGH->ShowCancelButton( false );
|
||||
bSizer7->Add( m_searchCtrlGH, 2, wxALL, 5 );
|
||||
|
||||
|
||||
bSizer111->Add( bSizer7, 0, wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_wizPage2_Github->SetSizer( bSizer111 );
|
||||
m_wizPage2_Github->Layout();
|
||||
bSizer111->Fit( m_wizPage2_Github );
|
||||
wxWizardPageSimple* m_wizPage3_Review = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) );
|
||||
m_pages.Add( m_wizPage3_Review );
|
||||
|
||||
wxBoxSizer* bSizer1111;
|
||||
bSizer1111 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText1121 = new wxStaticText( m_wizPage3_Review, wxID_ANY, _("Review and confirm the changes to the libraries:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText1121->Wrap( -1 );
|
||||
bSizer1111->Add( m_staticText1121, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_listCtrlReview = new wxDataViewListCtrl( m_wizPage3_Review, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_HORIZ_RULES|wxDV_ROW_LINES|wxDV_VERT_RULES );
|
||||
m_dvLibName = m_listCtrlReview->AppendTextColumn( _("Library") );
|
||||
m_dvLibStatus = m_listCtrlReview->AppendTextColumn( _("Status") );
|
||||
m_dvLibFormat = m_listCtrlReview->AppendTextColumn( _("Format") );
|
||||
bSizer1111->Add( m_listCtrlReview, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_wizPage3_Review->SetSizer( bSizer1111 );
|
||||
m_wizPage3_Review->Layout();
|
||||
bSizer1111->Fit( m_wizPage3_Review );
|
||||
wxWizardPageSimple* m_wizPage4_SelectTarget = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) );
|
||||
m_pages.Add( m_wizPage4_SelectTarget );
|
||||
|
||||
wxBoxSizer* bSizer12;
|
||||
bSizer12 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText12 = new wxStaticText( m_wizPage4_SelectTarget, wxID_ANY, _("Where do you wish the new libraries to be added:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText12->Wrap( -1 );
|
||||
bSizer12->Add( m_staticText12, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_radioGlobal = new wxRadioButton( m_wizPage4_SelectTarget, wxID_ANY, _("To global library configuration (visible by all projects)"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer12->Add( m_radioGlobal, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_radioProject = new wxRadioButton( m_wizPage4_SelectTarget, wxID_ANY, _("To the current project only"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer12->Add( m_radioProject, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_wizPage4_SelectTarget->SetSizer( bSizer12 );
|
||||
m_wizPage4_SelectTarget->Layout();
|
||||
bSizer12->Fit( m_wizPage4_SelectTarget );
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
|
||||
for ( unsigned int i = 1; i < m_pages.GetCount(); i++ )
|
||||
{
|
||||
m_pages.Item( i )->SetPrev( m_pages.Item( i - 1 ) );
|
||||
m_pages.Item( i - 1 )->SetNext( m_pages.Item( i ) );
|
||||
}
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxID_ANY, wxEVT_WIZARD_FINISHED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnWizardFinished ) );
|
||||
this->Connect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPageChanged ) );
|
||||
this->Connect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGING, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPageChanging ) );
|
||||
m_downloadGithub->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnCheckSaveCopy ), NULL, this );
|
||||
m_btnBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnBrowseButtonClick ), NULL, this );
|
||||
m_btnSelectAllGH->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnSelectAllGH ), NULL, this );
|
||||
m_btnUnselectAllGH->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnUnselectAllGH ), NULL, this );
|
||||
m_searchCtrlGH->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnChangeSearch ), NULL, this );
|
||||
}
|
||||
|
||||
WIZARD_FPLIB_TABLE_BASE::~WIZARD_FPLIB_TABLE_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxID_ANY, wxEVT_WIZARD_FINISHED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnWizardFinished ) );
|
||||
this->Disconnect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPageChanged ) );
|
||||
this->Disconnect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGING, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPageChanging ) );
|
||||
m_downloadGithub->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnCheckSaveCopy ), NULL, this );
|
||||
m_btnBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnBrowseButtonClick ), NULL, this );
|
||||
m_btnSelectAllGH->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnSelectAllGH ), NULL, this );
|
||||
m_btnUnselectAllGH->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnUnselectAllGH ), NULL, this );
|
||||
m_searchCtrlGH->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnChangeSearch ), NULL, this );
|
||||
|
||||
m_pages.Clear();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,94 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WIZARD_ADD_FPLIB_BASE_H__
|
||||
#define __WIZARD_ADD_FPLIB_BASE_H__
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/radiobut.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/hyperlink.h>
|
||||
#include <wx/dirctrl.h>
|
||||
#include <wx/checklst.h>
|
||||
#include <wx/srchctrl.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/wizard.h>
|
||||
#include <wx/dynarray.h>
|
||||
WX_DEFINE_ARRAY_PTR( wxWizardPageSimple*, WizardPages );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class WIZARD_FPLIB_TABLE_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class WIZARD_FPLIB_TABLE_BASE : public wxWizard
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxStaticText* m_staticText1;
|
||||
wxRadioButton* m_radioAddLocal;
|
||||
wxRadioButton* m_radioAddGithub;
|
||||
wxTextCtrl* m_textCtrlGithubURL;
|
||||
wxCheckBox* m_downloadGithub;
|
||||
wxStaticText* m_downloadDir;
|
||||
wxButton* m_btnBrowse;
|
||||
wxStaticText* m_invalidDir;
|
||||
wxStaticBitmap* m_bitmapRepo;
|
||||
wxHyperlinkCtrl* m_hyperlinkGithubKicad;
|
||||
wxStaticText* m_staticText7;
|
||||
wxGenericDirCtrl* m_filePicker;
|
||||
wxStaticText* m_staticText112;
|
||||
wxCheckListBox* m_checkListGH;
|
||||
wxButton* m_btnSelectAllGH;
|
||||
wxButton* m_btnUnselectAllGH;
|
||||
wxSearchCtrl* m_searchCtrlGH;
|
||||
wxStaticText* m_staticText1121;
|
||||
wxDataViewListCtrl* m_listCtrlReview;
|
||||
wxDataViewColumn* m_dvLibName;
|
||||
wxDataViewColumn* m_dvLibStatus;
|
||||
wxDataViewColumn* m_dvLibFormat;
|
||||
wxStaticText* m_staticText12;
|
||||
wxRadioButton* m_radioGlobal;
|
||||
wxRadioButton* m_radioProject;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnWizardFinished( wxWizardEvent& event ) { event.Skip(); }
|
||||
virtual void OnPageChanged( wxWizardEvent& event ) { event.Skip(); }
|
||||
virtual void OnPageChanging( wxWizardEvent& event ) { event.Skip(); }
|
||||
virtual void OnCheckSaveCopy( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnBrowseButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnSelectAllGH( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnUnselectAllGH( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnChangeSearch( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
WIZARD_FPLIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Add Footprint Libraries Wizard"), const wxBitmap& bitmap = wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ), const wxPoint& pos = wxDefaultPosition, long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER );
|
||||
WizardPages m_pages;
|
||||
~WIZARD_FPLIB_TABLE_BASE();
|
||||
|
||||
};
|
||||
|
||||
#endif //__WIZARD_ADD_FPLIB_BASE_H__
|
|
@ -138,8 +138,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
||||
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
|
||||
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
||||
EVT_MENU( ID_PCB_LIB_WIZARD,
|
||||
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
||||
EVT_MENU( ID_PCB_LIB_TABLE_EDIT,
|
||||
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
||||
EVT_MENU( wxID_PREFERENCES,
|
||||
|
@ -840,16 +838,10 @@ void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event )
|
|||
DisplayHotkeyList( this, g_Module_Editor_Hotkeys_Descr );
|
||||
break;
|
||||
|
||||
case ID_PCB_LIB_WIZARD:
|
||||
case ID_PCB_LIB_TABLE_EDIT:
|
||||
{
|
||||
bool tableChanged = false;
|
||||
int r = 0;
|
||||
|
||||
if( id == ID_PCB_LIB_TABLE_EDIT )
|
||||
r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() );
|
||||
else
|
||||
r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() );
|
||||
int r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() );
|
||||
|
||||
if( r & 1 )
|
||||
{
|
||||
|
|
|
@ -75,24 +75,6 @@ class PCB_PLOT_PARAMS;
|
|||
int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal,
|
||||
FP_LIB_TABLE* aProject );
|
||||
|
||||
/**
|
||||
* Function InvokeFootprintWizard
|
||||
* Runs the footprint library wizard for easy library addition.
|
||||
*
|
||||
* @param aCaller is the wxTopLevelWindow which is invoking the dialog.
|
||||
* @param aGlobal is the common footprint library table file being edited. If aGlobal is NULL, then
|
||||
* it will not be updated.
|
||||
* @param aProject is the project specific footprint library table file being edited. if aProject
|
||||
* is NULL, then it will not be updated.
|
||||
*
|
||||
* @return int 0 - no changes
|
||||
* 1 - changes in the global table
|
||||
* 2 - changes in the project table
|
||||
* 3 - changes in both tables
|
||||
*/
|
||||
int InvokeFootprintWizard( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal,
|
||||
FP_LIB_TABLE* aProject );
|
||||
|
||||
/**
|
||||
* Function Invoke3DShapeLibsDownloaderWizard
|
||||
* Runs the downloader wizard for easy 3D shape libraries download from
|
||||
|
|
|
@ -435,10 +435,6 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
_( "Edit path configuration environment variables" ),
|
||||
KiBitmap( path_xpm ) );
|
||||
|
||||
AddMenuItem( prefs_menu, ID_PCB_LIB_WIZARD,
|
||||
_( "Add &Footprint Libraries Wizard..." ), _( "Add footprint libraries with wizard" ),
|
||||
KiBitmap( wizard_add_fplib_small_xpm ) );
|
||||
|
||||
AddMenuItem( prefs_menu, ID_PCB_LIB_TABLE_EDIT,
|
||||
_( "Manage Footprint Li&braries..." ), _( "Configure footprint library table" ),
|
||||
KiBitmap( library_table_xpm ) );
|
||||
|
|
|
@ -326,11 +326,6 @@ void prepareLibraryMenu( wxMenu* aParentMenu )
|
|||
_( "Edit path configuration environment variables" ),
|
||||
KiBitmap( path_xpm ) );
|
||||
|
||||
AddMenuItem( aParentMenu, ID_PCB_LIB_WIZARD,
|
||||
_( "&Add Footprint Libraries Wizard..." ),
|
||||
_( "Add footprint libraries using wizard" ),
|
||||
KiBitmap( wizard_add_fplib_small_xpm ) );
|
||||
|
||||
AddMenuItem( aParentMenu, ID_PCB_LIB_TABLE_EDIT,
|
||||
_( "Manage Footprint Li&braries..." ),
|
||||
_( "Edit the global and project footprint library lists" ),
|
||||
|
|
|
@ -146,7 +146,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
// menu Config
|
||||
EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, PCB_EDIT_FRAME::OnConfigurePcbOptions )
|
||||
EVT_MENU( ID_PCB_LIB_TABLE_EDIT, PCB_EDIT_FRAME::Process_Config )
|
||||
EVT_MENU( ID_PCB_LIB_WIZARD, PCB_EDIT_FRAME::Process_Config )
|
||||
EVT_MENU( ID_PCB_3DSHAPELIB_WIZARD, PCB_EDIT_FRAME::Process_Config )
|
||||
EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, PCB_EDIT_FRAME::OnConfigurePaths )
|
||||
EVT_MENU( ID_CONFIG_SAVE, PCB_EDIT_FRAME::Process_Config )
|
||||
|
|
|
@ -90,16 +90,10 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
}
|
||||
break;
|
||||
|
||||
case ID_PCB_LIB_WIZARD:
|
||||
case ID_PCB_LIB_TABLE_EDIT:
|
||||
{
|
||||
bool tableChanged = false;
|
||||
int r = 0;
|
||||
|
||||
if( id == ID_PCB_LIB_TABLE_EDIT )
|
||||
r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() );
|
||||
else
|
||||
r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() );
|
||||
int r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() );
|
||||
|
||||
if( r & 1 )
|
||||
{
|
||||
|
|
|
@ -303,7 +303,6 @@ enum pcbnew_ids
|
|||
ID_MENU_PCB_SHOW_3D_FRAME,
|
||||
ID_PCB_USER_GRID_SETUP,
|
||||
ID_PCB_GEN_BOM_FILE_FROM_BOARD,
|
||||
ID_PCB_LIB_WIZARD,
|
||||
ID_PCB_3DSHAPELIB_WIZARD,
|
||||
ID_PCB_LIB_TABLE_EDIT,
|
||||
ID_MENU_PCB_SHOW_DESIGN_RULES_DIALOG,
|
||||
|
|
Loading…
Reference in New Issue