enhance: use instead of Ctrl , instead of Alt for all hotkeys used by this app on macOS (#103)

This commit is contained in:
leo 2024-05-05 18:19:59 +08:00
parent 9627206764
commit 68566b9b34
5 changed files with 26 additions and 19 deletions

View file

@ -68,13 +68,13 @@
Margin="0,0,0,8"/> Margin="0,0,0,8"/>
<Grid RowDefinitions="20,20,20,20" ColumnDefinitions="80,*"> <Grid RowDefinitions="20,20,20,20" ColumnDefinitions="80,*">
<TextBlock Grid.Row="0" Grid.Column="0" Classes="monospace bold" Text="Ctrl+T"/> <TextBlock Grid.Row="0" Grid.Column="0" Classes="monospace bold" Text="{OnPlatform Ctrl+T, macOS=⌘+T}"/>
<TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.NewTab}" /> <TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.NewTab}" />
<TextBlock Grid.Row="1" Grid.Column="0" Classes="monospace bold" Text="Ctrl+W" /> <TextBlock Grid.Row="1" Grid.Column="0" Classes="monospace bold" Text="{OnPlatform Ctrl+W, macOS=⌘+W}" />
<TextBlock Grid.Row="1" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.CloseTab}" /> <TextBlock Grid.Row="1" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.CloseTab}" />
<TextBlock Grid.Row="2" Grid.Column="0" Classes="monospace bold" Text="Ctrl+Tab"/> <TextBlock Grid.Row="2" Grid.Column="0" Classes="monospace bold" Text="{OnPlatform Ctrl+Tab, macOS=⌘+⌥+>}"/>
<TextBlock Grid.Row="2" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.GotoNextTab}" /> <TextBlock Grid.Row="2" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.GotoNextTab}" />
<TextBlock Grid.Row="3" Grid.Column="0" Classes="monospace bold" Text="ESC"/> <TextBlock Grid.Row="3" Grid.Column="0" Classes="monospace bold" Text="ESC"/>
@ -88,19 +88,19 @@
Margin="0,8"/> Margin="0,8"/>
<Grid RowDefinitions="20,20,20,20,20,20" ColumnDefinitions="80,*"> <Grid RowDefinitions="20,20,20,20,20,20" ColumnDefinitions="80,*">
<TextBlock Grid.Row="0" Grid.Column="0" Classes="monospace bold" Text="Ctrl+F"/> <TextBlock Grid.Row="0" Grid.Column="0" Classes="monospace bold" Text="{OnPlatform Ctrl+F, macOS=⌘+F}"/>
<TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.ToggleSearch}" /> <TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.ToggleSearch}" />
<TextBlock Grid.Row="1" Grid.Column="0" Classes="monospace bold" Text="Ctrl+1"/> <TextBlock Grid.Row="1" Grid.Column="0" Classes="monospace bold" Text="{OnPlatform Ctrl+1, macOS=⌘+1}"/>
<TextBlock Grid.Row="1" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.ViewHistories}" /> <TextBlock Grid.Row="1" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.ViewHistories}" />
<TextBlock Grid.Row="2" Grid.Column="0" Classes="monospace bold" Text="Ctrl+2"/> <TextBlock Grid.Row="2" Grid.Column="0" Classes="monospace bold" Text="{OnPlatform Ctrl+2, macOS=⌘+2}"/>
<TextBlock Grid.Row="2" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.ViewChanges}" /> <TextBlock Grid.Row="2" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.ViewChanges}" />
<TextBlock Grid.Row="3" Grid.Column="0" Classes="monospace bold" Text="Ctrl+3"/> <TextBlock Grid.Row="3" Grid.Column="0" Classes="monospace bold" Text="{OnPlatform Ctrl+3, macOS=⌘+3}"/>
<TextBlock Grid.Row="3" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.ViewStashes}" /> <TextBlock Grid.Row="3" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.ViewStashes}" />
<TextBlock Grid.Row="4" Grid.Column="0" Classes="monospace bold" Text="SPACE"/> <TextBlock Grid.Row="4" Grid.Column="0" Classes="monospace bold" Text="Space"/>
<TextBlock Grid.Row="4" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.StageOrUnstageSelected}" /> <TextBlock Grid.Row="4" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.StageOrUnstageSelected}" />
<TextBlock Grid.Row="5" Grid.Column="0" Classes="monospace bold" Text="F5"/> <TextBlock Grid.Row="5" Grid.Column="0" Classes="monospace bold" Text="F5"/>
@ -114,10 +114,10 @@
Margin="0,8"/> Margin="0,8"/>
<Grid RowDefinitions="20,20,20,20" ColumnDefinitions="80,*"> <Grid RowDefinitions="20,20,20,20" ColumnDefinitions="80,*">
<TextBlock Grid.Row="0" Grid.Column="0" Classes="monospace bold" Text="Ctrl+F"/> <TextBlock Grid.Row="0" Grid.Column="0" Classes="monospace bold" Text="{OnPlatform Ctrl+F, macOS=⌘+F}"/>
<TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.TextEditor.Search}" /> <TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.TextEditor.Search}" />
<TextBlock Grid.Row="1" Grid.Column="0" Classes="monospace bold" Text="Shift+F3"/> <TextBlock Grid.Row="1" Grid.Column="0" Classes="monospace bold" Text="{OnPlatform Shift+F3, macOS=⇧+F3}"/>
<TextBlock Grid.Row="1" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.TextEditor.GotoPrevMatch}" /> <TextBlock Grid.Row="1" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.TextEditor.GotoPrevMatch}" />
<TextBlock Grid.Row="2" Grid.Column="0" Classes="monospace bold" Text="F3"/> <TextBlock Grid.Row="2" Grid.Column="0" Classes="monospace bold" Text="F3"/>

