diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 1cb4a1fc..9f79f81d 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -10,7 +10,6 @@ using Avalonia.Platform.Storage; using Avalonia.Threading; using CommunityToolkit.Mvvm.ComponentModel; -using SourceGit.Models; namespace SourceGit.ViewModels { @@ -219,17 +218,17 @@ namespace SourceGit.ViewModels ev.Handled = true; }; menu.Items.Add(copyPath); - var copyFileName = new MenuItem() - { - Header = App.Text("CopyFileName"), - Icon = App.CreateMenuIcon("Icon.Copy"), - }; + + var copyFileName = new MenuItem(); + copyFileName.Header = App.Text("CopyFileName"); + copyFileName.Icon = App.CreateMenuIcon("Icons.Copy"); copyFileName.Click += (_, e) => { App.CopyText(Path.GetFileName(change.Path)); e.Handled = true; }; menu.Items.Add(copyFileName); + return menu; } @@ -295,11 +294,9 @@ namespace SourceGit.ViewModels ev.Handled = true; }; - var copyFileName = new MenuItem() - { - Header = App.Text("CopyFileName"), - Icon = App.CreateMenuIcon("Icon.Copy"), - }; + var copyFileName = new MenuItem(); + copyFileName.Header = App.Text("CopyFileName"); + copyFileName.Icon = App.CreateMenuIcon("Icons.Copy"); copyFileName.Click += (_, e) => { App.CopyText(Path.GetFileName(file.Path)); diff --git a/src/ViewModels/RevisionCompare.cs b/src/ViewModels/RevisionCompare.cs index 0263f41b..1fdec102 100644 --- a/src/ViewModels/RevisionCompare.cs +++ b/src/ViewModels/RevisionCompare.cs @@ -181,19 +181,18 @@ namespace SourceGit.ViewModels App.CopyText(change.Path); ev.Handled = true; }; - menu.Items.Add(copyPath); - var copyFileName = new MenuItem() - { - Header = App.Text("CopyFileName"), - Icon = App.CreateMenuIcon("Icon.Copy"), - }; + + var copyFileName = new MenuItem(); + copyFileName.Header = App.Text("CopyFileName"); + copyFileName.Icon = App.CreateMenuIcon("Icons.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 4c7a92b6..4167c244 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -584,11 +584,10 @@ namespace SourceGit.ViewModels e.Handled = true; }; menu.Items.Add(copy); - var copyFileName = new MenuItem() - { - Header = App.Text("CopyFileName"), - Icon = App.CreateMenuIcon("Icon.Copy"), - }; + + var copyFileName = new MenuItem(); + copyFileName.Header = App.Text("CopyFileName"); + copyFileName.Icon = App.CreateMenuIcon("Icons.Copy"); copyFileName.Click += (_, e) => { App.CopyText(Path.GetFileName(change.Path)); @@ -801,6 +800,15 @@ namespace SourceGit.ViewModels App.CopyText(change.Path); e.Handled = true; }; + + var copyFileName = new MenuItem(); + copyFileName.Header = App.Text("CopyFileName"); + copyFileName.Icon = App.CreateMenuIcon("Icons.Copy"); + copyFileName.Click += (_, e) => + { + App.CopyText(Path.GetFileName(change.Path)); + e.Handled = true; + }; menu.Items.Add(explore); menu.Items.Add(openWith); @@ -811,6 +819,7 @@ namespace SourceGit.ViewModels menu.Items.Add(patch); menu.Items.Add(new MenuItem() { Header = "-" }); menu.Items.Add(copyPath); + menu.Items.Add(copyFileName); } else {