Add an option to not migrate library tables when migrating settings

Fixes https://gitlab.com/kicad/code/kicad/-/issues/3924
This commit is contained in:
Jon Evans 2020-09-24 20:54:31 -04:00
parent ae3ef90f7d
commit 0c5aabc7f7
6 changed files with 99 additions and 7 deletions

View File

@ -83,6 +83,8 @@ bool DIALOG_MIGRATE_SETTINGS::TransferDataFromWindow()
else
m_manager->SetMigrationSource( wxEmptyString );
m_manager->SetMigrateLibraryTables( m_cbCopyLibraryTables->GetValue() );
return true;
}
@ -92,6 +94,7 @@ void DIALOG_MIGRATE_SETTINGS::OnPrevVerSelected( wxCommandEvent& event )
m_standardButtons->GetAffirmativeButton()->Enable();
m_cbPath->Enable();
m_btnCustomPath->Enable();
m_cbCopyLibraryTables->Enable();
validatePath();
}
@ -126,6 +129,7 @@ void DIALOG_MIGRATE_SETTINGS::OnDefaultSelected( wxCommandEvent& event )
m_standardButtons->GetAffirmativeButton()->Enable();
m_cbPath->Disable();
m_btnCustomPath->Disable();
m_cbCopyLibraryTables->Disable();
showPathError( false );
}
@ -147,4 +151,4 @@ void DIALOG_MIGRATE_SETTINGS::showPathError( bool aShow )
m_lblPathError->Show( aShow );
Layout();
Fit();
}
}

View File

@ -61,6 +61,12 @@ DIALOG_MIGRATE_SETTINGS_BASE::DIALOG_MIGRATE_SETTINGS_BASE( wxWindow* parent, wx
bSizer6->Add( m_lblPathError, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
m_cbCopyLibraryTables = new wxCheckBox( this, wxID_ANY, wxT("Import library configuration from previous version"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbCopyLibraryTables->SetValue(true);
m_cbCopyLibraryTables->SetToolTip( wxT("When checked, the symbol and footprint library tables from the previous version will be imported into this version") );
bSizer6->Add( m_cbCopyLibraryTables, 0, wxALL, 5 );
m_btnUseDefaults = new wxRadioButton( this, wxID_ANY, wxT("Start with default settings"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_btnUseDefaults, 0, wxALL|wxEXPAND, 5 );

View File

@ -487,6 +487,70 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Import library configuration from previous version</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbCopyLibraryTables</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">When checked, the symbol and footprint library tables from the previous version will be imported into this version</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>

View File

@ -24,6 +24,7 @@
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/statline.h>
#include <wx/dialog.h>
@ -45,6 +46,7 @@ class DIALOG_MIGRATE_SETTINGS_BASE : public DIALOG_SHIM
wxComboBox* m_cbPath;
wxBitmapButton* m_btnCustomPath;
wxStaticText* m_lblPathError;
wxCheckBox* m_cbCopyLibraryTables;
wxRadioButton* m_btnUseDefaults;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_standardButtons;

View File

@ -50,7 +50,8 @@ SETTINGS_MANAGER::SETTINGS_MANAGER( bool aHeadless ) :
m_headless( aHeadless ),
m_kiway( nullptr ),
m_common_settings( nullptr ),
m_migration_source()
m_migration_source(),
m_migrateLibraryTables( true )
{
// Check if the settings directory already exists, and if not, perform a migration if possible
if( !MigrateIfNeeded() )
@ -356,18 +357,28 @@ private:
wxString m_src;
wxString m_dest;
wxString m_errors;
bool m_migrateTables;
public:
MIGRATION_TRAVERSER( const wxString& aSrcDir, const wxString& aDestDir ) :
m_src( aSrcDir ), m_dest( aDestDir )
MIGRATION_TRAVERSER( const wxString& aSrcDir, const wxString& aDestDir, bool aMigrateTables ) :
m_src( aSrcDir ),
m_dest( aDestDir ),
m_migrateTables( aMigrateTables )
{
}
wxString GetErrors() { return m_errors; }
virtual wxDirTraverseResult OnFile( const wxString& aSrcFilePath ) override
wxDirTraverseResult OnFile( const wxString& aSrcFilePath ) override
{
wxFileName file( aSrcFilePath );
if( !m_migrateTables && ( file.GetName() == wxT( "sym-lib-table" ) ||
file.GetName() == wxT( "fp-lib-table" ) ) )
{
return wxDIR_CONTINUE;
}
wxString path = file.GetPath();
path.Replace( m_src, m_dest, false );
@ -381,7 +392,7 @@ public:
return wxDIR_CONTINUE;
}
virtual wxDirTraverseResult OnDir( const wxString& dirPath ) override
wxDirTraverseResult OnDir( const wxString& dirPath ) override
{
wxFileName dir( dirPath );
@ -452,7 +463,7 @@ bool SETTINGS_MANAGER::MigrateIfNeeded()
return true;
}
MIGRATION_TRAVERSER traverser( m_migration_source, path.GetFullPath() );
MIGRATION_TRAVERSER traverser( m_migration_source, path.GetFullPath(), m_migrateLibraryTables );
wxDir source_dir( m_migration_source );
source_dir.Traverse( traverser );

View File

@ -189,6 +189,8 @@ public:
*/
void SetMigrationSource( const wxString& aSource ) { m_migration_source = aSource; }
void SetMigrateLibraryTables( bool aMigrate = true ) { m_migrateLibraryTables = aMigrate; }
/**
* Retreives the name of the most recent previous KiCad version that can be found in the
* user settings directory. For legacy versions (5.x, and 5.99 builds before this code was
@ -382,6 +384,9 @@ private:
wxString m_migration_source;
/// If true, the symbol and footprint library tables will be migrated from the previous version
bool m_migrateLibraryTables;
/// True if settings loaded successfully at construction
bool m_ok;