Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ViewModels/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,11 @@ public void NavigateToCommit(string sha)
}
}

public Models.Commit GetCommitInfo(string sha)
{
return new Commands.QuerySingleCommit(_fullpath, sha).Result();
}

public void NavigateToCurrentHead()
{
if (_currentBranch != null)
Expand Down
36 changes: 34 additions & 2 deletions src/Views/WorkingCopy.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,23 @@
Foreground="DarkOrange"
TextDecorations="Underline"
Cursor="Hand"
PointerPressed="OnPressedSHA"/>
PointerPressed="OnPressedSHA"
PointerEntered="OnSHAPointerEntered"
ToolTip.ShowDelay="0">
<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>
</StackPanel>
</DataTemplate>

Expand All @@ -235,7 +251,23 @@
Foreground="DarkOrange"
TextDecorations="Underline"
Cursor="Hand"
PointerPressed="OnPressedSHA"/>
PointerPressed="OnPressedSHA"
PointerEntered="OnSHAPointerEntered"
ToolTip.ShowDelay="0">
<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>
<TextBlock Margin="4,0,0,0" Text="{Binding Subject}"/>
</StackPanel>
</DataTemplate>
Expand Down
33 changes: 33 additions & 0 deletions src/Views/WorkingCopy.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.Threading.Tasks;

using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.VisualTree;
using Avalonia.Threading;

namespace SourceGit.Views
{
Expand Down Expand Up @@ -123,6 +126,36 @@ private void OnStageSelectedButtonClicked(object _, RoutedEventArgs e)
e.Handled = true;
}

private void OnSHAPointerEntered(object sender, PointerEventArgs e)
{
var repoView = this.FindAncestorOfType<Repository>();
if (repoView is { DataContext: ViewModels.Repository repo } && sender is TextBlock text)
{
var commit = repo.GetCommitInfo(text.Text);

if (sender is Control control)
{
var tooltip = ToolTip.GetTip(control);
if (tooltip is Models.Commit tip_commit && tip_commit.SHA == commit.SHA)
return;

Task.Run(() =>
{
Dispatcher.UIThread.Invoke(() =>
{
if (control.IsEffectivelyVisible && control.IsPointerOver)
{
ToolTip.SetTip(control, commit);
ToolTip.SetIsOpen(control, true);
}
});
});
}
}

e.Handled = true;
}

private void OnUnstageSelectedButtonClicked(object _, RoutedEventArgs e)
{
if (DataContext is ViewModels.WorkingCopy vm)
Expand Down