Skip to content

ux: show a few more shortcuts on menu items #1532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ViewModels/Histories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text;

using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Platform.Storage;

using CommunityToolkit.Mvvm.ComponentModel;
Expand Down Expand Up @@ -428,6 +429,7 @@ public ContextMenu MakeContextMenu(DataGrid list)
var copyMultipleInfo = new MenuItem();
copyMultipleInfo.Header = App.Text("CommitCM.CopySHA") + " - " + App.Text("CommitCM.CopySubject");
copyMultipleInfo.Icon = App.CreateMenuIcon("Icons.Info");
copyMultipleInfo.InputGesture = new KeyGesture(Key.C, OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control);
copyMultipleInfo.Click += async (_, e) =>
{
var builder = new StringBuilder();
Expand Down Expand Up @@ -724,6 +726,7 @@ public ContextMenu MakeContextMenu(DataGrid list)
var createBranch = new MenuItem();
createBranch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
createBranch.Header = App.Text("CreateBranch");
createBranch.InputGesture = new KeyGesture(Key.B, OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control);
createBranch.Click += (_, e) =>
{
if (_repo.CanCreatePopup())
Expand Down Expand Up @@ -839,6 +842,7 @@ public ContextMenu MakeContextMenu(DataGrid list)
var copyInfo = new MenuItem();
copyInfo.Header = App.Text("CommitCM.CopySHA") + " - " + App.Text("CommitCM.CopySubject");
copyInfo.Icon = App.CreateMenuIcon("Icons.Info");
copyInfo.InputGesture = new KeyGesture(Key.C, OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control);
copyInfo.Click += async (_, e) =>
{
await App.CopyTextAsync($"{commit.SHA.AsSpan(0, 10)} - {commit.Subject}");
Expand Down
7 changes: 7 additions & 0 deletions src/ViewModels/WorkingCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;

using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Platform.Storage;
using Avalonia.Threading;

Expand Down Expand Up @@ -676,6 +677,7 @@ public ContextMenu CreateContextMenuForUnstagedChanges(string selectedSingleFold
var stage = new MenuItem();
stage.Header = App.Text("FileCM.Stage");
stage.Icon = App.CreateMenuIcon("Icons.File.Add");
stage.InputGesture = new KeyGesture(Key.Enter);
stage.Click += (_, e) =>
{
StageChanges(_selectedUnstaged, null);
Expand All @@ -685,6 +687,7 @@ public ContextMenu CreateContextMenuForUnstagedChanges(string selectedSingleFold
var discard = new MenuItem();
discard.Header = App.Text("FileCM.Discard");
discard.Icon = App.CreateMenuIcon("Icons.Undo");
discard.InputGesture = new KeyGesture(Key.Delete);
discard.Click += (_, e) =>
{
Discard(_selectedUnstaged);
Expand Down Expand Up @@ -1079,6 +1082,7 @@ public ContextMenu CreateContextMenuForUnstagedChanges(string selectedSingleFold
var stage = new MenuItem();
stage.Header = App.Text("FileCM.StageMulti", _selectedUnstaged.Count);
stage.Icon = App.CreateMenuIcon("Icons.File.Add");
stage.InputGesture = new KeyGesture(Key.Enter);
stage.Click += (_, e) =>
{
StageChanges(_selectedUnstaged, null);
Expand All @@ -1088,6 +1092,7 @@ public ContextMenu CreateContextMenuForUnstagedChanges(string selectedSingleFold
var discard = new MenuItem();
discard.Header = App.Text("FileCM.DiscardMulti", _selectedUnstaged.Count);
discard.Icon = App.CreateMenuIcon("Icons.Undo");
discard.InputGesture = new KeyGesture(Key.Delete);
discard.Click += (_, e) =>
{
Discard(_selectedUnstaged);
Expand Down Expand Up @@ -1263,6 +1268,7 @@ public ContextMenu CreateContextMenuForStagedChanges(string selectedSingleFolder
var unstage = new MenuItem();
unstage.Header = App.Text("FileCM.Unstage");
unstage.Icon = App.CreateMenuIcon("Icons.File.Remove");
unstage.InputGesture = new KeyGesture(Key.Enter);
unstage.Click += (_, e) =>
{
UnstageChanges(_selectedStaged, null);
Expand Down Expand Up @@ -1466,6 +1472,7 @@ public ContextMenu CreateContextMenuForStagedChanges(string selectedSingleFolder
var unstage = new MenuItem();
unstage.Header = App.Text("FileCM.UnstageMulti", _selectedStaged.Count);
unstage.Icon = App.CreateMenuIcon("Icons.File.Remove");
unstage.InputGesture = new KeyGesture(Key.Enter);
unstage.Click += (_, e) =>
{
UnstageChanges(_selectedStaged, null);
Expand Down