KiCad PCB EDA Suite
Loading...
Searching...
No Matches
startwizard_provider_libraries.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 * @author Jon Evans <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <pgm_base.h>
29
30
32{
33public:
34 PANEL_STARTWIZARD_LIBRARIES( const std::shared_ptr<STARTWIZARD_PROVIDER_LIBRARIES_MODEL>& aModel,
35 wxWindow* aParent, STARTWIZARD* aWizard ) :
37 m_model( aModel ),
38 m_wizard( aWizard )
39 {
41 m_sizerWarning->Layout();
42
44 }
45
46 bool TransferDataFromWindow() override
47 {
48 if( m_rbDefaultTables->GetValue() )
50 else if( m_rbImport->GetValue() )
52 else
54
55 return true;
56 }
57
58 bool TransferDataToWindow() override
59 {
60 switch( m_model->mode )
61 {
63 case STARTWIZARD_LIBRARIES_MODE::IMPORT: m_rbImport->SetValue( true ); break;
64 case STARTWIZARD_LIBRARIES_MODE::CREATE_BLANK: m_rbBlankTables->SetValue( true ); break;
65 }
66
67 if( auto settings = dynamic_cast<STARTWIZARD_PROVIDER_SETTINGS*>( m_wizard->GetProvider( "settings" ) ) )
68 {
69 if( !settings->NeedsUserInput() )
70 {
71 // If the user didn't see the settings screen at all, just hide this option; we
72 // only offer import when we have the context of a previous version settings
73 // path selected by the user
74 m_rbImport->Show( false );
75 }
76 else if( settings->GetModel().mode == STARTWIZARD_SETTINGS_MODE::USE_DEFAULTS )
77 {
78 // But if they did see the screen and chose not to import, show the option but
79 // disable it as a breadcrumb that they can go back and choose to import settings
80 m_rbImport->Disable();
81
82 if( m_rbImport->GetValue() )
83 m_rbDefaultTables->SetValue( true );
84 }
85 else
86 {
87 m_rbImport->Enable();
88 }
89 }
90
92
93 return true;
94 }
95
97 {
98 wxString missingTablesText;
99 m_showWarning = false;
100
101 for( const LIBRARY_TABLE_TYPE& type : m_model->missing_tables )
102 {
104 m_showWarning = true;
105
106 switch( type )
107 {
109 missingTablesText.Append( _( "Symbol library table" ) + "\n" );
110 break;
111
113 missingTablesText.Append( _( "Footprint library table" ) + "\n" );
114 break;
115
117 missingTablesText.Append( _( "Design Block library table" ) + "\n" );
118 break;
119
121 break;
122 }
123 }
124
125 m_stRequiredTables->SetLabel( missingTablesText.BeforeLast( '\n' ) );
126 }
127
128private:
129 std::shared_ptr<STARTWIZARD_PROVIDER_LIBRARIES_MODEL> m_model;
132};
133
134
139
140
145
146
147wxPanel* STARTWIZARD_PROVIDER_LIBRARIES::GetWizardPanel( wxWindow* aParent, STARTWIZARD* aWizard )
148{
149 m_model = std::make_shared<STARTWIZARD_PROVIDER_LIBRARIES_MODEL>();
151 return new PANEL_STARTWIZARD_LIBRARIES( m_model, aParent, aWizard );
152}
153
154
156{
157 // TODO(JE) handle importing tables from previous version and sanitizing them
158
159 bool populateTables = m_model->mode == STARTWIZARD_LIBRARIES_MODE::USE_DEFAULTS;
160
162 {
163 LIBRARY_MANAGER::CreateGlobalTable( type, populateTables );
164 }
165}
166
167
175
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
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 bool IsTableValid(const wxString &aPath)
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(const std::shared_ptr< STARTWIZARD_PROVIDER_LIBRARIES_MODEL > &aModel, wxWindow *aParent, STARTWIZARD *aWizard)
std::shared_ptr< STARTWIZARD_PROVIDER_LIBRARIES_MODEL > m_model
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.
STARTWIZARD_PROVIDER(const wxString &aPageName)
#define _(s)
LIBRARY_TABLE_TYPE
see class PGM_BASE