mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-03 18:15:01 +00:00
Added workspaces shortcuts (#1328)
- added Alt+Space for opening Workspaces context menu (which can then be navigated normally with arrows) - added Alt+1 through Alt+9 for switching to corresponding workspace
This commit is contained in:
parent
506dbc218c
commit
01945f231e
5 changed files with 63 additions and 3 deletions
|
@ -45,7 +45,7 @@
|
|||
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Increase}}"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<Grid RowDefinitions="20,20,20,20,20,20,20,20" ColumnDefinitions="150,*">
|
||||
<Grid RowDefinitions="20,20,20,20,20,20,20,20,20,20" ColumnDefinitions="150,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+P, macOS=⌘+\,}"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.OpenPreferences}"/>
|
||||
|
||||
|
@ -69,6 +69,12 @@
|
|||
|
||||
<TextBlock Grid.Row="7" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Q, macOS=⌘+Q}"/>
|
||||
<TextBlock Grid.Row="7" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Quit}" />
|
||||
|
||||
<TextBlock Grid.Row="8" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Alt+Space, macOS=⌥+␣}"/>
|
||||
<TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.OpenWorkspaces}" />
|
||||
|
||||
<TextBlock Grid.Row="9" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Alt+1 - Alt+9, macOS=⌥+1 - ⌥+9}"/>
|
||||
<TextBlock Grid.Row="9" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.OpenWorkspaceAtIndex}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="{DynamicResource Text.Hotkeys.Repo}"
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
</Button>
|
||||
|
||||
<!-- Workspace Switcher -->
|
||||
<Button Grid.Column="1" Classes="icon_button" VerticalAlignment="Bottom" Margin="0,0,0,1" Click="OnOpenWorkspaceMenu">
|
||||
<Button Grid.Column="1" Classes="icon_button" Name="WorkspacesButton" VerticalAlignment="Bottom" Margin="0,0,0,1" Click="OnOpenWorkspaceMenu">
|
||||
<ToolTip.Tip>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{DynamicResource Text.Workspace}" FontWeight="Bold" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
|
|
|
@ -248,6 +248,27 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (e.KeyModifiers.HasFlag(KeyModifiers.Alt))
|
||||
{
|
||||
if (e.Key == Key.Space && DataContext is ViewModels.Launcher launcher)
|
||||
{
|
||||
var menu = launcher.CreateContextForWorkspace();
|
||||
var workspacesButton = this.FindControl<Button>("WorkspacesButton");
|
||||
if (menu != null)
|
||||
{
|
||||
menu.PlacementTarget = workspacesButton;
|
||||
menu.Placement = PlacementMode.BottomEdgeAlignedLeft;
|
||||
menu.Open(workspacesButton);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchToWorkspaceIndex(e.Key);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
else if (e.Key == Key.Escape)
|
||||
{
|
||||
vm.ActivePage.CancelPopup();
|
||||
|
@ -282,6 +303,29 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private void SwitchToWorkspaceIndex(Key eKey)
|
||||
{
|
||||
int newIndex;
|
||||
switch (eKey)
|
||||
{
|
||||
case Key.D1 or Key.NumPad1: newIndex = 0; break;
|
||||
case Key.D2 or Key.NumPad2: newIndex = 1; break;
|
||||
case Key.D3 or Key.NumPad3: newIndex = 2; break;
|
||||
case Key.D4 or Key.NumPad4: newIndex = 3; break;
|
||||
case Key.D5 or Key.NumPad5: newIndex = 4; break;
|
||||
case Key.D6 or Key.NumPad6: newIndex = 5; break;
|
||||
case Key.D7 or Key.NumPad7: newIndex = 6; break;
|
||||
case Key.D8 or Key.NumPad8: newIndex = 7; break;
|
||||
case Key.D9 or Key.NumPad9: newIndex = 8; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
if (DataContext is ViewModels.Launcher launcher)
|
||||
{
|
||||
launcher.SwitchWorkspace(newIndex);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyUp(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyUp(e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue