diff --git a/pcsx2/gui/AppEventSources.cpp b/pcsx2/gui/AppEventSources.cpp index 6a5d835cfc..26412ab3eb 100644 --- a/pcsx2/gui/AppEventSources.cpp +++ b/pcsx2/gui/AppEventSources.cpp @@ -109,7 +109,6 @@ void IEventListener_AppStatus::DispatchEvent( const AppEventInfo& evtinfo ) AppStatusEvent_OnSettingsApplied(); break; - case AppStatus_Exiting: AppStatusEvent_OnExit(); break; diff --git a/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp b/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp index 8596e672a4..9fb55d6af6 100644 --- a/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp +++ b/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp @@ -42,6 +42,54 @@ using namespace Panels; static const int s_orient = wxBK_LEFT; #endif +class ScopedOkButtonDisabler +{ +protected: + Dialogs::BaseConfigurationDialog* m_parent; + + wxWindow* m_apply; + wxWindow* m_ok; + wxWindow* m_cancel; + +public: + ScopedOkButtonDisabler( Dialogs::BaseConfigurationDialog* parent ) + { + m_parent = parent; + m_parent->AllowApplyActivation( false ); + + m_apply = m_parent->FindWindow( wxID_APPLY ); + m_ok = m_parent->FindWindow( wxID_OK ); + m_cancel = m_parent->FindWindow( wxID_CANCEL ); + + if (m_apply) m_apply ->Disable(); + if (m_ok) m_ok ->Disable(); + if (m_cancel) m_cancel->Disable(); + } + + // Use this to prevent the Apply button from being re-enabled. + void DetachApply() + { + m_apply = NULL; + } + + void DetachAll() + { + m_apply = m_ok = m_cancel = NULL; + } + + virtual ~ScopedOkButtonDisabler() throw() + { + if (m_apply) m_apply ->Enable(); + if (m_ok) m_ok ->Enable(); + if (m_cancel) m_cancel->Enable(); + + m_parent->AllowApplyActivation( true ); + } +}; + +// -------------------------------------------------------------------------------------- +// BaseApplicableDialog (implementations) +// -------------------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(BaseApplicableDialog, wxDialogWithHelpers) BaseApplicableDialog::BaseApplicableDialog( wxWindow* parent, const wxString& title, const pxDialogCreationFlags& cflags ) @@ -86,7 +134,8 @@ Dialogs::BaseConfigurationDialog::BaseConfigurationDialog( wxWindow* parent, con : _parent( parent, title ) { SetMinWidth( idealWidth ); - m_listbook = NULL; + m_listbook = NULL; + m_allowApplyActivation = true; Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BaseConfigurationDialog::OnOk_Click ) ); Connect( wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BaseConfigurationDialog::OnCancel_Click ) ); @@ -170,7 +219,8 @@ void Dialogs::BaseConfigurationDialog::SomethingChanged() void Dialogs::BaseConfigurationDialog::OnSomethingChanged( wxCommandEvent& evt ) { evt.Skip(); - if( (evt.GetId() != wxID_OK) && (evt.GetId() != wxID_CANCEL) && (evt.GetId() != wxID_APPLY) ) + if (!m_allowApplyActivation) return; + if ((evt.GetId() != wxID_OK) && (evt.GetId() != wxID_CANCEL) && (evt.GetId() != wxID_APPLY)) SomethingChanged(); } @@ -181,44 +231,11 @@ void Dialogs::BaseConfigurationDialog::OnCloseWindow( wxCloseEvent& evt ) evt.Skip(); } -class ScopedOkButtonDisabler + +void Dialogs::BaseConfigurationDialog::AllowApplyActivation( bool allow ) { -protected: - wxWindow* m_apply; - wxWindow* m_ok; - wxWindow* m_cancel; - -public: - ScopedOkButtonDisabler( wxWindow* parent ) - { - m_apply = parent->FindWindow( wxID_APPLY ); - m_ok = parent->FindWindow( wxID_OK ); - m_cancel = parent->FindWindow( wxID_CANCEL ); - - if (m_apply) m_apply ->Disable(); - if (m_ok) m_ok ->Disable(); - if (m_cancel) m_cancel->Disable(); - } - - // Use this to prevent the Apply buton from being re-enabled. - //avih: Does this work?? As far as I know Apply is always enabled... - void DetachApply() - { - m_apply = NULL; - } - - void DetachAll() - { - m_apply = m_ok = m_cancel = NULL; - } - - virtual ~ScopedOkButtonDisabler() throw() - { - if (m_apply) m_apply ->Enable(); - if (m_ok) m_ok ->Enable(); - if (m_cancel) m_cancel->Enable(); - } -}; + m_allowApplyActivation = allow; +} void Dialogs::BaseConfigurationDialog::OnOk_Click( wxCommandEvent& evt ) { diff --git a/pcsx2/gui/Dialogs/ConfigurationDialog.h b/pcsx2/gui/Dialogs/ConfigurationDialog.h index dfd448030f..e4429dce86 100644 --- a/pcsx2/gui/Dialogs/ConfigurationDialog.h +++ b/pcsx2/gui/Dialogs/ConfigurationDialog.h @@ -44,6 +44,7 @@ namespace Dialogs protected: wxListbook* m_listbook; wxArrayString m_labels; + bool m_allowApplyActivation; public: virtual ~BaseConfigurationDialog() throw(); @@ -59,6 +60,8 @@ namespace Dialogs template< typename T > void AddPage( const wxChar* label, int iconid ); + void AllowApplyActivation( bool allow=true ); + protected: void OnSettingsApplied( wxCommandEvent& evt ); diff --git a/pcsx2/gui/Panels/BaseApplicableConfigPanel.cpp b/pcsx2/gui/Panels/BaseApplicableConfigPanel.cpp index 07ed2395f0..b4a917a4a1 100644 --- a/pcsx2/gui/Panels/BaseApplicableConfigPanel.cpp +++ b/pcsx2/gui/Panels/BaseApplicableConfigPanel.cpp @@ -199,12 +199,12 @@ void BaseApplicableConfigPanel::OnSettingsApplied( wxCommandEvent& evt ) void BaseApplicableConfigPanel::AppStatusEvent_OnSettingsApplied() {} BaseApplicableConfigPanel_SpecificConfig::BaseApplicableConfigPanel_SpecificConfig(wxWindow* parent, wxOrientation orient) -: BaseApplicableConfigPanel( parent, orient) + : BaseApplicableConfigPanel( parent, orient ) { } BaseApplicableConfigPanel_SpecificConfig::BaseApplicableConfigPanel_SpecificConfig(wxWindow* parent, wxOrientation orient, const wxString& staticLabel ) -: BaseApplicableConfigPanel( parent, orient, staticLabel) + : BaseApplicableConfigPanel( parent, orient, staticLabel ) { }