feature: add context menu for issue link in commit details panel (#651)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-04 15:31:55 +08:00
parent 64860950c7
commit 163e8cc0a4
No known key found for this signature in database
24 changed files with 76 additions and 66 deletions

View file

@ -176,7 +176,41 @@ namespace SourceGit.Views
}
else
{
Native.OS.OpenBrowser(_lastHover.Link);
var point = e.GetCurrentPoint(this);
var link = _lastHover.Link;
if (point.Properties.IsLeftButtonPressed)
{
Native.OS.OpenBrowser(link);
}
else if (point.Properties.IsRightButtonPressed)
{
var open = new MenuItem();
open.Header = App.Text("IssueLinkCM.OpenInBrowser");
open.Icon = App.CreateMenuIcon("Icons.OpenWith");
open.Click += (_, ev) =>
{
ev.Handled = true;
var parentView = this.FindAncestorOfType<CommitBaseInfo>();
if (parentView is { DataContext: ViewModels.CommitDetail detail })
detail.NavigateTo(link);
};
var copy = new MenuItem();
copy.Header = App.Text("IssueLinkCM.CopyLink");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Click += (_, ev) =>
{
App.CopyText(link);
ev.Handled = true;
};
var menu = new ContextMenu();
menu.Items.Add(open);
menu.Items.Add(copy);
menu.Open(this);
}
}
e.Handled = true;