code_review: PR #710

* SourceGit.Commands.* should not reference SourceGit.ViewModels.*
* remove unused namespace using
* update translations for zh_CN and zh_TW
* use WrapPanel instead of inner ScrollViewer
* some other UI/UX changes

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-20 09:42:48 +08:00
parent dd0580d0f5
commit ab2156bfc2
No known key found for this signature in database
7 changed files with 107 additions and 110 deletions

View file

@ -1,25 +1,17 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using SourceGit.ViewModels;
namespace SourceGit.Commands namespace SourceGit.Commands
{ {
public class QueryCommitChildren : Command public class QueryCommitChildren : Command
{ {
public QueryCommitChildren(string repo, string commit, string filters) public QueryCommitChildren(string repo, string commit, int max, string filters)
{ {
WorkingDirectory = repo; WorkingDirectory = repo;
Context = repo; Context = repo;
_commit = commit; _commit = commit;
if (string.IsNullOrEmpty(filters)) if (string.IsNullOrEmpty(filters))
filters = "--all"; filters = "--branches --remotes --tags";
Args = $"rev-list -{Preference.Instance.MaxHistoryCommits} --parents {filters} ^{commit}"; Args = $"rev-list -{max} --parents {filters} ^{commit}";
}
protected override void OnReadline(string line)
{
if (line.Contains(_commit))
_lines.Add(line.Substring(0, 40));
} }
public IEnumerable<string> Result() public IEnumerable<string> Result()
@ -28,6 +20,12 @@ namespace SourceGit.Commands
return _lines; return _lines;
} }
protected override void OnReadline(string line)
{
if (line.Contains(_commit))
_lines.Add(line.Substring(0, 40));
}
private string _commit; private string _commit;
private List<string> _lines = new List<string>(); private List<string> _lines = new List<string>();
} }

View file

@ -128,6 +128,7 @@
<x:String x:Key="Text.CommitDetail.Info" xml:space="preserve">基本信息</x:String> <x:String x:Key="Text.CommitDetail.Info" xml:space="preserve">基本信息</x:String>
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">修改者</x:String> <x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">修改者</x:String>
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">变更列表</x:String> <x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">变更列表</x:String>
<x:String x:Key="Text.CommitDetail.Info.Children" xml:space="preserve">子提交</x:String>
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交者</x:String> <x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交者</x:String>
<x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">查看包含此提交的分支/标签</x:String> <x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">查看包含此提交的分支/标签</x:String>
<x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">本提交已被以下分支/标签包含</x:String> <x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">本提交已被以下分支/标签包含</x:String>

View file

@ -128,7 +128,8 @@
<x:String x:Key="Text.CommitDetail.Info" xml:space="preserve">基本資訊</x:String> <x:String x:Key="Text.CommitDetail.Info" xml:space="preserve">基本資訊</x:String>
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">作者</x:String> <x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">作者</x:String>
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">變更列表</x:String> <x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">變更列表</x:String>
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交者</x:String> <x:String x:Key="Text.CommitDetail.Info.Children" xml:space="preserve">後續提交</x:String>
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交</x:String>
<x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">檢視包含此提交的分支或標籤</x:String> <x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">檢視包含此提交的分支或標籤</x:String>
<x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">本提交包含於以下分支或標籤</x:String> <x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">本提交包含於以下分支或標籤</x:String>
<x:String x:Key="Text.CommitDetail.Info.GotoChangesPage" xml:space="preserve">僅顯示前 100 項變更。請前往 [變更對比] 頁面以瀏覽所有變更。</x:String> <x:String x:Key="Text.CommitDetail.Info.GotoChangesPage" xml:space="preserve">僅顯示前 100 項變更。請前往 [變更對比] 頁面以瀏覽所有變更。</x:String>

View file

@ -547,7 +547,9 @@ namespace SourceGit.ViewModels
{ {
Task.Run(() => Task.Run(() =>
{ {
var cmdChildren = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA, _repo.Settings.BuildHistoriesFilter()) { Cancel = _cancelToken }; var max = Preference.Instance.MaxHistoryCommits;
var filter = _repo.Settings.BuildHistoriesFilter();
var cmdChildren = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA, max, filter) { Cancel = _cancelToken };
var children = cmdChildren.Result(); var children = cmdChildren.Result();
if (!cmdChildren.Cancel.Requested) if (!cmdChildren.Cancel.Requested)
Dispatcher.UIThread.Post(() => Children.AddRange(children)); Dispatcher.UIThread.Post(() => Children.AddRange(children));

View file

@ -144,6 +144,12 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _showAuthorTimeInGraph, value); set => SetProperty(ref _showAuthorTimeInGraph, value);
} }
public bool ShowChildren
{
get => _showChildren;
set => SetProperty(ref _showChildren, value);
}
public string IgnoreUpdateTag public string IgnoreUpdateTag
{ {
get => _ignoreUpdateTag; get => _ignoreUpdateTag;
@ -294,12 +300,6 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _statisticsSampleColor, value); set => SetProperty(ref _statisticsSampleColor, value);
} }
public bool ShowChildren
{
get => _showChildren;
set => SetProperty(ref _showChildren, value);
}
public List<RepositoryNode> RepositoryNodes public List<RepositoryNode> RepositoryNodes
{ {
get; get;
@ -598,6 +598,7 @@ namespace SourceGit.ViewModels
private int _subjectGuideLength = 50; private int _subjectGuideLength = 50;
private bool _useFixedTabWidth = true; private bool _useFixedTabWidth = true;
private bool _showAuthorTimeInGraph = false; private bool _showAuthorTimeInGraph = false;
private bool _showChildren = false;
private bool _check4UpdatesOnStartup = true; private bool _check4UpdatesOnStartup = true;
private double _lastCheckUpdateTime = 0; private double _lastCheckUpdateTime = 0;
@ -623,7 +624,5 @@ namespace SourceGit.ViewModels
private string _externalMergeToolPath = string.Empty; private string _externalMergeToolPath = string.Empty;
private uint _statisticsSampleColor = 0xFF00FF00; private uint _statisticsSampleColor = 0xFF00FF00;
private bool _showChildren = false;
} }
} }

View file

@ -53,8 +53,8 @@
<!-- Base Information --> <!-- Base Information -->
<Grid RowDefinitions="24,Auto,Auto,Auto,Auto" ColumnDefinitions="96,*"> <Grid RowDefinitions="24,Auto,Auto,Auto,Auto" ColumnDefinitions="96,*">
<!-- SHA --> <!-- SHA -->
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.SHA}" /> <TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal"> <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Height="24">
<TextBlock Classes="primary" <TextBlock Classes="primary"
Text="{Binding SHA}" Text="{Binding SHA}"
Margin="12,0,4,0" Margin="12,0,4,0"
@ -101,9 +101,8 @@
</StackPanel> </StackPanel>
<!-- PARENTS --> <!-- PARENTS -->
<TextBlock Grid.Row="1" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/> <TextBlock Grid.Row="1" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/>
<ScrollViewer Grid.Row="1" Grid.Column="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" AllowAutoHide="True"> <ItemsControl Grid.Row="1" Grid.Column="1" Height="24" Margin="12,0,0,0" ItemsSource="{Binding Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
<ItemsControl Height="24" Margin="12,0,0,0" ItemsSource="{Binding Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/> <StackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
@ -143,15 +142,13 @@
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
</ScrollViewer>
<!-- CHILDREN --> <!-- CHILDREN -->
<TextBlock Grid.Row="2" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Children}" IsVisible="{Binding #ThisControl.Children.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/> <TextBlock Grid.Row="2" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Children}" IsVisible="{Binding #ThisControl.Children.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/>
<ScrollViewer Grid.Row="2" Grid.Column="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" AllowAutoHide="True"> <ItemsControl Grid.Row="2" Grid.Column="1" Margin="12,0,0,0" ItemsSource="{Binding #ThisControl.Children}" IsVisible="{Binding #ThisControl.Children.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
<ItemsControl Height="24" Margin="12,0,0,0" ItemsSource="{Binding #ThisControl.Children}" IsVisible="{Binding #ThisControl.Children.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/> <WrapPanel Orientation="Horizontal" VerticalAlignment="Center" ItemHeight="24"/>
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
@ -188,10 +185,9 @@
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
</ScrollViewer>
<!-- REFS --> <!-- REFS -->
<TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Refs}" IsVisible="{Binding HasDecorators}"/> <TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Refs}" IsVisible="{Binding HasDecorators}"/>
<Border Grid.Row="3" Grid.Column="1" Margin="12,0,0,0" Height="24" IsVisible="{Binding HasDecorators}"> <Border Grid.Row="3" Grid.Column="1" Margin="12,0,0,0" Height="24" IsVisible="{Binding HasDecorators}">
<v:CommitRefsPresenter TagBackground="{DynamicResource Brush.DecoratorTag}" <v:CommitRefsPresenter TagBackground="{DynamicResource Brush.DecoratorTag}"
Foreground="{DynamicResource Brush.FG1}" Foreground="{DynamicResource Brush.FG1}"
@ -202,7 +198,7 @@
</Border> </Border>
<!-- Messages --> <!-- Messages -->
<TextBlock Grid.Row="4" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Message}" VerticalAlignment="Top" Margin="0,4,0,0" /> <TextBlock Grid.Row="4" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Message}" />
<v:CommitMessagePresenter Grid.Row="5" Grid.Column="1" <v:CommitMessagePresenter Grid.Row="5" Grid.Column="1"
Margin="12,5,8,0" Margin="12,5,8,0"
Classes="primary" Classes="primary"

View file

@ -112,13 +112,13 @@
<CheckBox Grid.Row="5" Grid.Column="1" <CheckBox Grid.Row="5" Grid.Column="1"
Height="32" Height="32"
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}" Content="{DynamicResource Text.Preference.General.ShowChildren}"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/> IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowChildren, Mode=TwoWay}"/>
<CheckBox Grid.Row="6" Grid.Column="1" <CheckBox Grid.Row="6" Grid.Column="1"
Height="32" Height="32"
Content="{DynamicResource Text.Preference.General.ShowChildren}" Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowChildren, Mode=TwoWay}"/> IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
</Grid> </Grid>
</TabItem> </TabItem>