enhance: remeber tag group and submodule group IsExpanded state.

This commit is contained in:
leo 2024-03-21 11:40:17 +08:00
parent c83d4588a1
commit 0e49ad181a
2 changed files with 24 additions and 4 deletions

View file

@ -210,6 +210,20 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _searchedCommits, value);
}
[JsonIgnore]
public bool IsTagGroupExpanded
{
get => _isTagGroupExpanded;
set => SetProperty(ref _isTagGroupExpanded, value);
}
[JsonIgnore]
public bool IsSubmoduleGroupExpanded
{
get => _isSubmoduleGroupExpanded;
set => SetProperty(ref _isSubmoduleGroupExpanded, value);
}
public void Open()
{
_watcher = new Models.Watcher(this);
@ -250,6 +264,9 @@ namespace SourceGit.ViewModels
_isSearching = false;
_searchCommitFilter = string.Empty;
_isTagGroupExpanded = false;
_isSubmoduleGroupExpanded = false;
_remotes.Clear();
_branches.Clear();
_localBranchTrees.Clear();
@ -1265,6 +1282,9 @@ namespace SourceGit.ViewModels
private string _searchCommitFilter = string.Empty;
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
private bool _isTagGroupExpanded = false;
private bool _isSubmoduleGroupExpanded = false;
private List<Models.Remote> _remotes = new List<Models.Remote>();
private List<Models.Branch> _branches = new List<Models.Branch>();
private List<Models.BranchTreeNode> _localBranchTrees = new List<Models.BranchTreeNode>();

View file

@ -241,7 +241,7 @@
</TreeView>
<!-- Tags -->
<ToggleButton Grid.Row="6" x:Name="toggleTags" Classes="group_expander">
<ToggleButton Grid.Row="6" Classes="group_expander" IsChecked="{Binding IsTagGroupExpanded, Mode=TwoWay}">
<Grid ColumnDefinitions="Auto,*,Auto">
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="4,0,0,0" Text="{DynamicResource Text.Repository.Tags}"/>
<TextBlock Grid.Column="1" Text="{Binding Tags, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
@ -265,7 +265,7 @@
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
LostFocus="OnTagDataGridLostFocus"
IsVisible="{Binding #toggleTags.IsChecked}"
IsVisible="{Binding IsTagGroupExpanded, Mode=OneWay}"
SelectionChanged="OnTagDataGridSelectionChanged"
ContextRequested="OnTagContextRequested">
<DataGrid.Columns>
@ -301,7 +301,7 @@
</DataGrid>
<!-- Submodules -->
<ToggleButton Grid.Row="8" x:Name="toggleSubmodules" Classes="group_expander">
<ToggleButton Grid.Row="8" Classes="group_expander" IsChecked="{Binding IsSubmoduleGroupExpanded, Mode=TwoWay}">
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="4,0,0,0" Text="{DynamicResource Text.Repository.Submodules}"/>
<TextBlock Grid.Column="1" Text="{Binding Submodules, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
@ -334,7 +334,7 @@
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
ContextRequested="OnSubmoduleContextRequested"
IsVisible="{Binding #toggleSubmodules.IsChecked}">
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}">
<DataGrid.Columns>
<DataGridTemplateColumn Header="ICON">
<DataGridTemplateColumn.CellTemplate>