Skip to content

Commit 614ffb0

Browse files
committed
feature: allow to copy parent SHA in commit details panel
Signed-off-by: leo <longshuang@msn.cn>
1 parent 0e06ce0 commit 614ffb0

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎src/Views/CommitBaseInfo.axaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
Margin="0,0,16,0"
122122
PointerEntered="OnSHAPointerEntered"
123123
PointerPressed="OnSHAPressed"
124+
ContextRequested="OnSHAContextRequested"
124125
ToolTip.ShowDelay="0">
125126
<ToolTip.IsOpen>
126127
<MultiBinding Converter="{x:Static BoolConverters.And}">

‎src/Views/CommitBaseInfo.axaml.cs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,26 @@ DataContext is ViewModels.CommitDetail detail &&
225225
e.Handled = true;
226226
}
227227

228+
private void OnSHAContextRequested(object sender, ContextRequestedEventArgs e)
229+
{
230+
if (sender is not Control { DataContext: string sha } control)
231+
return;
232+
233+
var copy = new MenuItem();
234+
copy.Header = App.Text("Copy");
235+
copy.Icon = this.CreateMenuIcon("Icons.Copy");
236+
copy.Click += async (_, ev) =>
237+
{
238+
await this.CopyTextAsync(sha);
239+
ev.Handled = true;
240+
};
241+
242+
var menu = new ContextMenu();
243+
menu.Items.Add(copy);
244+
menu.Open(control);
245+
e.Handled = true;
246+
}
247+
228248
private void OnUserContextRequested(object sender, ContextRequestedEventArgs e)
229249
{
230250
if (sender is not Control { Tag: Models.User user } control)

0 commit comments

Comments
 (0)