View file

@ -203,7 +203,7 @@
<ToolTip.Tip> <ToolTip.Tip>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="{DynamicResource Text.PageTabBar.Tab.Close}" VerticalAlignment="Center"/> <TextBlock Text="{DynamicResource Text.PageTabBar.Tab.Close}" VerticalAlignment="Center"/>
<TextBlock Margin="16,0,0,0" Text="Ctrl+W" Opacity=".6" FontSize="11" VerticalAlignment="Center"/> <TextBlock Margin="16,0,0,0" Text="{OnPlatform Ctrl+W, macOS=⌘+W}" Opacity=".6" FontSize="11" VerticalAlignment="Center"/>
</StackPanel> </StackPanel>
</ToolTip.Tip> </ToolTip.Tip>
<Path Width="8" Height="8" Data="{StaticResource Icons.Window.Close}"/> <Path Width="8" Height="8" Data="{StaticResource Icons.Window.Close}"/>
@ -226,12 +226,11 @@
<Button Classes="icon_button" <Button Classes="icon_button"
Width="16" Height="16" Width="16" Height="16"
Margin="8,0" Margin="8,0"
Command="{Binding AddNewTab}" Command="{Binding AddNewTab}">
HotKey="Ctrl+T">
<ToolTip.Tip> <ToolTip.Tip>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="{DynamicResource Text.PageTabBar.New}" VerticalAlignment="Center"/> <TextBlock Text="{DynamicResource Text.PageTabBar.New}" VerticalAlignment="Center"/>
<TextBlock Margin="16,0,0,0" Text="Ctrl+T" Opacity=".6" FontSize="11" VerticalAlignment="Center"/> <TextBlock Margin="16,0,0,0" Text="{OnPlatform Ctrl+T, macOS=⌘+T}" Opacity=".6" FontSize="11" VerticalAlignment="Center"/>
</StackPanel> </StackPanel>
</ToolTip.Tip> </ToolTip.Tip>

View file

@ -98,7 +98,8 @@ namespace SourceGit.Views
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)
{ {
var vm = DataContext as ViewModels.Launcher; var vm = DataContext as ViewModels.Launcher;
if (e.KeyModifiers.HasFlag(KeyModifiers.Control)) if ((OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Meta)) ||
(!OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Control)))
{ {
if (e.Key == Key.W) if (e.Key == Key.W)
{ {
@ -106,7 +107,14 @@ namespace SourceGit.Views
e.Handled = true; e.Handled = true;
return; return;
} }
else if (e.Key == Key.Tab) else if (e.Key == Key.T)
{
vm.AddNewTab();
e.Handled = true;
return;
}
else if ((OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Alt) && e.Key == Key.Right) ||
(!OperatingSystem.IsMacOS() && e.Key == Key.Tab))
{ {
vm.GotoNextTab(); vm.GotoNextTab();
e.Handled = true; e.Handled = true;

View file

@ -32,7 +32,7 @@
<ToolTip.Tip> <ToolTip.Tip>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="{DynamicResource Text.Repository.Search}" VerticalAlignment="Center"/> <TextBlock Text="{DynamicResource Text.Repository.Search}" VerticalAlignment="Center"/>
<TextBlock Margin="16,0,0,0" Text="Ctrl+F" Opacity=".6" FontSize="11" VerticalAlignment="Center"/> <TextBlock Margin="16,0,0,0" Text="{OnPlatform Ctrl+F, macOS=⌘+F}" Opacity=".6" FontSize="11" VerticalAlignment="Center"/>
</StackPanel> </StackPanel>
</ToolTip.Tip> </ToolTip.Tip>
<Path Width="14" Height="14" Data="{StaticResource Icons.Search}"/> <Path Width="14" Height="14" Data="{StaticResource Icons.Search}"/>

View file

@ -47,7 +47,7 @@
<ToolTip.Tip> <ToolTip.Tip>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="{DynamicResource Text.WorkingCopy.Unstaged.Stage}" VerticalAlignment="Center"/> <TextBlock Text="{DynamicResource Text.WorkingCopy.Unstaged.Stage}" VerticalAlignment="Center"/>
<TextBlock Margin="16,0,0,0" Text="SPACE" Opacity=".6" FontSize="11" VerticalAlignment="Center"/> <TextBlock Margin="16,0,0,0" Text="Space" Opacity=".6" FontSize="11" VerticalAlignment="Center"/>
</StackPanel> </StackPanel>
</ToolTip.Tip> </ToolTip.Tip>
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/> <Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/>
@ -183,7 +183,7 @@
<ToolTip.Tip> <ToolTip.Tip>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="{DynamicResource Text.WorkingCopy.Staged.Unstage}" VerticalAlignment="Center"/> <TextBlock Text="{DynamicResource Text.WorkingCopy.Staged.Unstage}" VerticalAlignment="Center"/>
<TextBlock Margin="16,0,0,0" Text="SPACE" Opacity=".6" FontSize="11" VerticalAlignment="Center"/> <TextBlock Margin="16,0,0,0" Text="Space" Opacity=".6" FontSize="11" VerticalAlignment="Center"/>
</StackPanel> </StackPanel>
</ToolTip.Tip> </ToolTip.Tip>
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/> <Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>