KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_export_older_version.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#include <confirm.h>
23#include <downgrade_target.h>
24
25
26DIALOG_EXPORT_OLDER_VERSION::DIALOG_EXPORT_OLDER_VERSION( wxWindow* aParent, const wxArrayString& aTargets,
27 const wxArrayString& aVariants,
28 const wxString& aDefaultPath ) :
30{
31 m_targetChoice->Append( aTargets );
32 m_targetChoice->SetSelection( 0 );
33
34 m_variantChoice->Append( _( "Base design" ) );
35 m_variantChoice->Append( aVariants );
36 m_variantChoice->SetSelection( 0 );
37
38 m_targetChoice->Bind( wxEVT_CHOICE,
39 [this]( wxCommandEvent& )
40 {
42 } );
44
45 m_destPicker->SetPath( aDefaultPath );
46
47 SetupStandardButtons( { { wxID_OK, _( "Continue" ) } } );
48
50}
51
52
54{
55 return m_targetChoice->GetStringSelection();
56}
57
58
60{
61 if( !m_variantChoice->IsEnabled() || m_variantChoice->GetSelection() <= 0 )
62 return wxEmptyString;
63
64 return m_variantChoice->GetStringSelection();
65}
66
67
69{
71 bool supportsVariants = target && target->m_schVersion >= 20250922;
72 bool canFlatten = target && !supportsVariants && m_variantChoice->GetCount() > 1;
73
74 m_variantLabel->Enable( canFlatten );
75 m_variantChoice->Enable( canFlatten );
76 m_variantChoice->SetToolTip( supportsVariants ? _( "The target supports variants. All variants are exported." )
77 : _( "Choose the variant to flatten into the exported design." ) );
78}
79
80
82{
83 return m_destPicker->GetPath();
84}
85
86
91
92
94{
95 if( m_destPicker->GetPath().IsEmpty() )
96 {
97 DisplayErrorMessage( this, _( "Choose a destination folder." ) );
98 return false;
99 }
100
101 return true;
102}
DIALOG_EXPORT_OLDER_VERSION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Export for Older KiCad Version"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxString GetVariant() const
The variant to flatten, or empty for the base design.
DIALOG_EXPORT_OLDER_VERSION(wxWindow *aParent, const wxArrayString &aTargets, const wxArrayString &aVariants, const wxString &aDefaultPath)
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...
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
This file is part of the common library.
const DOWNGRADE_TARGET * FindDowngradeTarget(const wxString &aNameOrId)
Match a user-supplied target string against name or stable id, case-insensitively.
#define _(s)
An older KiCad release we can export a project back to.
int m_schVersion
SEXPR_SCHEMATIC_FILE_VERSION for the target.