2020-03-10 18:46:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2022-12-13 20:47:28 +00:00
|
|
|
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-03-10 18:46:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <sch_edit_frame.h>
|
|
|
|
#include <wildcards_and_files_ext.h>
|
|
|
|
#include <confirm.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2022-12-13 20:47:28 +00:00
|
|
|
#include <widgets/std_bitmap_button.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/filedlg.h>
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
#include <dialog_sch_import_settings.h>
|
|
|
|
|
|
|
|
|
|
|
|
wxString DIALOG_SCH_IMPORT_SETTINGS::m_filePath; // remember for session
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_SCH_IMPORT_SETTINGS::DIALOG_SCH_IMPORT_SETTINGS( wxWindow* aParent, SCH_EDIT_FRAME* aFrame ) :
|
|
|
|
DIALOG_SCH_IMPORT_SETTINGS_BASE( aParent ),
|
|
|
|
m_frame( aFrame )
|
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons( { { wxID_OK, _( "Import Settings" ) } } );
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_SCH_IMPORT_SETTINGS::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
m_filePathCtrl->SetValue( m_filePath );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_SCH_IMPORT_SETTINGS::OnBrowseClicked( wxCommandEvent& event )
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxFileName fn = m_frame->Schematic().Root().GetFileName();
|
2020-06-08 02:19:46 +00:00
|
|
|
fn.SetExt( ProjectFileExtension );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Import Settings From" ), fn.GetPath(), fn.GetFullName(),
|
|
|
|
ProjectFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
|
|
|
m_filePathCtrl->SetValue( dlg.GetPath() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_SCH_IMPORT_SETTINGS::TransferDataFromWindow()
|
|
|
|
{
|
|
|
|
if( !wxFileExists( m_filePathCtrl->GetValue() ) )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxString::Format( _( "File not found." ) ) );
|
|
|
|
m_filePathCtrl->SetFocus();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_filePath = m_filePathCtrl->GetValue();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_SCH_IMPORT_SETTINGS::OnSelectAll( wxCommandEvent& event )
|
|
|
|
{
|
2020-07-06 10:51:04 +00:00
|
|
|
m_FormattingOpt->SetValue( true );
|
|
|
|
m_FieldNameTemplatesOpt->SetValue( true );
|
|
|
|
m_PinMapOpt->SetValue( true );
|
2020-03-10 18:46:57 +00:00
|
|
|
m_SeveritiesOpt->SetValue( true );
|
2020-07-06 10:51:04 +00:00
|
|
|
m_NetClassesOpt->SetValue( true );
|
2023-09-27 13:13:55 +00:00
|
|
|
m_BomPresetsOpt->SetValue( true );
|
|
|
|
m_BomFmtPresetsOpt->SetValue( true );
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|