From 270a6830b07a604bbeedd3d1f6bf3e4616eccc02 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 10 Mar 2026 08:48:04 -0400 Subject: [PATCH] Fix a few issues with library start wizard - Improve text layout / responsiveness - Fix missing stock tables warning not showing up in the right cases Fixes https://gitlab.com/kicad/code/kicad/-/issues/22923 --- .../dialogs/panel_startwizard_libraries_base.cpp | 11 +++++++++-- .../dialogs/panel_startwizard_libraries_base.fbp | 7 ++++--- common/dialogs/panel_startwizard_libraries_base.h | 6 +++++- common/libraries/library_manager.cpp | 13 ++++++++++++- .../startwizard/startwizard_provider_libraries.cpp | 14 ++++++++++++-- include/libraries/library_manager.h | 2 ++ 6 files changed, 44 insertions(+), 9 deletions(-) diff --git a/common/dialogs/panel_startwizard_libraries_base.cpp b/common/dialogs/panel_startwizard_libraries_base.cpp index 81bbc08c0d..7100a870e0 100644 --- a/common/dialogs/panel_startwizard_libraries_base.cpp +++ b/common/dialogs/panel_startwizard_libraries_base.cpp @@ -18,7 +18,7 @@ PANEL_STARTWIZARD_LIBRARIES_BASE::PANEL_STARTWIZARD_LIBRARIES_BASE( wxWindow* pa bSizer8 = new wxBoxSizer( wxVERTICAL ); m_stIntro = new wxStaticText( this, wxID_ANY, _("KiCad comes with a large set of symbol and footprint libraries maintained by the KiCad librarian team. You may also create your own libraries, and install third-party ones from the Plugin and Content Manager or other sources.\n\nLibrary tables are the configuration files which list the libraries to be loaded. Global libraries are available in every project, and you may also add project-specific libraries if desired."), wxDefaultPosition, wxDefaultSize, 0 ); - m_stIntro->Wrap( 540 ); + m_stIntro->Wrap( -1 ); bSizer8->Add( m_stIntro, 0, wxALL|wxEXPAND, 5 ); m_stRequiredTablesLabel = new wxStaticText( this, wxID_ANY, _("The following global library tables need to be created:"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -61,7 +61,7 @@ PANEL_STARTWIZARD_LIBRARIES_BASE::PANEL_STARTWIZARD_LIBRARIES_BASE( wxWindow* pa m_sizerWarning->Add( m_bmpWarning, 0, wxALL, 4 ); m_stWarning = new wxStaticText( this, wxID_ANY, _("The built-in library tables could not be found in the expected location. This usually means that you have installed the KiCad software without also installing the libraries. You can proceed with setup, but you will need to install the libraries separately in order for them to be available."), wxDefaultPosition, wxDefaultSize, 0 ); - m_stWarning->Wrap( 540 ); + m_stWarning->Wrap( -1 ); m_sizerWarning->Add( m_stWarning, 0, wxALL, 5 ); @@ -73,8 +73,15 @@ PANEL_STARTWIZARD_LIBRARIES_BASE::PANEL_STARTWIZARD_LIBRARIES_BASE( wxWindow* pa this->SetSizer( bPanelSizer ); this->Layout(); + bPanelSizer->Fit( this ); + + // Connect Events + this->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_STARTWIZARD_LIBRARIES_BASE::OnSize ) ); } PANEL_STARTWIZARD_LIBRARIES_BASE::~PANEL_STARTWIZARD_LIBRARIES_BASE() { + // Disconnect Events + this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_STARTWIZARD_LIBRARIES_BASE::OnSize ) ); + } diff --git a/common/dialogs/panel_startwizard_libraries_base.fbp b/common/dialogs/panel_startwizard_libraries_base.fbp index 8246019553..491f2236b7 100644 --- a/common/dialogs/panel_startwizard_libraries_base.fbp +++ b/common/dialogs/panel_startwizard_libraries_base.fbp @@ -48,13 +48,14 @@ PANEL_STARTWIZARD_LIBRARIES_BASE - 550,-1 + -1,-1 0 wxTAB_TRAVERSAL + OnSize bPanelSizer @@ -128,7 +129,7 @@ - 540 + -1 @@ -659,7 +660,7 @@ - 540 + -1 diff --git a/common/dialogs/panel_startwizard_libraries_base.h b/common/dialogs/panel_startwizard_libraries_base.h index 5519fa9f07..6e14fd75c5 100644 --- a/common/dialogs/panel_startwizard_libraries_base.h +++ b/common/dialogs/panel_startwizard_libraries_base.h @@ -45,9 +45,13 @@ class PANEL_STARTWIZARD_LIBRARIES_BASE : public wxPanel wxStaticBitmap* m_bmpWarning; wxStaticText* m_stWarning; + // Virtual event handlers, override them in your derived class + virtual void OnSize( wxSizeEvent& event ) { event.Skip(); } + + public: - PANEL_STARTWIZARD_LIBRARIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 550,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + 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 ); ~PANEL_STARTWIZARD_LIBRARIES_BASE(); diff --git a/common/libraries/library_manager.cpp b/common/libraries/library_manager.cpp index 48c44de757..a8ff6db6fc 100644 --- a/common/libraries/library_manager.cpp +++ b/common/libraries/library_manager.cpp @@ -346,6 +346,17 @@ wxString LIBRARY_MANAGER::DefaultGlobalTablePath( LIBRARY_TABLE_TYPE aType ) } +wxString LIBRARY_MANAGER::StockTablePath( LIBRARY_TABLE_TYPE aType ) +{ + wxString basePath = PATHS::GetStockTemplatesPath(); + + wxFileName fn( basePath, tableFileName( aType ) ); + fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS ); + + return fn.GetFullPath(); +} + + bool LIBRARY_MANAGER::IsTableValid( const wxString& aPath ) { if( wxFileName fn( aPath ); fn.IsFileReadable() ) @@ -393,7 +404,7 @@ bool LIBRARY_MANAGER::CreateGlobalTable( LIBRARY_TABLE_TYPE aType, bool aPopulat table.SetType( aType ); table.Rows().clear(); - wxFileName defaultLib( PATHS::GetStockTemplatesPath(), tableFileName( aType ) ); + wxFileName defaultLib( StockTablePath( aType ) ); if( !defaultLib.IsFileReadable() ) { diff --git a/common/startwizard/startwizard_provider_libraries.cpp b/common/startwizard/startwizard_provider_libraries.cpp index 60bb53446c..9aa494906d 100644 --- a/common/startwizard/startwizard_provider_libraries.cpp +++ b/common/startwizard/startwizard_provider_libraries.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ public: m_model( aModel ), m_wizard( aWizard ) { + wxWindowBase::SetMaxSize( { FromDIP( 640 ), -1 } ); m_bmpWarning->SetBitmap( KiBitmapBundle( BITMAPS::dialog_warning ) ); m_sizerWarning->Layout(); @@ -88,7 +90,8 @@ public: } } - m_sizerWarning->Hide( !m_showWarning ); + m_bmpWarning->Show( m_showWarning ); + m_stWarning->Show( m_showWarning ); return true; } @@ -100,7 +103,7 @@ public: for( const LIBRARY_TABLE_TYPE& type : m_model->missing_tables ) { - if( !LIBRARY_MANAGER::IsTableValid( LIBRARY_MANAGER::DefaultGlobalTablePath( type ) ) ) + if( !LIBRARY_MANAGER::IsTableValid( LIBRARY_MANAGER::StockTablePath( type ) ) ) m_showWarning = true; switch( type ) @@ -125,6 +128,13 @@ public: m_stRequiredTables->SetLabel( missingTablesText.BeforeLast( '\n' ) ); } + void OnSize( wxSizeEvent& aEvt ) override + { + aEvt.Skip(); + m_stIntro->Wrap( GetClientSize().x - FromDIP( 20 ) ); + m_stWarning->Wrap( GetClientSize().x - m_bmpWarning->GetSize().x - FromDIP( 28 ) ); + } + private: std::shared_ptr m_model; STARTWIZARD* m_wizard; diff --git a/include/libraries/library_manager.h b/include/libraries/library_manager.h index 7a605af1aa..c5d8d61851 100644 --- a/include/libraries/library_manager.h +++ b/include/libraries/library_manager.h @@ -231,6 +231,8 @@ public: static wxString DefaultGlobalTablePath( LIBRARY_TABLE_TYPE aType ); + static wxString StockTablePath( LIBRARY_TABLE_TYPE aType ); + static bool IsTableValid( const wxString& aPath ); /// @return true if all required global tables are present on disk and valid