Ask user before throwing away changes to DRC Rules.
Fixes https://gitlab.com/kicad/code/kicad/issues/5135
This commit is contained in:
parent
de6314e3b5
commit
e1c449902d
|
@ -1187,7 +1187,7 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnClose( wxCloseEvent& event )
|
||||||
|
|
||||||
if( m_dataModel->IsEdited() )
|
if( m_dataModel->IsEdited() )
|
||||||
{
|
{
|
||||||
if( !HandleUnsavedChanges( this, wxEmptyString,
|
if( !HandleUnsavedChanges( this, _( "Save changes?" ),
|
||||||
[&]()->bool { return TransferDataFromWindow(); } ) )
|
[&]()->bool { return TransferDataFromWindow(); } ) )
|
||||||
{
|
{
|
||||||
event.Veto();
|
event.Veto();
|
||||||
|
|
|
@ -727,22 +727,37 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnClose( wxCloseEvent& event )
|
||||||
// This is a cancel, so commit quietly as we're going to throw the results away anyway.
|
// This is a cancel, so commit quietly as we're going to throw the results away anyway.
|
||||||
m_grid->CommitPendingChanges( true );
|
m_grid->CommitPendingChanges( true );
|
||||||
|
|
||||||
|
int retval = wxCANCEL;
|
||||||
|
|
||||||
if( m_dataModel->IsEdited() )
|
if( m_dataModel->IsEdited() )
|
||||||
{
|
{
|
||||||
if( !HandleUnsavedChanges( this, wxEmptyString,
|
if( HandleUnsavedChanges( this, _( "Save changes?" ),
|
||||||
[&]()->bool { return TransferDataFromWindow(); } ) )
|
[&]()->bool
|
||||||
|
{
|
||||||
|
if( TransferDataFromWindow() )
|
||||||
|
{
|
||||||
|
retval = wxOK;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} ) )
|
||||||
|
{
|
||||||
|
if( IsQuasiModal() )
|
||||||
|
EndQuasiModal( retval );
|
||||||
|
else
|
||||||
|
EndModal( retval );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
event.Veto();
|
event.Veto();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( IsQuasiModal() )
|
event.Skip();
|
||||||
EndQuasiModal( wxID_CANCEL );
|
|
||||||
else if( IsModal() )
|
|
||||||
EndModal( wxID_CANCEL );
|
|
||||||
else
|
|
||||||
event.Skip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ class PAGED_DIALOG : public DIALOG_SHIM
|
||||||
private:
|
private:
|
||||||
wxString m_title;
|
wxString m_title;
|
||||||
|
|
||||||
|
bool m_dirty;
|
||||||
|
|
||||||
wxString m_errorMessage;
|
wxString m_errorMessage;
|
||||||
wxWindow* m_errorCtrl; // the control associated with m_errorMessage
|
wxWindow* m_errorCtrl; // the control associated with m_errorMessage
|
||||||
int m_errorRow; // the row if m_errorCtrl is a grid
|
int m_errorRow; // the row if m_errorCtrl is a grid
|
||||||
|
@ -62,6 +64,8 @@ public:
|
||||||
|
|
||||||
void SetInitialPage( const wxString& aPage, const wxString& aParentPage = wxEmptyString );
|
void SetInitialPage( const wxString& aPage, const wxString& aParentPage = wxEmptyString );
|
||||||
|
|
||||||
|
void SetModified() { m_modified = true; }
|
||||||
|
|
||||||
void SetError( const wxString& aMessage, const wxString& aPageName, int aCtrlId, int aRow = -1,
|
void SetError( const wxString& aMessage, const wxString& aPageName, int aCtrlId, int aRow = -1,
|
||||||
int aCol = -1 );
|
int aCol = -1 );
|
||||||
|
|
||||||
|
@ -74,15 +78,17 @@ protected:
|
||||||
bool TransferDataToWindow() override;
|
bool TransferDataToWindow() override;
|
||||||
bool TransferDataFromWindow() override;
|
bool TransferDataFromWindow() override;
|
||||||
|
|
||||||
|
void OnClose( wxCloseEvent& event );
|
||||||
|
void OnCancel( wxCommandEvent& event );
|
||||||
virtual void OnAuxiliaryAction( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnAuxiliaryAction( wxCommandEvent& event ) { event.Skip(); }
|
||||||
void OnResetButton( wxCommandEvent& aEvent );
|
void OnResetButton( wxCommandEvent& aEvent );
|
||||||
void OnUpdateUI( wxUpdateUIEvent& event );
|
void OnUpdateUI( wxUpdateUIEvent& event );
|
||||||
void OnPageChange( wxBookCtrlEvent& event );
|
void OnPageChange( wxBookCtrlEvent& event );
|
||||||
void OnPageChanging( wxBookCtrlEvent& aEvent );
|
|
||||||
|
|
||||||
PAGED_TREEBOOK* m_treebook;
|
PAGED_TREEBOOK* m_treebook;
|
||||||
wxButton* m_auxiliaryButton;
|
wxButton* m_auxiliaryButton;
|
||||||
wxButton* m_resetButton;
|
wxButton* m_resetButton;
|
||||||
|
wxButton* m_cancelButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ void PANEL_SETUP_RULES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
||||||
{
|
{
|
||||||
constexpr int flags = wxSTC_FIND_REGEXP| wxSTC_FIND_POSIX;
|
constexpr int flags = wxSTC_FIND_REGEXP| wxSTC_FIND_POSIX;
|
||||||
|
|
||||||
|
m_Parent->SetModified();
|
||||||
m_textEditor->SearchAnchor();
|
m_textEditor->SearchAnchor();
|
||||||
|
|
||||||
int i = std::max( 0, m_textEditor->SearchPrev( flags, "\( *rule " ) );
|
int i = std::max( 0, m_textEditor->SearchPrev( flags, "\( *rule " ) );
|
||||||
|
|
Loading…
Reference in New Issue