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 }
43
44 bool TransferDataFromWindow() override
45 {
46 if( m_rbDefaultTables->GetValue() )
48 else if( m_rbImport->GetValue() )
50 else
52
53 return true;
54 }
55
56 bool TransferDataToWindow() override
57 {
58 switch( m_model->mode )
59 {
61 case STARTWIZARD_LIBRARIES_MODE::IMPORT: m_rbImport->SetValue( true ); break;
62 case STARTWIZARD_LIBRARIES_MODE::CREATE_BLANK: m_rbBlankTables->SetValue( true ); break;
63 }
64
65 if( auto settings = dynamic_cast<STARTWIZARD_PROVIDER_SETTINGS*>( m_wizard->GetProvider( "settings" ) ) )
66 {
67 if( !settings->NeedsUserInput() )
68 {
69 // If the user didn't see the settings screen at all, just hide this option; we
70 // only offer import when we have the context of a previous version settings
71 // path selected by the user
72 m_rbImport->Show( false );
73 }
74 else if( settings->GetModel().mode == STARTWIZARD_SETTINGS_MODE::USE_DEFAULTS )
75 {
76 // But if they did see the screen and chose not to import, show the option but
77 // disable it as a breadcrumb that they can go back and choose to import settings
78 m_rbImport->Disable();
79
80 if( m_rbImport->GetValue() )
81 m_rbDefaultTables->SetValue( true );
82 }
83 else
84 {
85 m_rbImport->Enable();
86 }
87 }
88
89 wxString missingTablesText;
90 bool showWarning = false;
91
92 for( const LIBRARY_TABLE_TYPE& type : m_model->missing_tables )
93 {
95 showWarning = true;
96
97 switch( type )
98 {
100 missingTablesText.Append( _( "Symbol library table" ) + "\n" );
101 break;
102
104 missingTablesText.Append( _( "Footprint library table" ) + "\n" );
105 break;
106
108 missingTablesText.Append( _( "Design Block library table" ) + "\n" );
109 break;
110
112 break;
113 }
114 }
115
116 m_stRequiredTables->SetLabel( missingTablesText.BeforeLast( '\n' ) );
117
118 m_sizerWarning->Hide( !showWarning );
119
120 return true;
121 }
122
123private:
124 std::shared_ptr<STARTWIZARD_PROVIDER_LIBRARIES_MODEL> m_model;
126};
127
128
133
134
139
140
141wxPanel* STARTWIZARD_PROVIDER_LIBRARIES::GetWizardPanel( wxWindow* aParent, STARTWIZARD* aWizard )
142{
143 m_model = std::make_shared<STARTWIZARD_PROVIDER_LIBRARIES_MODEL>();
145 return new PANEL_STARTWIZARD_LIBRARIES( m_model, aParent, aWizard );
146}
147
148
150{
151 // TODO(JE) handle importing tables from previous version and sanitizing them
152
153 bool populateTables = m_model->mode == STARTWIZARD_LIBRARIES_MODE::USE_DEFAULTS;
154
156 {
157 LIBRARY_MANAGER::CreateGlobalTable( type, populateTables );
158 }
159}
160
161
169
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