Save a cancel value when asked if it's not being used to cancel.

Many, many KIDIALOGs use OK/Cancel and then rename both buttons to
confirm or deny some action.  In those cases we *do* want to store
the deny actions if they check "Do Not Show Again".

Fixes https://gitlab.com/kicad/code/kicad/issues/6979
This commit is contained in:
Jeff Young 2021-01-08 21:20:29 +00:00
parent 51e6846ca5
commit d0af4e9f9d
3 changed files with 29 additions and 14 deletions

View File

@ -35,18 +35,20 @@
static std::unordered_map<unsigned long, int> doNotShowAgainDlgs;
KIDIALOG::KIDIALOG( wxWindow* aParent, const wxString& aMessage,
const wxString& aCaption, long aStyle )
KIDIALOG::KIDIALOG( wxWindow* aParent, const wxString& aMessage, const wxString& aCaption,
long aStyle )
: wxRichMessageDialog( aParent, aMessage, aCaption, aStyle | wxCENTRE | wxSTAY_ON_TOP ),
m_hash( 0 )
m_hash( 0 ),
m_cancelMeansCancel( true )
{
}
KIDIALOG::KIDIALOG( wxWindow* aParent, const wxString& aMessage,
KD_TYPE aType, const wxString& aCaption )
KIDIALOG::KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType,
const wxString& aCaption )
: wxRichMessageDialog( aParent, aMessage, getCaption( aType, aCaption ), getStyle( aType ) ),
m_hash( 0 )
m_hash( 0 ),
m_cancelMeansCancel( true )
{
}
@ -85,8 +87,10 @@ bool KIDIALOG::Show( bool aShow )
int ret = wxRichMessageDialog::Show( aShow );
// Has the user asked not to show the dialog again and it was confirmed
if( IsCheckBoxChecked() && ret != wxID_CANCEL )
// Has the user asked not to show the dialog again?
// Note that we don't save a Cancel value unless the Cancel button is being used for some
// other function (which is actually more common than it being used for Cancel).
if( IsCheckBoxChecked() && (!m_cancelMeansCancel || ret != wxID_CANCEL ) )
doNotShowAgainDlgs[m_hash] = ret;
return ret;
@ -103,8 +107,10 @@ int KIDIALOG::ShowModal()
int ret = wxRichMessageDialog::ShowModal();
// Has the user asked not to show the dialog again
if( IsCheckBoxChecked() && ret != wxID_CANCEL )
// Has the user asked not to show the dialog again?
// Note that we don't save a Cancel value unless the Cancel button is being used for some
// other function (which is actually more common than it being used for Cancel).
if( IsCheckBoxChecked() && (!m_cancelMeansCancel || ret != wxID_CANCEL ) )
doNotShowAgainDlgs[m_hash] = ret;
return ret;

View File

@ -52,6 +52,12 @@ public:
KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType,
const wxString& aCaption = "" );
bool SetOKCancelLabels( const ButtonLabel& ok, const ButtonLabel& cancel ) override
{
m_cancelMeansCancel = false;
return wxRichMessageDialog::SetOKCancelLabels( ok, cancel );
}
///> Shows the 'do not show again' checkbox
void DoNotShowCheckbox( wxString file, int line );
@ -63,12 +69,15 @@ public:
int ShowModal() override;
protected:
///> Unique identifier of the dialog
unsigned long m_hash;
// Helper functions for wxRichMessageDialog constructor
static wxString getCaption( KD_TYPE aType, const wxString& aCaption );
static long getStyle( KD_TYPE aType );
protected:
unsigned long m_hash; // Unique id
bool m_cancelMeansCancel; // If the Cancel button is renamed then it should be
// saved by the DoNotShowAgain checkbox. If it's really
// a cancel then it should not.
};

View File

@ -60,7 +60,7 @@ void ZONE_FILLER_TOOL::CheckAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRep
std::vector<ZONE*> toFill;
for( auto zone : board()->Zones() )
for( ZONE* zone : board()->Zones() )
toFill.push_back(zone);
BOARD_COMMIT commit( this );