feature: show tooltip of parent commit when hover the parent SHA

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-12 17:59:50 +08:00
parent 1f158eeded
commit 6e4f971733
No known key found for this signature in database
3 changed files with 52 additions and 1 deletions

View file

@ -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 })