feature: use F1 to quick open the Keyboard Shortcuts Reference dialog (#1225)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-22 10:30:19 +08:00
parent 9f18cbca5b
commit 4c3698b171
No known key found for this signature in database
3 changed files with 18 additions and 1 deletions

View file

@ -35,7 +35,7 @@
<NativeMenu.Menu> <NativeMenu.Menu>
<NativeMenu> <NativeMenu>
<NativeMenuItem Header="{DynamicResource Text.About.Menu}" Command="{x:Static s:App.OpenAboutCommand}"/> <NativeMenuItem Header="{DynamicResource Text.About.Menu}" Command="{x:Static s:App.OpenAboutCommand}"/>
<NativeMenuItem Header="{DynamicResource Text.Hotkeys}" Command="{x:Static s:App.OpenHotkeysCommand}"/> <NativeMenuItem Header="{DynamicResource Text.Hotkeys}" Command="{x:Static s:App.OpenHotkeysCommand}" Gesture="F1"/>
<NativeMenuItem Header="{DynamicResource Text.SelfUpdate}" Command="{x:Static s:App.CheckForUpdateCommand}" IsVisible="{x:Static s:App.IsCheckForUpdateCommandVisible}"/> <NativeMenuItem Header="{DynamicResource Text.SelfUpdate}" Command="{x:Static s:App.CheckForUpdateCommand}" IsVisible="{x:Static s:App.IsCheckForUpdateCommandVisible}"/>
<NativeMenuItemSeparator/> <NativeMenuItemSeparator/>
<NativeMenuItem Header="{DynamicResource Text.Preferences}" Command="{x:Static s:App.OpenPreferencesCommand}" Gesture="⌘+,"/> <NativeMenuItem Header="{DynamicResource Text.Preferences}" Command="{x:Static s:App.OpenPreferencesCommand}" Gesture="⌘+,"/>

View file

@ -1,3 +1,5 @@
using Avalonia.Input;
namespace SourceGit.Views namespace SourceGit.Views
{ {
public partial class Hotkeys : ChromelessWindow public partial class Hotkeys : ChromelessWindow
@ -6,5 +8,13 @@ namespace SourceGit.Views
{ {
InitializeComponent(); InitializeComponent();
} }
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (!e.Handled && e.Key == Key.Escape)
Close();
}
} }
} }

View file

@ -141,6 +141,13 @@ namespace SourceGit.Views
return; return;
} }
// F1 opens preference dialog (macOS use hotkeys in system menu bar)
if (!OperatingSystem.IsMacOS() && e.Key == Key.F1)
{
App.ShowWindow(new Hotkeys(), true);
return;
}
// Ctrl+Q quits the application (macOS use hotkeys in system menu bar) // Ctrl+Q quits the application (macOS use hotkeys in system menu bar)
if (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control && e.Key == Key.Q) if (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control && e.Key == Key.Q)
{ {