mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
feature: show tooltip of parent commit when hover the parent SHA
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
1f158eeded
commit
6e4f971733
3 changed files with 52 additions and 1 deletions
|
@ -169,6 +169,11 @@ namespace SourceGit.ViewModels
|
|||
SearchChangeFilter = string.Empty;
|
||||
}
|
||||
|
||||
public Models.Commit GetParent(string sha)
|
||||
{
|
||||
return new Commands.QuerySingleCommit(_repo.FullPath, sha).Result();
|
||||
}
|
||||
|
||||
public List<Models.Object> GetRevisionFilesUnderFolder(string parentFolder)
|
||||
{
|
||||
return new Commands.QueryRevisionObjects(_repo.FullPath, _commit.SHA, parentFolder).Result();
|
||||
|
|
|
@ -117,7 +117,28 @@
|
|||
TextDecorations="Underline"
|
||||
Cursor="Hand"
|
||||
Margin="0,0,16,0"
|
||||
PointerPressed="OnSHAPressed"/>
|
||||
PointerEntered="OnSHAPointerEntered"
|
||||
PointerPressed="OnSHAPressed">
|
||||
<TextBlock.Styles>
|
||||
<Style Selector="ToolTip">
|
||||
<Setter Property="MaxWidth" Value="800"/>
|
||||
</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 Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</TextBlock.DataTemplates>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
|
@ -113,6 +115,29 @@ namespace SourceGit.Views
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private async void OnSHAPointerEntered(object sender, PointerEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.CommitDetail detail && sender is Control { DataContext: string sha } ctl)
|
||||
{
|
||||
var tooltip = ToolTip.GetTip(ctl);
|
||||
if (tooltip is Models.Commit commit && commit.SHA == sha)
|
||||
{
|
||||
ToolTip.SetIsOpen(ctl, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
var c = await Task.Run(() => detail.GetParent(sha));
|
||||
if (c != null)
|
||||
{
|
||||
ToolTip.SetTip(ctl, c);
|
||||
ToolTip.SetIsOpen(ctl, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnSHAPressed(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.CommitDetail detail && sender is Control { DataContext: string sha })
|
||||
|
|
Loading…
Reference in a new issue