Skip to content

Commit 4c3698b

Browse files
committed
feature: use F1 to quick open the Keyboard Shortcuts Reference dialog (#1225)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 9f18cbc commit 4c3698b

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/App.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<NativeMenu.Menu>
3636
<NativeMenu>
3737
<NativeMenuItem Header="{DynamicResource Text.About.Menu}" Command="{x:Static s:App.OpenAboutCommand}"/>
38-
<NativeMenuItem Header="{DynamicResource Text.Hotkeys}" Command="{x:Static s:App.OpenHotkeysCommand}"/>
38+
<NativeMenuItem Header="{DynamicResource Text.Hotkeys}" Command="{x:Static s:App.OpenHotkeysCommand}" Gesture="F1"/>
3939
<NativeMenuItem Header="{DynamicResource Text.SelfUpdate}" Command="{x:Static s:App.CheckForUpdateCommand}" IsVisible="{x:Static s:App.IsCheckForUpdateCommandVisible}"/>
4040
<NativeMenuItemSeparator/>
4141
<NativeMenuItem Header="{DynamicResource Text.Preferences}" Command="{x:Static s:App.OpenPreferencesCommand}" Gesture="⌘+,"/>

src/Views/Hotkeys.axaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Avalonia.Input;
2+
13
namespace SourceGit.Views
24
{
35
public partial class Hotkeys : ChromelessWindow
@@ -6,5 +8,13 @@ public Hotkeys()
68
{
79
InitializeComponent();
810
}
11+
12+
protected override void OnKeyDown(KeyEventArgs e)
13+
{
14+
base.OnKeyDown(e);
15+
16+
if (!e.Handled && e.Key == Key.Escape)
17+
Close();
18+
}
919
}
1020
}

src/Views/Launcher.axaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ protected override void OnKeyDown(KeyEventArgs e)
141141
return;
142142
}
143143

144+
// F1 opens preference dialog (macOS use hotkeys in system menu bar)
145+
if (!OperatingSystem.IsMacOS() && e.Key == Key.F1)
146+
{
147+
App.ShowWindow(new Hotkeys(), true);
148+
return;
149+
}
150+
144151
// Ctrl+Q quits the application (macOS use hotkeys in system menu bar)
145152
if (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control && e.Key == Key.Q)
146153
{

0 commit comments

Comments
 (0)