Clean up extra control creator logic in pcbnew save file dialog

This commit is contained in:
Ian McInerney 2022-12-17 22:56:20 +00:00
parent 8324c0b0cc
commit 82a11c71af
2 changed files with 14 additions and 11 deletions

View File

@ -227,16 +227,13 @@ bool AskSaveBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, bool* a
wxFileDialog dlg( aParent, _( "Save Board File As" ), fn.GetPath(), fn.GetFullName(), wildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
// Add a "Create a project" checkbox in standalone mode and one isn't loaded
#if wxCHECK_VERSION( 3, 1, 7 )
FILEDLG_HOOK_SAVE_PROJECT newProjectHook;
bool checkHook = false;
#endif
#if wxCHECK_VERSION( 3, 1, 7 )
dlg.SetCustomizeHook( newProjectHook );
checkHook = true;
if( Kiface().IsSingle() && aParent->Prj().IsNullProject() )
dlg.SetCustomizeHook( newProjectHook );
#else
// Add a "Create a project" checkbox in standalone mode and one isn't loaded
if( Kiface().IsSingle() && aParent->Prj().IsNullProject() )
dlg.SetExtraControlCreator( &LEGACYFILEDLG_SAVE_PROJECT::Create );
#endif
@ -253,7 +250,7 @@ bool AskSaveBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, bool* a
*aFileName = fn.GetFullPath();
#if wxCHECK_VERSION( 3, 1, 7 )
if( checkHook )
if( newProjectHook.IsAttachedToDialog() )
*aCreateProject = newProjectHook.GetCreateNewProject();
else if( !aParent->Prj().IsNullProject() )
*aCreateProject = true;

View File

@ -31,6 +31,8 @@ public:
{
m_cb = customizer.AddCheckBox( _( "Create a new project for this board" ) );
m_cb->SetValue( true );
m_controlsAttached = true;
}
virtual void TransferDataFromCustomControls() override
@ -41,12 +43,16 @@ public:
///< Gets the selected state of the create new project option
bool GetCreateNewProject() const { return m_createNewProject; }
private:
bool m_createNewProject;
///< Gets if this hook has attached controls to a dialog box
bool IsAttachedToDialog() const { return m_controlsAttached; }
wxFileDialogCheckBox* m_cb;
private:
bool m_createNewProject = true;
bool m_controlsAttached = false;
wxFileDialogCheckBox* m_cb = nullptr;
wxDECLARE_NO_COPY_CLASS( FILEDLG_HOOK_SAVE_PROJECT );
};
#endif
#endif