KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_sch_import_settings.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 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <bitmaps.h>
25#include <sch_edit_frame.h>
27#include <confirm.h>
28#include <schematic.h>
30#include <wx/filedlg.h>
31
33
34
35wxString DIALOG_SCH_IMPORT_SETTINGS::m_filePath; // remember for session
36
37
39 SCH_EDIT_FRAME* aFrame ) :
41 m_frame( aFrame )
42{
43 m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
44
45 SetupStandardButtons( { { wxID_OK, _( "Import Settings" ) } } );
46}
47
48
50{
51 m_filePathCtrl->SetValue( m_filePath );
52 return true;
53}
54
55
57{
58 wxFileName fn = m_frame->Schematic().Root().GetFileName();
60
61 wxFileDialog dlg( this, _( "Import Settings From" ), fn.GetPath(), fn.GetFullName(),
63 wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
64
65 if( dlg.ShowModal() == wxID_OK )
66 m_filePathCtrl->SetValue( dlg.GetPath() );
67}
68
69
71{
72 if( !wxFileExists( m_filePathCtrl->GetValue() ) )
73 {
74 DisplayError( this, wxString::Format( _( "File not found." ) ) );
75 m_filePathCtrl->SetFocus();
76 return false;
77 }
78
79 m_filePath = m_filePathCtrl->GetValue();
80 return true;
81}
82
83
84void DIALOG_SCH_IMPORT_SETTINGS::OnSelectAll( wxCommandEvent& event )
85{
86 m_FormattingOpt->SetValue( true );
87 m_FieldNameTemplatesOpt->SetValue( true );
88 m_PinMapOpt->SetValue( true );
89 m_SeveritiesOpt->SetValue( true );
90 m_NetClassesOpt->SetValue( true );
91 m_BomPresetsOpt->SetValue( true );
92 m_BomFmtPresetsOpt->SetValue( true );
93 m_BusAliasesOpt->SetValue( true );
94 m_TextVarsOpt->SetValue( true );
95}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
Class DIALOG_SCH_IMPORT_SETTINGS_BASE.
void OnSelectAll(wxCommandEvent &event) override
void OnBrowseClicked(wxCommandEvent &event) override
DIALOG_SCH_IMPORT_SETTINGS(wxWindow *aParent, SCH_EDIT_FRAME *aFrame)
void SetupStandardButtons(std::map< int, wxString > aLabels={})
SCH_SHEET & Root() const
Definition: schematic.h:130
Schematic editor (Eeschema) main window.
SCHEMATIC & Schematic() const
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:305
void SetBitmap(const wxBitmapBundle &aBmp)
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
This file is part of the common library.
#define _(s)
static const std::string ProjectFileExtension
static wxString ProjectFileWildcard()
Definition of file extensions used in Kicad.