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:
parent
d9ec998ff0
commit
09a2d50e09
|
@ -132,12 +132,14 @@ DIALOG_PCM::DIALOG_PCM( wxWindow* parent ) : DIALOG_PCM_BASE( parent )
|
||||||
m_sdbSizer1OK->SetLabel( _( "Close" ) );
|
m_sdbSizer1OK->SetLabel( _( "Close" ) );
|
||||||
m_sdbSizer1Cancel->SetLabel( _( "Discard Changes" ) );
|
m_sdbSizer1Cancel->SetLabel( _( "Discard Changes" ) );
|
||||||
m_sdbSizer1Apply->SetLabel( _( "Apply Changes" ) );
|
m_sdbSizer1Apply->SetLabel( _( "Apply Changes" ) );
|
||||||
|
|
||||||
m_sdbSizer1->Layout();
|
m_sdbSizer1->Layout();
|
||||||
|
|
||||||
SetDefaultItem( m_sdbSizer1OK );
|
SetDefaultItem( m_sdbSizer1OK );
|
||||||
|
|
||||||
Bind( wxEVT_CLOSE_WINDOW, &DIALOG_PCM::OnCloseWindow, this );
|
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();
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||||
KICAD_SETTINGS* app_settings = mgr.GetAppSettings<KICAD_SETTINGS>();
|
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 )
|
void DIALOG_PCM::OnCloseClicked( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
if( m_pendingActions.size() == 0
|
if( m_pendingActions.size() == 0
|
||||||
|
|
|
@ -67,6 +67,9 @@ public:
|
||||||
///< Discards selected pending actions
|
///< Discards selected pending actions
|
||||||
void OnDiscardActionClicked( wxCommandEvent& event ) override;
|
void OnDiscardActionClicked( wxCommandEvent& event ) override;
|
||||||
|
|
||||||
|
///< Handles modification of the buttons' status
|
||||||
|
void OnUpdateEventButtons( wxUpdateUIEvent& event );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Gets package data from PCM and displays it on repository tab
|
* @brief Gets package data from PCM and displays it on repository tab
|
||||||
|
|
Loading…
Reference in New Issue