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
This commit is contained in:
Jon Evans
2026-03-10 08:48:04 -04:00
parent 10592c242d
commit 270a6830b0
6 changed files with 44 additions and 9 deletions
@@ -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, _("<b>The following global library tables need to be created:</b>"), 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 ) );
}
@@ -48,13 +48,14 @@
<property name="minimum_size"></property>
<property name="name">PANEL_STARTWIZARD_LIBRARIES_BASE</property>
<property name="pos"></property>
<property name="size">550,-1</property>
<property name="size">-1,-1</property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnSize">OnSize</event>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">bPanelSizer</property>
@@ -128,7 +129,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">540</property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="true">
@@ -659,7 +660,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">540</property>
<property name="wrap">-1</property>
</object>
</object>
</object>
@@ -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();
+12 -1
View File
@@ -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() )
{
@@ -23,6 +23,7 @@
#include <bitmaps/bitmap_types.h>
#include <dialogs/panel_startwizard_libraries_base.h>
#include <libraries/library_manager.h>
#include <paths.h>
#include <startwizard/startwizard.h>
#include <startwizard/startwizard_provider_libraries.h>
#include <startwizard/startwizard_provider_settings.h>
@@ -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<STARTWIZARD_PROVIDER_LIBRARIES_MODEL> m_model;
STARTWIZARD* m_wizard;
+2
View File
@@ -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