Add cancel button and rename OK to apply

This commit is contained in:
Epicalert 2021-07-02 03:10:37 +08:00
parent d18f9d3162
commit dbd3afb6fe
No known key found for this signature in database
GPG key ID: CAA46F858D0979BD

View file

@ -22,6 +22,7 @@ class ConfigurationFrame : public wxFrame {
std::vector<std::string> modelVec;
wxCheckBox* useHaarCheckBox;
wxChoice* modelNameChoice;
void OnApply(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
};
@ -55,21 +56,27 @@ ConfigurationFrame::ConfigurationFrame() : wxFrame(NULL, wxID_ANY, "Configure "
modelNameChoice = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, modelVec.size(), modelArray);
// TODO: cancel button to exit without saving settings
wxButton* okButton = new wxButton(panel, wxID_OK, "OK");
wxButton* cancelButton = new wxButton(panel, wxID_CANCEL, "Cancel");
wxButton* applyButton = new wxButton(panel, wxID_APPLY, "Apply settings");
wxBoxSizer* bottomButtonSizer = new wxBoxSizer(wxHORIZONTAL);
bottomButtonSizer->Add(cancelButton, 0, wxALL, 5);
bottomButtonSizer->Add(applyButton, 0, wxALL, 5);
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(placeholderText, 0, wxALL | wxALIGN_LEFT, 10);
sizer->Add(useHaarCheckBox, 0, wxALL | wxALIGN_LEFT, 5);
sizer->Add(modelNameChoice, 0, wxALL | wxALIGN_LEFT, 5);
sizer->AddStretchSpacer(1);
sizer->Add(okButton, 0, wxALIGN_RIGHT | wxALL, 10);
sizer->Add(bottomButtonSizer, 0, wxALIGN_RIGHT | wxALL, 10);
panel->SetSizerAndFit(sizer);
Bind(wxEVT_BUTTON, &ConfigurationFrame::OnExit, this, wxID_OK);
Bind(wxEVT_BUTTON, &ConfigurationFrame::OnApply, this, wxID_APPLY);
Bind(wxEVT_BUTTON, &ConfigurationFrame::OnExit, this, wxID_CANCEL);
}
void ConfigurationFrame::OnExit(wxCommandEvent& event) {
void ConfigurationFrame::OnApply(wxCommandEvent& event) {
// write options to config file
std::ofstream configFile;
configFile.open(prefixCustom + "config.toml");
@ -83,3 +90,7 @@ void ConfigurationFrame::OnExit(wxCommandEvent& event) {
Close(true);
}
void ConfigurationFrame::OnExit(wxCommandEvent& event) {
Close(true);
}