diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 4ff2e840..aeaa1633 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -114,6 +114,7 @@ User name for this repository Copy Copy Path + Copy File Name Create Branch Based On : Check out after created diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 4dde24da..5ee15391 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -114,6 +114,7 @@ 应用于本仓库的用户名 复制 复制路径 + 复制文件名 新建分支 新分支基于 : 完成后切换到新分支 diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index b96c1fe1..1cb4a1fc 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -10,6 +10,7 @@ using Avalonia.Platform.Storage; using Avalonia.Threading; using CommunityToolkit.Mvvm.ComponentModel; +using SourceGit.Models; namespace SourceGit.ViewModels { @@ -218,7 +219,17 @@ namespace SourceGit.ViewModels ev.Handled = true; }; menu.Items.Add(copyPath); - + var copyFileName = new MenuItem() + { + Header = App.Text("CopyFileName"), + Icon = App.CreateMenuIcon("Icon.Copy"), + }; + copyFileName.Click += (_, e) => + { + App.CopyText(Path.GetFileName(change.Path)); + e.Handled = true; + }; + menu.Items.Add(copyFileName); return menu; } @@ -284,12 +295,24 @@ namespace SourceGit.ViewModels ev.Handled = true; }; + var copyFileName = new MenuItem() + { + Header = App.Text("CopyFileName"), + Icon = App.CreateMenuIcon("Icon.Copy"), + }; + copyFileName.Click += (_, e) => + { + App.CopyText(Path.GetFileName(file.Path)); + e.Handled = true; + }; + var menu = new ContextMenu(); menu.Items.Add(history); menu.Items.Add(blame); menu.Items.Add(explore); menu.Items.Add(saveAs); menu.Items.Add(copyPath); + menu.Items.Add(copyFileName); return menu; } diff --git a/src/ViewModels/RevisionCompare.cs b/src/ViewModels/RevisionCompare.cs index 9026aa7f..0263f41b 100644 --- a/src/ViewModels/RevisionCompare.cs +++ b/src/ViewModels/RevisionCompare.cs @@ -183,6 +183,17 @@ namespace SourceGit.ViewModels }; menu.Items.Add(copyPath); + var copyFileName = new MenuItem() + { + Header = App.Text("CopyFileName"), + Icon = App.CreateMenuIcon("Icon.Copy"), + }; + copyFileName.Click += (_, e) => + { + App.CopyText(Path.GetFileName(change.Path)); + e.Handled = true; + }; + menu.Items.Add(copyFileName); return menu; } diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 2c4f1c3a..4c7a92b6 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -209,7 +209,7 @@ namespace SourceGit.ViewModels _unstaged.Clear(); OnPropertyChanged(nameof(Unstaged)); } - + if (_staged != null) { _staged.Clear(); @@ -584,6 +584,17 @@ namespace SourceGit.ViewModels e.Handled = true; }; menu.Items.Add(copy); + var copyFileName = new MenuItem() + { + Header = App.Text("CopyFileName"), + Icon = App.CreateMenuIcon("Icon.Copy"), + }; + copyFileName.Click += (_, e) => + { + App.CopyText(Path.GetFileName(change.Path)); + e.Handled = true; + }; + menu.Items.Add(copyFileName); } else {