| 702 | } |
| 703 | |
| 704 | Preferences::Preferences(wxWindow *parent): wxDialog(parent, -1, _("Preferences"), wxDefaultPosition, wxSize(-1, -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { |
| 705 | SetIcon(GETICON(options_button_16)); |
| 706 | |
| 707 | book = new wxTreebook(this, -1, wxDefaultPosition, wxDefaultSize); |
| 708 | General(book, this); |
| 709 | General_DefaultStyles(book, this); |
| 710 | Audio(book, this); |
| 711 | Video(book, this); |
| 712 | Interface(book, this); |
| 713 | Interface_Colours(book, this); |
| 714 | new Interface_Hotkeys(book, this); |
| 715 | Backup(book, this); |
| 716 | Automation(book, this); |
| 717 | Advanced(book, this); |
| 718 | Advanced_Audio(book, this); |
| 719 | Advanced_Video(book, this); |
| 720 | |
| 721 | book->Fit(); |
| 722 | |
| 723 | book->ChangeSelection(OPT_GET("Tool/Preferences/Page")->GetInt()); |
| 724 | book->Bind(wxEVT_TREEBOOK_PAGE_CHANGED, [](wxBookCtrlEvent &evt) { |
| 725 | OPT_SET("Tool/Preferences/Page")->SetInt(evt.GetSelection()); |
| 726 | }); |
| 727 | |
| 728 | // Bottom Buttons |
| 729 | auto stdButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxAPPLY | wxHELP); |
| 730 | applyButton = stdButtonSizer->GetApplyButton(); |
| 731 | wxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL); |
| 732 | auto defaultButton = new wxButton(this, -1, _("&Restore Defaults")); |
| 733 | buttonSizer->Add(defaultButton, wxSizerFlags(0).Expand()); |
| 734 | buttonSizer->AddStretchSpacer(1); |
| 735 | buttonSizer->Add(stdButtonSizer, wxSizerFlags(0).Expand()); |
| 736 | |
| 737 | // Main Sizer |
| 738 | wxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); |
| 739 | mainSizer->Add(book, wxSizerFlags(1).Expand().Border()); |
| 740 | mainSizer->Add(buttonSizer, wxSizerFlags(0).Expand().Border(wxALL & ~wxTOP)); |
| 741 | |
| 742 | SetSizerAndFit(mainSizer); |
| 743 | CenterOnParent(); |
| 744 | |
| 745 | applyButton->Enable(false); |
| 746 | |
| 747 | Bind(wxEVT_BUTTON, &Preferences::OnOK, this, wxID_OK); |
| 748 | Bind(wxEVT_BUTTON, &Preferences::OnApply, this, wxID_APPLY); |
| 749 | Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Options"), wxID_HELP); |
| 750 | defaultButton->Bind(wxEVT_BUTTON, &Preferences::OnResetDefault, this); |
| 751 | } |
| 752 | |
| 753 | void ShowPreferences(wxWindow *parent) { |
| 754 | while (Preferences(parent).ShowModal() < 0); |
nothing calls this directly
no test coverage detected