mirror of https://github.com/BOINC/boinc.git
Manager: add 'Apply' button to Event Log options dialog
Activates 'Apply' button when the checkboxes change their state or 'Defaults' button is pressed. As requested in issue #1689.
This commit is contained in:
parent
eed66cc916
commit
d453c07018
|
@ -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; i<m_checkbox_list.size(); ++i) {
|
||||
wxCheckBox* ckbox = m_checkbox_list[i];
|
||||
val = ckbox->GetValue();
|
||||
mf.printf(" <%s>%d</%s>\n", (const char*)ckbox->GetLabel().ToAscii(), (int)val, (const char*)ckbox->GetLabel().ToAscii());
|
||||
}
|
||||
mf.printf(" </log_flags>\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; i<m_checkbox_list.size(); ++i) {
|
||||
wxCheckBox* ckbox = m_checkbox_list[i];
|
||||
val = ckbox->GetValue();
|
||||
mf.printf(" <%s>%d</%s>\n", (const char*)ckbox->GetLabel().ToAscii(), (int)val, (const char*)ckbox->GetLabel().ToAscii());
|
||||
}
|
||||
mf.printf(" </log_flags>\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();
|
||||
}
|
||||
|
|
|
@ -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 <wxCheckBox*> m_checkbox_list;
|
||||
wxButton* m_btnApply;
|
||||
|
||||
protected:
|
||||
wxString m_headingText;
|
||||
|
|
Loading…
Reference in New Issue