Skip to content

Commit ab2156b

Browse files
committed
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 <[email protected]>
1 parent dd0580d commit ab2156b

File tree

7 files changed

+113
-116
lines changed

7 files changed

+113
-116
lines changed

src/Commands/QueryCommitChildren.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using SourceGit.ViewModels;
1+
using System.Collections.Generic;
42

53
namespace SourceGit.Commands
64
{
75
public class QueryCommitChildren : Command
86
{
9-
public QueryCommitChildren(string repo, string commit, string filters)
7+
public QueryCommitChildren(string repo, string commit, int max, string filters)
108
{
119
WorkingDirectory = repo;
1210
Context = repo;
1311
_commit = commit;
1412
if (string.IsNullOrEmpty(filters))
15-
filters = "--all";
16-
Args = $"rev-list -{Preference.Instance.MaxHistoryCommits} --parents {filters} ^{commit}";
17-
}
18-
19-
protected override void OnReadline(string line)
20-
{
21-
if (line.Contains(_commit))
22-
_lines.Add(line.Substring(0, 40));
13+
filters = "--branches --remotes --tags";
14+
Args = $"rev-list -{max} --parents {filters} ^{commit}";
2315
}
2416

2517
public IEnumerable<string> Result()
@@ -28,6 +20,12 @@ public IEnumerable<string> Result()
2820
return _lines;
2921
}
3022

23+
protected override void OnReadline(string line)
24+
{
25+
if (line.Contains(_commit))
26+
_lines.Add(line.Substring(0, 40));
27+
}
28+
3129
private string _commit;
3230
private List<string> _lines = new List<string>();
3331
}

src/Resources/Locales/zh_CN.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
<x:String x:Key="Text.CommitDetail.Info" xml:space="preserve">基本信息</x:String>
129129
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">修改者</x:String>
130130
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">变更列表</x:String>
131+
<x:String x:Key="Text.CommitDetail.Info.Children" xml:space="preserve">子提交</x:String>
131132
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交者</x:String>
132133
<x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">查看包含此提交的分支/标签</x:String>
133134
<x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">本提交已被以下分支/标签包含</x:String>

src/Resources/Locales/zh_TW.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128
<x:String x:Key="Text.CommitDetail.Info" xml:space="preserve">基本資訊</x:String>
129129
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">作者</x:String>
130130
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">變更列表</x:String>
131-
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交者</x:String>
131+
<x:String x:Key="Text.CommitDetail.Info.Children" xml:space="preserve">後續提交</x:String>
132+
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交</x:String>
132133
<x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">檢視包含此提交的分支或標籤</x:String>
133134
<x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">本提交包含於以下分支或標籤</x:String>
134135
<x:String x:Key="Text.CommitDetail.Info.GotoChangesPage" xml:space="preserve">僅顯示前 100 項變更。請前往 [變更對比] 頁面以瀏覽所有變更。</x:String>

src/ViewModels/CommitDetail.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,9 @@ private void Refresh()
547547
{
548548
Task.Run(() =>
549549
{
550-
var cmdChildren = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA, _repo.Settings.BuildHistoriesFilter()) { Cancel = _cancelToken };
550+
var max = Preference.Instance.MaxHistoryCommits;
551+
var filter = _repo.Settings.BuildHistoriesFilter();
552+
var cmdChildren = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA, max, filter) { Cancel = _cancelToken };
551553
var children = cmdChildren.Result();
552554
if (!cmdChildren.Cancel.Requested)
553555
Dispatcher.UIThread.Post(() => Children.AddRange(children));

src/ViewModels/Preference.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ public bool ShowAuthorTimeInGraph
144144
set => SetProperty(ref _showAuthorTimeInGraph, value);
145145
}
146146

147+
public bool ShowChildren
148+
{
149+
get => _showChildren;
150+
set => SetProperty(ref _showChildren, value);
151+
}
152+
147153
public string IgnoreUpdateTag
148154
{
149155
get => _ignoreUpdateTag;
@@ -294,12 +300,6 @@ public uint StatisticsSampleColor
294300
set => SetProperty(ref _statisticsSampleColor, value);
295301
}
296302

