mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
feature: using TextBlock instead of SelectableTextBlock for commit SHA and add a button to copy it
This commit is contained in:
parent
6cf9448313
commit
e0b09d4dd4
7 changed files with 23 additions and 13 deletions
|
@ -124,6 +124,7 @@
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">PARENTS</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">PARENTS</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Refs" xml:space="preserve">REFS</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Refs" xml:space="preserve">REFS</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.SHA" xml:space="preserve">SHA</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.SHA" xml:space="preserve">SHA</x:String>
|
||||||
|
<x:String x:Key="Text.CommitDetail.Info.WebLinks" xml:space="preserve">Open in Browser</x:String>
|
||||||
<x:String x:Key="Text.CommitMessageTextBox.SubjectPlaceholder" xml:space="preserve">Enter commit subject</x:String>
|
<x:String x:Key="Text.CommitMessageTextBox.SubjectPlaceholder" xml:space="preserve">Enter commit subject</x:String>
|
||||||
<x:String x:Key="Text.CommitMessageTextBox.MessagePlaceholder" xml:space="preserve">Description</x:String>
|
<x:String x:Key="Text.CommitMessageTextBox.MessagePlaceholder" xml:space="preserve">Description</x:String>
|
||||||
<x:String x:Key="Text.Configure" xml:space="preserve">Repository Configure</x:String>
|
<x:String x:Key="Text.Configure" xml:space="preserve">Repository Configure</x:String>
|
||||||
|
|
|
@ -127,6 +127,7 @@
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">父提交</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">父提交</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Refs" xml:space="preserve">相关引用</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Refs" xml:space="preserve">相关引用</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.SHA" xml:space="preserve">提交指纹</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.SHA" xml:space="preserve">提交指纹</x:String>
|
||||||
|
<x:String x:Key="Text.CommitDetail.Info.WebLinks" xml:space="preserve">浏览器中查看</x:String>
|
||||||
<x:String x:Key="Text.CommitMessageTextBox.SubjectPlaceholder" xml:space="preserve">填写提交信息主题</x:String>
|
<x:String x:Key="Text.CommitMessageTextBox.SubjectPlaceholder" xml:space="preserve">填写提交信息主题</x:String>
|
||||||
<x:String x:Key="Text.CommitMessageTextBox.MessagePlaceholder" xml:space="preserve">详细描述</x:String>
|
<x:String x:Key="Text.CommitMessageTextBox.MessagePlaceholder" xml:space="preserve">详细描述</x:String>
|
||||||
<x:String x:Key="Text.Configure" xml:space="preserve">仓库配置</x:String>
|
<x:String x:Key="Text.Configure" xml:space="preserve">仓库配置</x:String>
|
||||||
|
|
|
@ -127,6 +127,7 @@
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">前次提交</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">前次提交</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Refs" xml:space="preserve">相關參照</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Refs" xml:space="preserve">相關參照</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.SHA" xml:space="preserve">提交編號</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.SHA" xml:space="preserve">提交編號</x:String>
|
||||||
|
<x:String x:Key="Text.CommitDetail.Info.WebLinks" xml:space="preserve">在瀏覽器中訪問</x:String>
|
||||||
<x:String x:Key="Text.CommitMessageTextBox.SubjectPlaceholder" xml:space="preserve">填寫提交訊息標題</x:String>
|
<x:String x:Key="Text.CommitMessageTextBox.SubjectPlaceholder" xml:space="preserve">填寫提交訊息標題</x:String>
|
||||||
<x:String x:Key="Text.CommitMessageTextBox.MessagePlaceholder" xml:space="preserve">詳細描述</x:String>
|
<x:String x:Key="Text.CommitMessageTextBox.MessagePlaceholder" xml:space="preserve">詳細描述</x:String>
|
||||||
<x:String x:Key="Text.Configure" xml:space="preserve">存放庫設定</x:String>
|
<x:String x:Key="Text.Configure" xml:space="preserve">存放庫設定</x:String>
|
||||||
|
|
|
@ -55,20 +55,23 @@
|
||||||
<!-- 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" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
||||||
<SelectableTextBlock Classes="primary"
|
<TextBlock Classes="primary"
|
||||||
Text="{Binding SHA}"
|
Text="{Binding SHA}"
|
||||||
Margin="12,0,4,0"
|
Margin="12,0,4,0"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
|
|
||||||
<Button Classes="icon_button" Width="24" Cursor="Hand" Click="OnOpenWebLink" IsVisible="{Binding #ThisControl.WebLinks, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}">
|
<Button Classes="icon_button" Width="24" Cursor="Hand" Click="OnCopyCommitSHA" ToolTip.Tip="{DynamicResource Text.Copy}">
|
||||||
<Path Width="12" Height="12" Data="{StaticResource Icons.Link}" Fill="{DynamicResource Brush.Link}"/>
|
<Path Width="12" Height="12" Data="{StaticResource Icons.Copy}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button Classes="icon_button" Width="24" Cursor="Hand" Click="OnOpenContainsIn" IsVisible="{Binding #ThisControl.SupportsContainsIn}" ToolTip.Tip="{DynamicResource Text.CommitDetail.Info.ContainsIn}">
|
<Button Classes="icon_button" Width="24" Cursor="Hand" Click="OnOpenContainsIn" IsVisible="{Binding #ThisControl.SupportsContainsIn}" ToolTip.Tip="{DynamicResource Text.CommitDetail.Info.ContainsIn}">
|
||||||
<Path Width="12" Height="12" Data="{StaticResource Icons.Relation}"/>
|
<Path Width="12" Height="12" Data="{StaticResource Icons.Relation}"/>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
|
<Button Classes="icon_button" Width="24" Cursor="Hand" Click="OnOpenWebLink" IsVisible="{Binding #ThisControl.WebLinks, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}" ToolTip.Tip="{DynamicResource Text.CommitDetail.Info.WebLinks}">
|
||||||
|
<Path Width="12" Height="12" Data="{StaticResource Icons.Link}" Fill="{DynamicResource Brush.Link}"/>
|
||||||
|
</Button>
|
||||||
|
</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" Text="{DynamicResource Text.CommitDetail.Info.Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/>
|
||||||
|
|
|
@ -49,6 +49,14 @@ namespace SourceGit.Views
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnCopyCommitSHA(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is Button { DataContext: Models.Commit commit })
|
||||||
|
App.CopyText(commit.SHA);
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnOpenWebLink(object sender, RoutedEventArgs e)
|
private void OnOpenWebLink(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (DataContext is ViewModels.CommitDetail detail)
|
if (DataContext is ViewModels.CommitDetail detail)
|
||||||
|
|
|
@ -83,14 +83,13 @@ namespace SourceGit.Views
|
||||||
if (matches.Count == 0)
|
if (matches.Count == 0)
|
||||||
{
|
{
|
||||||
Inlines.Add(new Run(message));
|
Inlines.Add(new Run(message));
|
||||||
InvalidateTextLayout();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
matches.Sort((l, r) => l.Start - r.Start);
|
matches.Sort((l, r) => l.Start - r.Start);
|
||||||
_matches = matches;
|
_matches = matches;
|
||||||
|
|
||||||
var inlines = new List<Run>();
|
var inlines = new List<Inline>();
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
foreach (var match in matches)
|
foreach (var match in matches)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +107,6 @@ namespace SourceGit.Views
|
||||||
inlines.Add(new Run(message.Substring(pos)));
|
inlines.Add(new Run(message.Substring(pos)));
|
||||||
|
|
||||||
Inlines.AddRange(inlines);
|
Inlines.AddRange(inlines);
|
||||||
InvalidateTextLayout();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,14 +207,13 @@ namespace SourceGit.Views
|
||||||
if (matches.Count == 0)
|
if (matches.Count == 0)
|
||||||
{
|
{
|
||||||
Inlines.Add(new Run(subject));
|
Inlines.Add(new Run(subject));
|
||||||
InvalidateTextLayout();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
matches.Sort((l, r) => l.Start - r.Start);
|
matches.Sort((l, r) => l.Start - r.Start);
|
||||||
_matches = matches;
|
_matches = matches;
|
||||||
|
|
||||||
var inlines = new List<Run>();
|
var inlines = new List<Inline>();
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
foreach (var match in matches)
|
foreach (var match in matches)
|
||||||
{
|
{
|
||||||
|
@ -232,7 +231,6 @@ namespace SourceGit.Views
|
||||||
inlines.Add(new Run(subject.Substring(pos)));
|
inlines.Add(new Run(subject.Substring(pos)));
|
||||||
|
|
||||||
Inlines.AddRange(inlines);
|
Inlines.AddRange(inlines);
|
||||||
InvalidateTextLayout();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue