KiCad PCB EDA Suite
dialog_global_lib_table_config.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 (C) 2019 Wayne Stambaugh <[email protected]>
5 * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
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
22
23#include <pgm_base.h>
24#include <search_stack.h>
25#include <systemdirsappend.h>
26
27#include <wx/stdpaths.h>
28
29
31 const wxString& aTableName ) :
33 m_defaultFileFound( false )
34{
35 m_tableName = aTableName;
36
37 wxString tmp;
38
39 tmp.Printf( _( "Configure Global %s Library Table" ), aTableName.Capitalize() );
40 SetTitle( tmp );
41
42 tmp.Printf( _( "KiCad has been run for the first time using the new %s library table for\n"
43 "accessing libraries. In order for KiCad to access %s libraries,\n"
44 "you must configure your global %s library table. Please select from one\n"
45 "of the options below. If you are not sure which option to select, please\n"
46 "use the default selection." ), aTableName, aTableName, aTableName );
47 m_staticText1->SetLabel( tmp );
48
49 tmp.Printf( _( "Copy default global %s library table (recommended)"), aTableName );
50 m_defaultRb->SetLabel( tmp );
51 tmp.Printf( _( "Select this option if you not sure about configuring the global %s library "
52 "table" ), aTableName );
53 m_defaultRb->SetToolTip( tmp );
54
55 tmp.Printf( _( "Copy custom global %s library table" ), aTableName );
56 m_customRb->SetLabel( tmp );
57 tmp.Printf( _( "Select this option to copy a %s library table file other than the default" ),
58 aTableName );
59 m_customRb->SetToolTip( tmp );
60
61 tmp.Printf( _( "Create an empty global %s library table" ), aTableName );
62 m_emptyRb->SetLabel( tmp );
63 tmp.Printf( _( "Select this option to define %s libraries in project specific library tables" ),
64 aTableName );
65 m_emptyRb->SetToolTip( tmp );
66
67 tmp.Printf( _( "Select global %s library table file:" ), aTableName );
68 m_staticText2->SetLabel( tmp );
69
70 m_filePicker1->Connect( wxEVT_UPDATE_UI,
72 nullptr, this );
73
75
77}
78
79
81{
82 m_filePicker1->Disconnect( wxEVT_UPDATE_UI,
84 nullptr, this );
85}
86
87
89{
90 aEvent.Enable( m_customRb->GetValue() );
91}
92
93
95{
96 aEvent.Enable( m_defaultFileFound );
97}
98
99
101{
102 if( !wxDialog::TransferDataToWindow() )
103 return false;
104
105 wxFileName fn = GetGlobalTableFileName();
106
107 SEARCH_STACK ss;
108
109 SystemDirsAppend( &ss );
110
111 wxString templatePath =
112 Pgm().GetLocalEnvVariables().at( wxT( "KICAD6_TEMPLATE_DIR" ) ).GetValue();
113
114 if( !templatePath.IsEmpty() )
115 ss.AddPaths( templatePath, 0 );
116 else
117 templatePath = wxStandardPaths::Get().GetUserConfigDir();
118
119 m_filePicker1->SetInitialDirectory( templatePath );
120
121 // Attempt to find the default global file table from the KiCad template folder.
122 wxString fileName = ss.FindValidPath( fn.GetName() );
123
124 m_defaultFileFound = wxFileName::FileExists( fileName );
125
127 {
128 m_filePicker1->SetPath(fileName );
129 m_filePicker1->Enable( false );
130 }
131 else
132 {
133 m_customRb->SetValue( true );
134 }
135
136 return true;
137}
Class DIALOG_GLOBAL_LIB_TABLE_CONFIG_BASE.
virtual void onUpdateDefaultSelection(wxUpdateUIEvent &aEvent) override
DIALOG_GLOBAL_LIB_TABLE_CONFIG(wxWindow *aParent, const wxString &aTableName)
virtual void onUpdateFilePicker(wxUpdateUIEvent &aEvent) override
virtual wxFileName GetGlobalTableFileName()=0
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Look for files in a number of paths.
Definition: search_stack.h:42
void AddPaths(const wxString &aPaths, int aIndex=-1)
Insert or append path(s).
#define _(s)
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Append system places to aSearchStack in a platform specific way and pertinent to KiCad programs.
System directories search utilities.