Skip to content

Commit dd3c658

Browse files
authored
ux: show a few more shortcuts on menu items (#1532)
1 parent fe9439c commit dd3c658

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/ViewModels/Histories.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text;
66

77
using Avalonia.Controls;
8+
using Avalonia.Input;
89
using Avalonia.Platform.Storage;
910

1011
using CommunityToolkit.Mvvm.ComponentModel;
@@ -428,6 +429,7 @@ public ContextMenu MakeContextMenu(DataGrid list)
428429
var copyMultipleInfo = new MenuItem();
429430
copyMultipleInfo.Header = App.Text("CommitCM.CopySHA") + " - " + App.Text("CommitCM.CopySubject");
430431
copyMultipleInfo.Icon = App.CreateMenuIcon("Icons.Info");
432+
copyMultipleInfo.InputGesture = new KeyGesture(Key.C, OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control);
431433
copyMultipleInfo.Click += async (_, e) =>
432434
{
433435
var builder = new StringBuilder();
@@ -724,6 +726,7 @@ public ContextMenu MakeContextMenu(DataGrid list)
724726
var createBranch = new MenuItem();
725727
createBranch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
726728
createBranch.Header = App.Text("CreateBranch");
729+
createBranch.InputGesture = new KeyGesture(Key.B, OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control);
727730
createBranch.Click += (_, e) =>
728731
{
729732
if (_repo.CanCreatePopup())
@@ -839,6 +842,7 @@ public ContextMenu MakeContextMenu(DataGrid list)
839842
var copyInfo = new MenuItem();
840843
copyInfo.Header = App.Text("CommitCM.CopySHA") + " - " + App.Text("CommitCM.CopySubject");
841844
copyInfo.Icon = App.CreateMenuIcon("Icons.Info");
845+
copyInfo.InputGesture = new KeyGesture(Key.C, OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control);
842846
copyInfo.Click += async (_, e) =>
843847
{
844848
await App.CopyTextAsync($"{commit.SHA.AsSpan(0, 10)} - {commit.Subject}");

src/ViewModels/WorkingCopy.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Threading.Tasks;
55

66
using Avalonia.Controls;
7+
using Avalonia.Input;
78
using Avalonia.Platform.Storage;
89
using Avalonia.Threading;
910

@@ -676,6 +677,7 @@ public ContextMenu CreateContextMenuForUnstagedChanges(string selectedSingleFold
676677
var stage = new MenuItem();
677678
stage.Header = App.Text("FileCM.Stage");
678679
stage.Icon = App.CreateMenuIcon("Icons.File.Add");
680+
stage.InputGesture = new KeyGesture(Key.Enter);
679681
stage.Click += (_, e) =>
680682
{
681683
StageChanges(_selectedUnstaged, null);
@@ -685,6 +687,7 @@ public ContextMenu CreateContextMenuForUnstagedChanges(string selectedSingleFold
685687
var discard = new MenuItem();
686688
discard.Header = App.Text("FileCM.Discard");
687689
discard.Icon = App.CreateMenuIcon("Icons.Undo");
690+
discard.InputGesture = new KeyGesture(Key.Delete);
688691
discard.Click += (_, e) =>
689692
{
690693
Discard(_selectedUnstaged);
@@ -1079,6 +1082,7 @@ public ContextMenu CreateContextMenuForUnstagedChanges(string selectedSingleFold
10791082
var stage = new MenuItem();
10801083
stage.Header = App.Text("FileCM.StageMulti", _selectedUnstaged.Count);
10811084
stage.Icon = App.CreateMenuIcon("Icons.File.Add");
1085+
stage.InputGesture = new KeyGesture(Key.Enter);
10821086
stage.Click += (_, e) =>
10831087
{
10841088
StageChanges(_selectedUnstaged, null);
@@ -1088,6 +1092,7 @@ public ContextMenu CreateContextMenuForUnstagedChanges(string selectedSingleFold
10881092
var discard = new MenuItem();
10891093
discard.Header = App.Text("FileCM.DiscardMulti", _selectedUnstaged.Count);
10901094
discard.Icon = App.CreateMenuIcon("Icons.Undo");
1095+
discard.InputGesture = new KeyGesture(Key.Delete);
10911096
discard.Click += (_, e) =>
10921097
{
10931098
Discard(_selectedUnstaged);
@@ -1263,6 +1268,7 @@ public ContextMenu CreateContextMenuForStagedChanges(string selectedSingleFolder
12631268
var unstage = new MenuItem();
12641269
unstage.Header = App.Text("FileCM.Unstage");
12651270
unstage.Icon = App.CreateMenuIcon("Icons.File.Remove");
1271+
unstage.InputGesture = new KeyGesture(Key.Enter);
12661272
unstage.Click += (_, e) =>
12671273
{
12681274
UnstageChanges(_selectedStaged, null);
@@ -1466,6 +1472,7 @@ public ContextMenu CreateContextMenuForStagedChanges(string selectedSingleFolder
14661472
var unstage = new MenuItem();
14671473
unstage.Header = App.Text("FileCM.UnstageMulti", _selectedStaged.Count);
14681474
unstage.Icon = App.CreateMenuIcon("Icons.File.Remove");
1475+
unstage.InputGesture = new KeyGesture(Key.Enter);
14691476
unstage.Click += (_, e) =>
14701477
{
14711478
UnstageChanges(_selectedStaged, null);

0 commit comments

Comments
 (0)