mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 19:55:00 +00:00
enhance: show commit full message tooltip when hover commit subject in FileHistories
view (#1232)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
7890f7abbf
commit
fafa2a53ae
3 changed files with 37 additions and 1 deletions
|
@ -305,11 +305,23 @@ namespace SourceGit.ViewModels
|
|||
_repo.NavigateToCommit(commit.SHA);
|
||||
}
|
||||
|
||||
public string GetCommitFullMessage(Models.Commit commit)
|
||||
{
|
||||
var sha = commit.SHA;
|
||||
if (_fullCommitMessages.TryGetValue(sha, out var msg))
|
||||
return msg;
|
||||
|
||||
msg = new Commands.QueryCommitFullMessage(_repo.FullPath, sha).Result();
|
||||
_fullCommitMessages[sha] = msg;
|
||||
return msg;
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
private readonly string _file = null;
|
||||
private bool _isLoading = true;
|
||||
private bool _prevIsDiffMode = true;
|
||||
private List<Models.Commit> _commits = null;
|
||||
private Dictionary<string, string> _fullCommitMessages = new Dictionary<string, string>();
|
||||
private object _viewContent = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,12 @@
|
|||
<TextBlock Grid.Column="3" Classes="primary" Text="{Binding AuthorTimeShortStr}" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="1" Classes="primary" Text="{Binding Subject}" VerticalAlignment="Bottom"/>
|
||||
<TextBlock Grid.Row="1"
|
||||
Classes="primary"
|
||||
Text="{Binding Subject}"
|
||||
VerticalAlignment="Bottom"
|
||||
DataContextChanged="OnCommitSubjectDataContextChanged"
|
||||
PointerMoved="OnCommitSubjectPointerMoved"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
@ -57,5 +59,22 @@ namespace SourceGit.Views
|
|||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCommitSubjectDataContextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is TextBlock textBlock)
|
||||
ToolTip.SetTip(textBlock, null);
|
||||
}
|
||||
|
||||
private void OnCommitSubjectPointerMoved(object sender, PointerEventArgs e)
|
||||
{
|
||||
if (sender is TextBlock { DataContext: Models.Commit commit } textBlock &&
|
||||
DataContext is ViewModels.FileHistories vm)
|
||||
{
|
||||
var tooltip = ToolTip.GetTip(textBlock);
|
||||
if (tooltip == null)
|
||||
ToolTip.SetTip(textBlock, vm.GetCommitFullMessage(commit));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue