30#include <magic_enum.hpp>
47 wxWindowBase::SetMaxSize( { FromDIP( 640 ), -1 } );
65 m_containingSizer->Fit(
this );
66 SetSize( GetBestSize() );
78 m_model->mode_initialized =
true;
87 if( !
m_model->mode_initialized )
93 if( settings->NeedsUserInput() )
99 m_model->mode_initialized =
true;
113 if( !settings->NeedsUserInput() )
146 wxString missingTablesText;
154 wxLogTrace(
traceLibraries, wxT(
"Stock table path for %s is not valid; will show warning" ),
155 magic_enum::enum_name( type ) );
162 missingTablesText.Append(
_(
"Symbol library table" ) +
"\n" );
166 missingTablesText.Append(
_(
"Footprint library table" ) +
"\n" );
170 missingTablesText.Append(
_(
"Design Block library table" ) +
"\n" );
181 void OnSize( wxSizeEvent& aEvt )
override
190#if defined( __WXMAC__ )
191 m_stIntro->Wrap( GetClientSize().x - FromDIP( 20 ) );
193#elif defined( __WXMSW__ )
197 m_stIntro->Wrap( GetClientSize().x - FromDIP( 10 ) );
216 std::shared_ptr<STARTWIZARD_PROVIDER_LIBRARIES_MODEL>
m_model;
238 m_model = std::make_shared<STARTWIZARD_PROVIDER_LIBRARIES_MODEL>();
245 const wxString& aStockPath,
bool aStockPathValid )
248 ? R
"(^\$\{KICAD\d+_SYMBOL_DIR\})"
249 : R"(^\$\{KICAD\d+_FOOTPRINT_DIR\})" );
254 bool insertStock =
false;
255 bool haveChained =
false;
256 bool chainedRepointed =
false;
257 std::set<wxString> toRemove;
261 if( std::regex_search( row.URI().ToStdString(), builtInPattern ) )
263 toRemove.insert( row.URI() );
265 wxLogTrace(
traceLibraries, wxT(
"Libraries migration: removing old stock row '%s'" ), row.URI() );
271 if( row.URI().Matches( aStockPath ) )
274 wxT(
"Libraries migration: migrated table already has latest stock setup" ) );
279 wxT(
"Libraries migration: migrated table has working stock table at "
280 "'%s' but calculated stock path '%s' is missing or invalid. Leaving alone." ),
281 row.URI(), aStockPath );
286 wxT(
"Libraries migration: migrated chained table URI from '%s' to '%s'" ),
287 row.URI(), aStockPath );
288 row.SetDescription(
_(
"KiCad Default Libraries" ) );
289 row.SetURI( aStockPath );
290 chainedRepointed =
true;
295 auto toErase = std::ranges::remove_if( aTable.
Rows(),
298 return toRemove.contains( aRow.URI() );
301 aTable.
Rows().erase( toErase.begin(), toErase.end() );
309 wxLogTrace(
traceLibraries, wxT(
"Libraries migration: inserting chained default table" ) );
314 chained.
SetURI( aStockPath );
315 aTable.
Rows().insert( aTable.
Rows().begin(), chained );
318 return !toRemove.empty() || insertStock || chainedRepointed;
336 wxFileName tableFile( tablePath );
345 wxLogTrace(
traceLibraries, wxT(
"Libraries migration: no actions needed" ) );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
static wxString DefaultGlobalTablePath(LIBRARY_TABLE_TYPE aType)
static std::vector< LIBRARY_TABLE_TYPE > InvalidGlobalTables()
static bool GlobalTablesValid()
static bool CreateGlobalTable(LIBRARY_TABLE_TYPE aType, bool aPopulateDefaultLibraries)
static wxString StockTablePath(LIBRARY_TABLE_TYPE aType)
static bool IsTableValid(const wxString &aPath)
void SetNickname(const wxString &aNickname)
void SetType(const wxString &aType)
void SetDescription(const wxString &aDescription)
static const wxString TABLE_TYPE_NAME
void SetURI(const wxString &aUri)
LIBRARY_TABLE_ROW MakeRow() const
Builds a new row that is suitable for this table (does not insert it)
const std::deque< LIBRARY_TABLE_ROW > & Rows() const
wxRadioButton * m_rbBlankTables
wxRadioButton * m_rbImport
wxCheckBox * m_cbMigrateBuiltInLibraries
wxStaticText * m_stWarning
wxRadioButton * m_rbDefaultTables
PANEL_STARTWIZARD_LIBRARIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxStaticBitmap * m_bmpWarning
wxStaticText * m_stRequiredTables
wxBoxSizer * m_sizerWarning
PANEL_STARTWIZARD_LIBRARIES(const std::shared_ptr< STARTWIZARD_PROVIDER_LIBRARIES_MODEL > &aModel, wxWindow *aParent, STARTWIZARD *aWizard)
void UpdateMigrateCheckboxState()
bool TransferDataFromWindow() override
std::shared_ptr< STARTWIZARD_PROVIDER_LIBRARIES_MODEL > m_model
void OnSize(wxSizeEvent &aEvt) override
bool TransferDataToWindow() override
void OnModeChanged(wxCommandEvent &aEvt)
std::shared_ptr< STARTWIZARD_PROVIDER_LIBRARIES_MODEL > m_model
wxPanel * GetWizardPanel(wxWindow *aParent, STARTWIZARD *aWizard) override
void ApplyDefaults() override
Apply whatever actions and settings should happen if the user cancels the startup wizard.
bool NeedsUserInput() const override
static KICOMMON_API bool MigrateBuiltInLibraries(LIBRARY_TABLE &aTable, LIBRARY_TABLE_TYPE aType, const wxString &aStockPath, bool aStockPathValid)
Migrates built-in (stock) library references in an imported global library table to the current versi...
STARTWIZARD_PROVIDER_LIBRARIES()
STARTWIZARD_PROVIDER(const wxString &aPageName)
const wxChar *const traceLibraries
Flag to enable library table and library manager tracing.
std::vector< std::vector< std::string > > table
wxLogTrace helper definitions.