Enable/Disable the apply/discard buttons

When there are no pending actions, we should not show the user the
ability to apply/discard the pending actions.  This uses wxUpdateUI in
the correct manner, limiting it to only the elements being updated and
using the event actions to ensure we don't have a cascade

Fixes https://gitlab.com/kicad/code/kicad/issues/10761
This commit is contained in:
Seth Hillbrand 2022-05-11 13:47:50 -07:00
parent d9ec998ff0
commit 09a2d50e09
2 changed files with 12 additions and 1 deletions

View File

@ -132,12 +132,14 @@ DIALOG_PCM::DIALOG_PCM( wxWindow* parent ) : DIALOG_PCM_BASE( parent )
m_sdbSizer1OK->SetLabel( _( "Close" ) );
m_sdbSizer1Cancel->SetLabel( _( "Discard Changes" ) );
m_sdbSizer1Apply->SetLabel( _( "Apply Changes" ) );
m_sdbSizer1->Layout();
SetDefaultItem( m_sdbSizer1OK );
Bind( wxEVT_CLOSE_WINDOW, &DIALOG_PCM::OnCloseWindow, this );
m_sdbSizer1Cancel->Bind( wxEVT_UPDATE_UI, &DIALOG_PCM::OnUpdateEventButtons, this );
m_sdbSizer1Apply->Bind( wxEVT_UPDATE_UI, &DIALOG_PCM::OnUpdateEventButtons, this );
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
KICAD_SETTINGS* app_settings = mgr.GetAppSettings<KICAD_SETTINGS>();
@ -166,6 +168,12 @@ DIALOG_PCM::~DIALOG_PCM()
}
void DIALOG_PCM::OnUpdateEventButtons( wxUpdateUIEvent& event )
{
event.Enable( !m_pendingActions.empty() );
}
void DIALOG_PCM::OnCloseClicked( wxCommandEvent& event )
{
if( m_pendingActions.size() == 0

View File

@ -67,6 +67,9 @@ public:
///< Discards selected pending actions
void OnDiscardActionClicked( wxCommandEvent& event ) override;
///< Handles modification of the buttons' status
void OnUpdateEventButtons( wxUpdateUIEvent& event );
private:
/**
* @brief Gets package data from PCM and displays it on repository tab