297-
public bool ShowChildren
298-
{
299-
get => _showChildren;
300-
set => SetProperty(ref _showChildren, value);
301-
}
302-
303303
public List<RepositoryNode> RepositoryNodes
304304
{
305305
get;
@@ -598,6 +598,7 @@ private bool RemoveInvalidRepositoriesRecursive(List<RepositoryNode> collection)
598598
private int _subjectGuideLength = 50;
599599
private bool _useFixedTabWidth = true;
600600
private bool _showAuthorTimeInGraph = false;
601+
private bool _showChildren = false;
601602

602603
private bool _check4UpdatesOnStartup = true;
603604
private double _lastCheckUpdateTime = 0;
@@ -623,7 +624,5 @@ private bool RemoveInvalidRepositoriesRecursive(List<RepositoryNode> collection)
623624
private string _externalMergeToolPath = string.Empty;
624625

625626
private uint _statisticsSampleColor = 0xFF00FF00;
626-
627-
private bool _showChildren = false;
628627
}
629628
}

src/Views/CommitBaseInfo.axaml

Lines changed: 86 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
<!-- Base Information -->
5454
<Grid RowDefinitions="24,Auto,Auto,Auto,Auto" ColumnDefinitions="96,*">
5555
<!-- SHA -->
56-
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
57-
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
56+
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
57+
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Height="24">
5858
<TextBlock Classes="primary"
5959
Text="{Binding SHA}"
6060
Margin="12,0,4,0"
@@ -101,97 +101,93 @@
101101
</StackPanel>
102102

103103
<!-- PARENTS -->
104-
<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}}"/>
105-
<ScrollViewer Grid.Row="1" Grid.Column="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" AllowAutoHide="True">
106-
<ItemsControl Height="24" Margin="12,0,0,0" ItemsSource="{Binding Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
107-
<ItemsControl.ItemsPanel>
108-
<ItemsPanelTemplate>
109-
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
110-
</ItemsPanelTemplate>
111-
</ItemsControl.ItemsPanel>
112-
113-
<ItemsControl.ItemTemplate>
114-
<DataTemplate>
115-
<TextBlock Classes="primary"
116-
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
117-
Foreground="DarkOrange"
118-
TextDecorations="Underline"
119-
Cursor="Hand"
120-
Margin="0,0,16,0"
121-
PointerEntered="OnSHAPointerEntered"
122-
PointerPressed="OnSHAPressed">
123-
<TextBlock.Styles>
124-
<Style Selector="ToolTip">
125-
<Setter Property="MaxWidth" Value="600"/>
126-
</Style>
127-
</TextBlock.Styles>
128-
129-
<TextBlock.DataTemplates>
130-
<DataTemplate DataType="m:Commit">
131-
<StackPanel MinWidth="400" Orientation="Vertical">
132-
<Grid ColumnDefinitions="Auto,*,Auto">
133-
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
134-
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
135-
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding CommitterTimeStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
136-
</Grid>
137-
138-
<TextBlock Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" TextWrapping="Wrap"/>
139-
</StackPanel>
140-
</DataTemplate>
141-
</TextBlock.DataTemplates>
142-
</TextBlock>
143-
</DataTemplate>
144-
</ItemsControl.ItemTemplate>
145-
</ItemsControl>
146-
</ScrollViewer>
104+
<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}}"/>
105+
<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}}">
106+
<ItemsControl.ItemsPanel>
107+
<ItemsPanelTemplate>
108+
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
109+
</ItemsPanelTemplate>
110+
</ItemsControl.ItemsPanel>
111+
112+
<ItemsControl.ItemTemplate>
113+
<DataTemplate>
114+
<TextBlock Classes="primary"
115+
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
116+
Foreground="DarkOrange"
117+
TextDecorations="Underline"
118+
Cursor="Hand"
119+
Margin="0,0,16,0"
120+
PointerEntered="OnSHAPointerEntered"
121+
PointerPressed="OnSHAPressed">
122+
<TextBlock.Styles>
123+
<Style Selector="ToolTip">
124+
<Setter Property="MaxWidth" Value="600"/>
125+
</Style>
126+
</TextBlock.Styles>
127+
128+
<TextBlock.DataTemplates>
129+
<DataTemplate DataType="m:Commit">
130+
<StackPanel MinWidth="400" Orientation="Vertical">
131+
<Grid ColumnDefinitions="Auto,*,Auto">
132+
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
133+
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
134+
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding CommitterTimeStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
135+
</Grid>
136+
137+
<TextBlock Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" TextWrapping="Wrap"/>
138+
</StackPanel>
139+
</DataTemplate>
140+
</TextBlock.DataTemplates>
141+
</TextBlock>
142+
</DataTemplate>
143+
</ItemsControl.ItemTemplate>
144+
</ItemsControl>
147145

148146
<!-- CHILDREN -->
149-
<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}}"/>
150-
<ScrollViewer Grid.Row="2" Grid.Column="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" AllowAutoHide="True">
151-
<ItemsControl Height="24" Margin="12,0,0,0" ItemsSource="{Binding #ThisControl.Children}" IsVisible="{Binding #ThisControl.Children.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
152-
<ItemsControl.ItemsPanel>
153-
<ItemsPanelTemplate>
154-
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
155-
</ItemsPanelTemplate>
156-
</ItemsControl.ItemsPanel>
157-
158-
<ItemsControl.ItemTemplate>
159-
<DataTemplate>
160-
<TextBlock Classes="primary"
161-
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
162-
Foreground="DarkOrange"
163-
TextDecorations="Underline"
164-
Cursor="Hand"
165-
Margin="0,0,16,0"
166-
PointerEntered="OnSHAPointerEntered"
167-
PointerPressed="OnSHAPressed">
168-
<TextBlock.Styles>
169-
<Style Selector="ToolTip">
170-
<Setter Property="MaxWidth" Value="600"/>
171-
</Style>
172-
</TextBlock.Styles>
173-
174-
<TextBlock.DataTemplates>
175-
<DataTemplate DataType="m:Commit">
176-
<StackPanel MinWidth="400" Orientation="Vertical">
177-
<Grid ColumnDefinitions="Auto,*,Auto">
178-
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
179-
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
180-
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding CommitterTimeStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
181-
</Grid>
182-
183-
<TextBlock Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" TextWrapping="Wrap"/>
184-
</StackPanel>
185-
</DataTemplate>
186-
</TextBlock.DataTemplates>
187-
</TextBlock>
188-
</DataTemplate>
189-
</ItemsControl.ItemTemplate>
190-
</ItemsControl>
191-
</ScrollViewer>
147+
<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}}"/>
148+
<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}}">
149+
<ItemsControl.ItemsPanel>
150+
<ItemsPanelTemplate>
151+
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center" ItemHeight="24"/>
152+
</ItemsPanelTemplate>
153+
</ItemsControl.ItemsPanel>
154+
155+
<ItemsControl.ItemTemplate>
156+
<DataTemplate>
157+
<TextBlock Classes="primary"
158+
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
159+
Foreground="DarkOrange"
160+
TextDecorations="Underline"
161+
Cursor="Hand"
162+
Margin="0,0,16,0"
163+
PointerEntered="OnSHAPointerEntered"
164+
PointerPressed="OnSHAPressed">
165+
<TextBlock.Styles>
166+
<Style Selector="ToolTip">
167+
<Setter Property="MaxWidth" Value="600"/>
168+
</Style>
169+
</TextBlock.Styles>
170+
171+
<TextBlock.DataTemplates>
172+
<DataTemplate DataType="m:Commit">
173+
<StackPanel MinWidth="400" Orientation="Vertical">
174+
<Grid ColumnDefinitions="Auto,*,Auto">
175+
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
176+
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
177+
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding CommitterTimeStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
178+
</Grid>
179+
180+
<TextBlock Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" TextWrapping="Wrap"/>
181+
</StackPanel>
182+
</DataTemplate>
183+
</TextBlock.DataTemplates>
184+
</TextBlock>
185+
</DataTemplate>
186+
</ItemsControl.ItemTemplate>
187+
</ItemsControl>
192188

193189
<!-- REFS -->
194-
<TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Refs}" IsVisible="{Binding HasDecorators}"/>
190+
<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}"/>
195191
<Border Grid.Row="3" Grid.Column="1" Margin="12,0,0,0" Height="24" IsVisible="{Binding HasDecorators}">
196192
<v:CommitRefsPresenter TagBackground="{DynamicResource Brush.DecoratorTag}"
197193
Foreground="{DynamicResource Brush.FG1}"
@@ -202,7 +198,7 @@
202198
</Border>
203199

204200
<!-- Messages -->
205-
<TextBlock Grid.Row="4" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Message}" VerticalAlignment="Top" Margin="0,4,0,0" />
201+
<TextBlock Grid.Row="4" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Message}" />
206202
<v:CommitMessagePresenter Grid.Row="5" Grid.Column="1"
207203
Margin="12,5,8,0"
208204
Classes="primary"

src/Views/Preference.axaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@
112112

113113
<CheckBox Grid.Row="5" Grid.Column="1"
114114
Height="32"
115-
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
116-
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
115+
Content="{DynamicResource Text.Preference.General.ShowChildren}"
116+
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowChildren, Mode=TwoWay}"/>
117117

118118
<CheckBox Grid.Row="6" Grid.Column="1"
119119
Height="32"
120-
Content="{DynamicResource Text.Preference.General.ShowChildren}"
121-
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowChildren, Mode=TwoWay}"/>
120+
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
121+
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
122122
</Grid>
123123
</TabItem>
124124

0 commit comments

Comments
 (0)