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>();
258 wxFileName tableFile( tablePath );
265 ? R
"(^\$\{KICAD\d+_SYMBOL_DIR\})"
266 : R"(^\$\{KICAD\d+_FOOTPRINT_DIR\})" );
268 bool insertStock =
true;
269 std::set<wxString> toRemove;
273 if( std::regex_search( row.URI().ToStdString(), builtInPattern ) )
275 toRemove.insert( row.URI() );
276 wxLogTrace(
traceLibraries, wxT(
"Libraries migration: removing old stock row '%s'" ), row.URI() );
282 if( row.URI().Matches( stockPath ) )
285 wxT(
"Libraries migration: migrated table already has latest stock setup" ) );
290 wxT(
"Libraries migration: migrated table has working stock table at "
291 "'%s' but calculated stock path '%s' is missing or invalid. Leaving alone." ),
292 row.URI(), stockPath );
297 wxT(
"Libraries migration: migrated chained table URI from '%s' to '%s'" ),
298 row.URI(), stockPath );
299 row.SetDescription(
_(
"KiCad Default Libraries" ) );
300 row.SetURI( stockPath );
305 auto toErase = std::ranges::remove_if(
table.Rows(),
308 return toRemove.contains( aRow.URI() );
311 table.Rows().erase( toErase.begin(), toErase.end() );
315 wxLogTrace(
traceLibraries, wxT(
"Libraries migration: inserting chained default table" ) );
320 chained.
SetURI( stockPath );
321 table.Rows().insert(
table.Rows().begin(), chained );
324 if( toRemove.size() || insertStock )
326 wxLogTrace(
traceLibraries, wxT(
"Libraries migration: removed %zu rows; saving" ), toRemove.size() );
331 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)
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
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.