mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
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:
parent
dd0580d0f5
commit
ab2156bfc2
7 changed files with 107 additions and 110 deletions
|
@ -1,25 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SourceGit.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SourceGit.Commands
|
||||
{
|
||||
public class QueryCommitChildren : Command
|
||||
{
|
||||
public QueryCommitChildren(string repo, string commit, string filters)
|
||||
public QueryCommitChildren(string repo, string commit, int max, string filters)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
_commit = commit;
|
||||
if (string.IsNullOrEmpty(filters))
|
||||
filters = "--all";
|
||||
Args = $"rev-list -{Preference.Instance.MaxHistoryCommits} --parents {filters} ^{commit}";
|
||||
}
|
||||
|
||||
protected override void OnReadline(string line)
|
||||
{
|
||||
if (line.Contains(_commit))
|
||||
_lines.Add(line.Substring(0, 40));
|
||||
filters = "--branches --remotes --tags";
|
||||
Args = $"rev-list -{max} --parents {filters} ^{commit}";
|
||||
}
|
||||
|
||||
public IEnumerable<string> Result()
|
||||
|
@ -28,6 +20,12 @@ namespace SourceGit.Commands
|
|||
return _lines;
|
||||
}
|
||||
|
||||
protected override void OnReadline(string line)
|
||||
{
|
||||
if (line.Contains(_commit))
|
||||
_lines.Add(line.Substring(0, 40));
|
||||
}
|
||||
|
||||
private string _commit;
|
||||
private List<string> _lines = new List<string>();
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@
|
|||
<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.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.ContainsIn" xml:space="preserve">查看包含此提交的分支/标签</x:String>
|
||||
<x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">本提交已被以下分支/标签包含</x:String>
|
||||
|
|
|
@ -128,7 +128,8 @@
|
|||
<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.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.Title" xml:space="preserve">本提交包含於以下分支或標籤</x:String>
|
||||
<x:String x:Key="Text.CommitDetail.Info.GotoChangesPage" xml:space="preserve">僅顯示前 100 項變更。請前往 [變更對比] 頁面以瀏覽所有變更。</x:String>
|
||||
|
|
|
@ -547,7 +547,9 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
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();
|
||||
if (!cmdChildren.Cancel.Requested)
|
||||
Dispatcher.UIThread.Post(() => Children.AddRange(children));
|
||||
|
|
|
@ -144,6 +144,12 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _showAuthorTimeInGraph, value);
|
||||
}
|
||||
|
||||
public bool ShowChildren
|
||||
{
|
||||
get => _showChildren;
|
||||
set => SetProperty(ref _showChildren, value);
|
||||
}
|
||||
|
||||
public string IgnoreUpdateTag
|
||||
{
|
||||
get => _ignoreUpdateTag;
|
||||
|
@ -294,12 +300,6 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _statisticsSampleColor, value);
|
||||
}
|
||||
|
||||
public bool ShowChildren
|
||||
{
|
||||
get => _showChildren;
|
||||
set => SetProperty(ref _showChildren, value);
|
||||
}
|
||||
|
||||
public List<RepositoryNode> RepositoryNodes
|
||||
{
|
||||
get;
|
||||
|
@ -598,6 +598,7 @@ namespace SourceGit.ViewModels
|
|||
private int _subjectGuideLength = 50;
|
||||
private bool _useFixedTabWidth = true;
|
||||
private bool _showAuthorTimeInGraph = false;
|
||||
private bool _showChildren = false;
|
||||
|
||||
private bool _check4UpdatesOnStartup = true;
|
||||
private double _lastCheckUpdateTime = 0;
|
||||
|
@ -623,7 +624,5 @@ namespace SourceGit.ViewModels
|
|||
private string _externalMergeToolPath = string.Empty;
|
||||
|
||||
private uint _statisticsSampleColor = 0xFF00FF00;
|
||||
|
||||
private bool _showChildren = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@
|
|||
<!-- Base Information -->
|
||||
<Grid RowDefinitions="24,Auto,Auto,Auto,Auto" ColumnDefinitions="96,*">
|
||||
<!-- SHA -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
||||
<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" Height="24">
|
||||
<TextBlock Classes="primary"
|
||||
Text="{Binding SHA}"
|
||||
Margin="12,0,4,0"
|
||||
|
@ -101,97 +101,93 @@
|
|||
</StackPanel>
|
||||
|
||||
<!-- 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}}"/>
|
||||
<ScrollViewer Grid.Row="1" Grid.Column="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" AllowAutoHide="True">
|
||||
<ItemsControl Height="24" Margin="12,0,0,0" ItemsSource="{Binding Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<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}}"/>
|
||||
<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.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Classes="primary"
|
||||
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||
Foreground="DarkOrange"
|
||||
TextDecorations="Underline"
|
||||
Cursor="Hand"
|
||||
Margin="0,0,16,0"
|
||||
PointerEntered="OnSHAPointerEntered"
|
||||
PointerPressed="OnSHAPressed">
|
||||
<TextBlock.Styles>
|
||||
<Style Selector="ToolTip">
|
||||
<Setter Property="MaxWidth" Value="600"/>
|
||||
</Style>
|
||||
</TextBlock.Styles>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Classes="primary"
|
||||
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||
Foreground="DarkOrange"
|
||||
TextDecorations="Underline"
|
||||
Cursor="Hand"
|
||||
Margin="0,0,16,0"
|
||||
PointerEntered="OnSHAPointerEntered"
|
||||
PointerPressed="OnSHAPressed">
|
||||
<TextBlock.Styles>
|
||||
<Style Selector="ToolTip">
|
||||
<Setter Property="MaxWidth" Value="600"/>
|
||||
</Style>
|
||||
</TextBlock.Styles>
|
||||
|
||||
<TextBlock.DataTemplates>
|
||||
<DataTemplate DataType="m:Commit">
|
||||
<StackPanel MinWidth="400" Orientation="Vertical">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
|
||||
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
|
||||
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding CommitterTimeStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
|
||||
</Grid>
|
||||
<TextBlock.DataTemplates>
|
||||
<DataTemplate DataType="m:Commit">
|
||||
<StackPanel MinWidth="400" Orientation="Vertical">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
|
||||
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
|
||||
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding CommitterTimeStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</TextBlock.DataTemplates>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
<TextBlock Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</TextBlock.DataTemplates>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<!-- 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}}"/>
|
||||
<ScrollViewer Grid.Row="2" Grid.Column="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" AllowAutoHide="True">
|
||||
<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>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<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}}"/>
|
||||
<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.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center" ItemHeight="24"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Classes="primary"
|
||||
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||
Foreground="DarkOrange"
|
||||
TextDecorations="Underline"
|
||||
Cursor="Hand"
|
||||
Margin="0,0,16,0"
|
||||
PointerEntered="OnSHAPointerEntered"
|
||||
PointerPressed="OnSHAPressed">
|
||||
<TextBlock.Styles>
|
||||
<Style Selector="ToolTip">
|
||||
<Setter Property="MaxWidth" Value="600"/>
|
||||
</Style>
|
||||
</TextBlock.Styles>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Classes="primary"
|
||||
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||
Foreground="DarkOrange"
|
||||
TextDecorations="Underline"
|
||||
Cursor="Hand"
|
||||
Margin="0,0,16,0"
|
||||
PointerEntered="OnSHAPointerEntered"
|
||||
PointerPressed="OnSHAPressed">
|
||||
<TextBlock.Styles>
|
||||
<Style Selector="ToolTip">
|
||||
<Setter Property="MaxWidth" Value="600"/>
|
||||
</Style>
|
||||
</TextBlock.Styles>
|
||||
|
||||
<TextBlock.DataTemplates>
|
||||
<DataTemplate DataType="m:Commit">
|
||||
<StackPanel MinWidth="400" Orientation="Vertical">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
|
||||
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
|
||||
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding CommitterTimeStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
|
||||
</Grid>
|
||||
<TextBlock.DataTemplates>
|
||||
<DataTemplate DataType="m:Commit">
|
||||
<StackPanel MinWidth="400" Orientation="Vertical">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
|
||||
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
|
||||
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding CommitterTimeStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</TextBlock.DataTemplates>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
<TextBlock Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</TextBlock.DataTemplates>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<!-- 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}">
|
||||
<v:CommitRefsPresenter TagBackground="{DynamicResource Brush.DecoratorTag}"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
|
@ -202,7 +198,7 @@
|
|||
</Border>
|
||||
|
||||
<!-- 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"
|
||||
Margin="12,5,8,0"
|
||||
Classes="primary"
|
||||
|
|
|
@ -112,13 +112,13 @@
|
|||
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
|
||||
Content="{DynamicResource Text.Preference.General.ShowChildren}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowChildren, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Preference.General.ShowChildren}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowChildren, Mode=TwoWay}"/>
|
||||
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
|
|
Loading…
Reference in a new issue