Clean up extra control creator logic in pcbnew save file dialog
This commit is contained in:
parent
8324c0b0cc
commit
82a11c71af
|
@ -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,
|
wxFileDialog dlg( aParent, _( "Save Board File As" ), fn.GetPath(), fn.GetFullName(), wildcard,
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
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 )
|
#if wxCHECK_VERSION( 3, 1, 7 )
|
||||||
FILEDLG_HOOK_SAVE_PROJECT newProjectHook;
|
FILEDLG_HOOK_SAVE_PROJECT newProjectHook;
|
||||||
bool checkHook = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxCHECK_VERSION( 3, 1, 7 )
|
if( Kiface().IsSingle() && aParent->Prj().IsNullProject() )
|
||||||
dlg.SetCustomizeHook( newProjectHook );
|
dlg.SetCustomizeHook( newProjectHook );
|
||||||
checkHook = true;
|
|
||||||
#else
|
#else
|
||||||
// Add a "Create a project" checkbox in standalone mode and one isn't loaded
|
|
||||||
if( Kiface().IsSingle() && aParent->Prj().IsNullProject() )
|
if( Kiface().IsSingle() && aParent->Prj().IsNullProject() )
|
||||||
dlg.SetExtraControlCreator( &LEGACYFILEDLG_SAVE_PROJECT::Create );
|
dlg.SetExtraControlCreator( &LEGACYFILEDLG_SAVE_PROJECT::Create );
|
||||||
#endif
|
#endif
|
||||||
|
@ -253,7 +250,7 @@ bool AskSaveBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, bool* a
|
||||||
*aFileName = fn.GetFullPath();
|
*aFileName = fn.GetFullPath();
|
||||||
|
|
||||||
#if wxCHECK_VERSION( 3, 1, 7 )
|
#if wxCHECK_VERSION( 3, 1, 7 )
|
||||||
if( checkHook )
|
if( newProjectHook.IsAttachedToDialog() )
|
||||||
*aCreateProject = newProjectHook.GetCreateNewProject();
|
*aCreateProject = newProjectHook.GetCreateNewProject();
|
||||||
else if( !aParent->Prj().IsNullProject() )
|
else if( !aParent->Prj().IsNullProject() )
|
||||||
*aCreateProject = true;
|
*aCreateProject = true;
|
||||||
|
|
|
@ -31,6 +31,8 @@ public:
|
||||||
{
|
{
|
||||||
m_cb = customizer.AddCheckBox( _( "Create a new project for this board" ) );
|
m_cb = customizer.AddCheckBox( _( "Create a new project for this board" ) );
|
||||||
m_cb->SetValue( true );
|
m_cb->SetValue( true );
|
||||||
|
|
||||||
|
m_controlsAttached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TransferDataFromCustomControls() override
|
virtual void TransferDataFromCustomControls() override
|
||||||
|
@ -41,10 +43,14 @@ public:
|
||||||
///< Gets the selected state of the create new project option
|
///< Gets the selected state of the create new project option
|
||||||
bool GetCreateNewProject() const { return m_createNewProject; }
|
bool GetCreateNewProject() const { return m_createNewProject; }
|
||||||
|
|
||||||
private:
|
///< Gets if this hook has attached controls to a dialog box
|
||||||
bool m_createNewProject;
|
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 );
|
wxDECLARE_NO_COPY_CLASS( FILEDLG_HOOK_SAVE_PROJECT );
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue