| 662 | } |
| 663 | |
| 664 | void UpdateFormatOptions() |
| 665 | { |
| 666 | int formatSelection = formatChoice->GetSelection(); |
| 667 | _currentlyDisplayedFormat = formatSelection; |
| 668 | |
| 669 | try |
| 670 | { |
| 671 | PrepareConfig(); |
| 672 | globalConfig().combined(); |
| 673 | } |
| 674 | catch (const InapplicableOptionException& e) |
| 675 | { |
| 676 | /* The current set of options is invalid for some reason. Just |
| 677 | * swallow the errors. */ |
| 678 | } |
| 679 | catch (const ErrorException& e) |
| 680 | { |
| 681 | /* This really isn't supposed to happen, but sometimes does and |
| 682 | * it crashes the whole program. */ |
| 683 | return; |
| 684 | } |
| 685 | |
| 686 | assert(!wxGetApp().IsWorkerThreadRunning()); |
| 687 | |
| 688 | formatOptionsContainer->DestroyChildren(); |
| 689 | auto* sizer = new wxBoxSizer(wxVERTICAL); |
| 690 | |
| 691 | if (formatSelection == wxNOT_FOUND) |
| 692 | sizer->Add(new wxStaticText( |
| 693 | formatOptionsContainer, wxID_ANY, "(no format selected)")); |
| 694 | else |
| 695 | { |
| 696 | std::string formatName = _formatNames[formatChoice->GetSelection()]; |
| 697 | |
| 698 | for (auto& group : globalConfig()->option_group()) |
| 699 | { |
| 700 | std::string groupName = group.comment(); |
| 701 | if (groupName == "$formats") |
| 702 | groupName = "Formats"; |
| 703 | sizer->Add(new wxStaticText( |
| 704 | formatOptionsContainer, wxID_ANY, groupName + ":")); |
| 705 | |
| 706 | bool first = true; |
| 707 | bool valueSet = false; |
| 708 | wxRadioButton* defaultButton = nullptr; |
| 709 | for (auto& option : group.option()) |
| 710 | { |
| 711 | auto* rb = new wxRadioButton(formatOptionsContainer, |
| 712 | wxID_ANY, |
| 713 | option.comment(), |
| 714 | wxDefaultPosition, |
| 715 | wxDefaultSize, |
| 716 | first ? wxRB_GROUP : 0); |
| 717 | auto key = std::make_pair(formatName, option.name()); |
| 718 | sizer->Add(rb); |
| 719 | |
| 720 | rb->Bind(wxEVT_RADIOBUTTON, |
| 721 | [=](wxCommandEvent& e) |
nothing calls this directly
no test coverage detected