diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 51056f67..ef060f04 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -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 GetRevisionFilesUnderFolder(string parentFolder) { return new Commands.QueryRevisionObjects(_repo.FullPath, _commit.SHA, parentFolder).Result(); diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml index 76ea0227..3eece45f 100644 --- a/src/Views/CommitBaseInfo.axaml +++ b/src/Views/CommitBaseInfo.axaml @@ -117,7 +117,28 @@ TextDecorations="Underline" Cursor="Hand" Margin="0,0,16,0" - PointerPressed="OnSHAPressed"/> + PointerEntered="OnSHAPointerEntered" + PointerPressed="OnSHAPressed"> + + + + + + + + + + + + + + + + + + diff --git a/src/Views/CommitBaseInfo.axaml.cs b/src/Views/CommitBaseInfo.axaml.cs index 228fbe8e..6eb31a60 100644 --- a/src/Views/CommitBaseInfo.axaml.cs +++ b/src/Views/CommitBaseInfo.axaml.cs @@ -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 })