diff --git a/clientgui/DlgDiagnosticLogFlags.cpp b/clientgui/DlgDiagnosticLogFlags.cpp index e9e6a9710b..54e359422d 100644 --- a/clientgui/DlgDiagnosticLogFlags.cpp +++ b/clientgui/DlgDiagnosticLogFlags.cpp @@ -41,6 +41,8 @@ BEGIN_EVENT_TABLE(CDlgDiagnosticLogFlags, wxDialog) EVT_SIZE(CDlgDiagnosticLogFlags::OnSize) EVT_BUTTON(wxID_OK,CDlgDiagnosticLogFlags::OnOK) EVT_BUTTON(ID_DEFAULTSBTN,CDlgDiagnosticLogFlags::OnSetDefaults) + EVT_BUTTON(wxID_APPLY,CDlgDiagnosticLogFlags::OnApply) + EVT_CHECKBOX(wxID_ANY,CDlgDiagnosticLogFlags::OnCheckBox) END_EVENT_TABLE() @@ -128,6 +130,11 @@ CDlgDiagnosticLogFlags::CDlgDiagnosticLogFlags(wxWindow* parent) : btnCancel->SetToolTip( _("Close the dialog without saving") ); buttonSizer->Add( btnCancel, 0, wxALL, 5 ); + m_btnApply = new wxButton( this, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 ); + m_btnApply->SetToolTip( _("Save all values") ); + m_btnApply->Enable(false); + buttonSizer->Add( m_btnApply, 0, wxALL, 5 ); + btnCancel->SetDefault(); bSizer1->Add( buttonSizer, 0, wxALIGN_RIGHT | wxALL, 15 ); @@ -188,6 +195,35 @@ void CDlgDiagnosticLogFlags::CreateCheckboxes() { m_checkboxSizer->Fit( m_scrolledWindow ); } +void CDlgDiagnosticLogFlags::SaveFlags() { + SET_LOCALE sl; + char buf[64000]; + MIOFILE mf; + bool val; + unsigned int i; + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + + mf.init_buf_write(buf, sizeof(buf)); + for (i = 0; iGetValue(); + mf.printf(" <%s>%d\n", (const char*)ckbox->GetLabel().ToAscii(), (int)val, (const char*)ckbox->GetLabel().ToAscii()); + } + mf.printf(" \n"); + + XML_PARSER xp(&mf); + mf.init_buf_read(buf); + log_flags.parse(xp); + + int retval = pDoc->rpc.set_cc_config(m_cc_config, log_flags); + if (!retval) { + pDoc->rpc.read_cc_config(); + } +} + /* saves dialog size and (on Mac) position */ bool CDlgDiagnosticLogFlags::SaveState() { @@ -242,32 +278,8 @@ void CDlgDiagnosticLogFlags::OnSize(wxSizeEvent& event) { void CDlgDiagnosticLogFlags::OnOK(wxCommandEvent& event) { - SET_LOCALE sl; - char buf[64000]; - MIOFILE mf; - bool val; - unsigned int i; - CMainDocument* pDoc = wxGetApp().GetDocument(); + SaveFlags(); - wxASSERT(pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - - mf.init_buf_write(buf, sizeof(buf)); - for (i=0; iGetValue(); - mf.printf(" <%s>%d\n", (const char*)ckbox->GetLabel().ToAscii(), (int)val, (const char*)ckbox->GetLabel().ToAscii()); - } - mf.printf(" \n"); - - XML_PARSER xp(&mf); - mf.init_buf_read(buf); - log_flags.parse(xp); - - int retval = pDoc->rpc.set_cc_config(m_cc_config, log_flags); - if (!retval) { - pDoc->rpc.read_cc_config(); - } event.Skip(); } @@ -277,5 +289,19 @@ void CDlgDiagnosticLogFlags::OnSetDefaults(wxCommandEvent& ) { m_checkboxSizer->Clear(true); CreateCheckboxes(); + m_btnApply->Enable(); Layout(); } + +void CDlgDiagnosticLogFlags::OnApply(wxCommandEvent & event) { + SaveFlags(); + m_btnApply->Enable(false); + + event.Skip(); +} + +void CDlgDiagnosticLogFlags::OnCheckBox(wxCommandEvent & event) { + m_btnApply->Enable(); + + event.Skip(); +} diff --git a/clientgui/DlgDiagnosticLogFlags.h b/clientgui/DlgDiagnosticLogFlags.h index e664c90c3a..c55cdf056e 100644 --- a/clientgui/DlgDiagnosticLogFlags.h +++ b/clientgui/DlgDiagnosticLogFlags.h @@ -49,18 +49,22 @@ public: void OnSize(wxSizeEvent& event); void OnOK(wxCommandEvent& event); void OnSetDefaults(wxCommandEvent& event); + void OnApply(wxCommandEvent& event); + void OnCheckBox(wxCommandEvent& event); private: //generic layout methods bool SaveState(); bool RestoreState(); void CreateCheckboxes(); + void SaveFlags(); LOG_FLAGS log_flags; CC_CONFIG m_cc_config; wxGridSizer* m_headingSizer; std::vector m_checkbox_list; + wxButton* m_btnApply; protected: wxString m_headingText;