Browse Source

Restore the per-group bulk-toggle checkbox in decompiler settings

DecompilerSettingsGroupViewModel carries the full tri-state AreAllItemsChecked plumbing to bulk-toggle every setting in a category (the C# language-version groups), but the panel's Expander header had been reduced to plain category text, so each group rendered without its checkbox. Restore the header CheckBox bound to AreAllItemsChecked, matching the original.
pull/3755/head
Siegfried Pammer 1 month ago
parent
commit
ab2d3699b8
  1. 42
      ILSpy.Tests/Options/OptionsPageScrollReachTests.cs
  2. 11
      ILSpy/Options/DecompilerSettingsPanel.axaml

42
ILSpy.Tests/Options/OptionsPageScrollReachTests.cs

@ -107,4 +107,46 @@ public class OptionsPageScrollReachTests
+ "obscures it. Indicates either ScrollViewer.Extent under-measures the StackPanel " + "obscures it. Indicates either ScrollViewer.Extent under-measures the StackPanel "
+ "content or the ContentPresenter under-allocates the TabControl's vertical room."); + "content or the ContentPresenter under-allocates the TabControl's vertical room.");
} }
[AvaloniaTest]
public void Each_Decompiler_Settings_Group_Has_A_Header_Checkbox()
{
// Every Decompiler-settings category (the C# language-version groups) carries a tri-state
// header checkbox bound to AreAllItemsChecked that bulk-toggles the group. The group
// viewmodel has the whole plumbing, but the panel's Expander header had been reduced to
// plain category text, so each group rendered WITHOUT its checkbox. Realize the panel and
// assert each group's header checkbox is present (its Content is the Category string,
// distinct from the per-item checkboxes whose Content is a setting Description).
var window = AppComposition.Current.GetExport<MainWindow>();
window.Width = 900;
window.Height = 600;
window.Show();
Dispatcher.UIThread.RunJobs();
var command = AppComposition.Current.GetExport<MainMenuCommandRegistry>()
.GetCommand(nameof(Resources._Options));
command.Execute(null);
Dispatcher.UIThread.RunJobs();
var view = window.GetVisualDescendants().OfType<OptionsPageView>().Single();
var model = (OptionsPageModel)((ContentTabPage)((MainWindowViewModel)window.DataContext!)
.DockWorkspace.Documents!.VisibleDockables!
.OfType<ContentTabPage>().Single(t => t.Content is OptionsPageModel)).Content!;
var decompilerPage = model.Pages.OfType<DecompilerSettingsViewModel>().Single();
model.SelectedPage = decompilerPage;
Dispatcher.UIThread.RunJobs();
var renderedCheckboxContents = view.GetVisualDescendants().OfType<CheckBox>()
.Select(cb => cb.Content?.ToString())
.Where(s => !string.IsNullOrEmpty(s))
.ToHashSet();
decompilerPage.Settings.Should().NotBeEmpty("baseline: the Decompiler panel must have groups");
foreach (var group in decompilerPage.Settings)
{
renderedCheckboxContents.Should().Contain(group.Category,
$"the '{group.Category}' group must render a header checkbox (the bulk-toggle), "
+ "not just the category text");
}
}
} }

11
ILSpy/Options/DecompilerSettingsPanel.axaml

@ -16,7 +16,16 @@
<ItemsControl ItemsSource="{Binding Settings}"> <ItemsControl ItemsSource="{Binding Settings}">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate x:DataType="vm:DecompilerSettingsGroupViewModel"> <DataTemplate x:DataType="vm:DecompilerSettingsGroupViewModel">
<Expander Header="{Binding Category}" IsExpanded="True" Margin="0,2"> <Expander IsExpanded="True" Margin="0,2">
<!-- The header is a tri-state checkbox (all/none/some) that bulk-toggles
every item in the group, not just a label. AreAllItemsChecked drives
it; OnAreAllItemsCheckedChanged cascades to the items. -->
<Expander.Header>
<CheckBox FontWeight="Bold"
VerticalContentAlignment="Center"
Content="{Binding Category}"
IsChecked="{Binding AreAllItemsChecked, Mode=TwoWay}" />
</Expander.Header>
<ItemsControl ItemsSource="{Binding Settings}" Margin="12,4,0,0"> <ItemsControl ItemsSource="{Binding Settings}" Margin="12,4,0,0">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate x:DataType="vm:DecompilerSettingsItemViewModel"> <DataTemplate x:DataType="vm:DecompilerSettingsItemViewModel">

Loading…
Cancel
Save