code_review: PR #160

* should be `Icons.Copy` not `Icon.Copy`
* remove unused using
* keep the same code style in a function
This commit is contained in:
leo 2024-06-01 12:34:16 +08:00
parent 04e6ed45a7
commit 9d9dd6acb5
3 changed files with 27 additions and 22 deletions

View file

@ -10,7 +10,6 @@ using Avalonia.Platform.Storage;
using Avalonia.Threading; using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using SourceGit.Models;
namespace SourceGit.ViewModels namespace SourceGit.ViewModels
{ {
@ -219,17 +218,17 @@ namespace SourceGit.ViewModels
ev.Handled = true; ev.Handled = true;
}; };
menu.Items.Add(copyPath); menu.Items.Add(copyPath);
var copyFileName = new MenuItem()
{ var copyFileName = new MenuItem();
Header = App.Text("CopyFileName"), copyFileName.Header = App.Text("CopyFileName");
Icon = App.CreateMenuIcon("Icon.Copy"), copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
};
copyFileName.Click += (_, e) => copyFileName.Click += (_, e) =>
{ {
App.CopyText(Path.GetFileName(change.Path)); App.CopyText(Path.GetFileName(change.Path));
e.Handled = true; e.Handled = true;
}; };
menu.Items.Add(copyFileName); menu.Items.Add(copyFileName);
return menu; return menu;
} }
@ -295,11 +294,9 @@ namespace SourceGit.ViewModels
ev.Handled = true; ev.Handled = true;
}; };
var copyFileName = new MenuItem() var copyFileName = new MenuItem();
{ copyFileName.Header = App.Text("CopyFileName");
Header = App.Text("CopyFileName"), copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
Icon = App.CreateMenuIcon("Icon.Copy"),
};
copyFileName.Click += (_, e) => copyFileName.Click += (_, e) =>
{ {
App.CopyText(Path.GetFileName(file.Path)); App.CopyText(Path.GetFileName(file.Path));

View file

@ -181,19 +181,18 @@ namespace SourceGit.ViewModels
App.CopyText(change.Path); App.CopyText(change.Path);
ev.Handled = true; ev.Handled = true;
}; };
menu.Items.Add(copyPath); menu.Items.Add(copyPath);
var copyFileName = new MenuItem()
{ var copyFileName = new MenuItem();
Header = App.Text("CopyFileName"), copyFileName.Header = App.Text("CopyFileName");
Icon = App.CreateMenuIcon("Icon.Copy"), copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
};
copyFileName.Click += (_, e) => copyFileName.Click += (_, e) =>
{ {
App.CopyText(Path.GetFileName(change.Path)); App.CopyText(Path.GetFileName(change.Path));
e.Handled = true; e.Handled = true;
}; };
menu.Items.Add(copyFileName); menu.Items.Add(copyFileName);
return menu; return menu;
} }

View file

@ -584,11 +584,10 @@ namespace SourceGit.ViewModels
e.Handled = true; e.Handled = true;
}; };
menu.Items.Add(copy); menu.Items.Add(copy);
var copyFileName = new MenuItem()
{ var copyFileName = new MenuItem();
Header = App.Text("CopyFileName"), copyFileName.Header = App.Text("CopyFileName");
Icon = App.CreateMenuIcon("Icon.Copy"), copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
};
copyFileName.Click += (_, e) => copyFileName.Click += (_, e) =>
{ {
App.CopyText(Path.GetFileName(change.Path)); App.CopyText(Path.GetFileName(change.Path));
@ -801,6 +800,15 @@ namespace SourceGit.ViewModels
App.CopyText(change.Path); App.CopyText(change.Path);
e.Handled = true; 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(explore);
menu.Items.Add(openWith); menu.Items.Add(openWith);
@ -811,6 +819,7 @@ namespace SourceGit.ViewModels
menu.Items.Add(patch); menu.Items.Add(patch);
menu.Items.Add(new MenuItem() { Header = "-" }); menu.Items.Add(new MenuItem() { Header = "-" });
menu.Items.Add(copyPath); menu.Items.Add(copyPath);
menu.Items.Add(copyFileName);
} }
else else
{ {