mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-25 22:25:00 +00:00
feature: hotkeys enhancement. see issue #19
This commit is contained in:
parent
b309c1c346
commit
acb74a4b95
8 changed files with 167 additions and 13 deletions
92
src/Views/Hotkeys.axaml
Normal file
92
src/Views/Hotkeys.axaml
Normal file
|
@ -0,0 +1,92 @@
|
|||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:SourceGit.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.Hotkeys"
|
||||
Icon="/App.ico"
|
||||
Title="{DynamicResource Text.Hotkeys}"
|
||||
Background="{DynamicResource Brush.Window}"
|
||||
SizeToContent="WidthAndHeight"
|
||||
CanResize="False"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ExtendClientAreaToDecorationsHint="True"
|
||||
ExtendClientAreaChromeHints="NoChrome">
|
||||
<Grid RowDefinitions="30,*">
|
||||
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto">
|
||||
<Path Grid.Column="0"
|
||||
Width="14" Height="14"
|
||||
Margin="10,0,0,0"
|
||||
Data="{StaticResource Icons.Hotkeys}"
|
||||
IsVisible="{Binding Source={x:Static vm:Preference.Instance}, Path=UseMacOSStyle, Converter={x:Static BoolConverters.Not}}"/>
|
||||
|
||||
<Grid Grid.Column="0" Classes="caption_button_box" Margin="2,4,0,0" IsVisible="{Binding Source={x:Static vm:Preference.Instance}, Path=UseMacOSStyle}">
|
||||
<Button Classes="caption_button_macos" Click="CloseWindow">
|
||||
<Grid>
|
||||
<Ellipse Fill="{DynamicResource Brush.MacOS.Close}"/>
|
||||
<Path Height="6" Width="6" Stretch="Fill" Fill="#404040" Stroke="#404040" StrokeThickness="1" Data="{StaticResource Icons.Window.Close}"/>
|
||||
</Grid>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
|
||||
Classes="bold"
|
||||
Text="{DynamicResource Text.Hotkeys}"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
IsHitTestVisible="False"/>
|
||||
|
||||
<Button Grid.Column="2"
|
||||
Classes="caption_button"
|
||||
Click="CloseWindow"
|
||||
IsVisible="{Binding Source={x:Static vm:Preference.Instance}, Path=UseMacOSStyle, Converter={x:Static BoolConverters.Not}}">
|
||||
<Path Data="{StaticResource Icons.Window.Close}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="16,8,16,16">
|
||||
<TextBlock Text="{DynamicResource Text.Hotkeys.Global}"
|
||||
Foreground="{DynamicResource Brush.FG2}"
|
||||
FontWeight="Bold"
|
||||
FontSize="13"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<Grid RowDefinitions="Auto,Auto,Auto,Auto" ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Ctrl+T" FontFamily="{StaticResource JetBrainsMono}"/>
|
||||
<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" Text="Ctrl+W" FontFamily="{StaticResource JetBrainsMono}"/>
|
||||
<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" Text="Ctrl+Tab" FontFamily="{StaticResource JetBrainsMono}"/>
|
||||
<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" Text="ESC" FontFamily="{StaticResource JetBrainsMono}"/>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.CancelPopup}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="{DynamicResource Text.Hotkeys.Repo}"
|
||||
Foreground="{DynamicResource Brush.FG2}"
|
||||
FontWeight="Bold"
|
||||
FontSize="13"
|
||||
Margin="0,8"/>
|
||||
|
||||
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto" ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Ctrl+F" FontFamily="{StaticResource JetBrainsMono}"/>
|
||||
<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" Text="Ctrl+1" FontFamily="{StaticResource JetBrainsMono}"/>
|
||||
<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" Text="Ctrl+2" FontFamily="{StaticResource JetBrainsMono}"/>
|
||||
<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" Text="Ctrl+3" FontFamily="{StaticResource JetBrainsMono}"/>
|
||||
<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" Text="SPACE" FontFamily="{StaticResource JetBrainsMono}"/>
|
||||
<TextBlock Grid.Row="4" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.StageOrUnstageSelected}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
14
src/Views/Hotkeys.axaml.cs
Normal file
14
src/Views/Hotkeys.axaml.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views {
|
||||
public partial class Hotkeys : Window {
|
||||
public Hotkeys() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void CloseWindow(object sender, RoutedEventArgs e) {
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,6 +47,11 @@
|
|||
<Path Width="14" Height="14" Data="{StaticResource Icons.Settings2}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="{DynamicResource Text.Hotkeys}" Click="OpenHotkeys">
|
||||
<MenuItem.Icon>
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Hotkeys}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="{DynamicResource Text.About}" Click="OpenAboutDialog">
|
||||
<MenuItem.Icon>
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Info}"/>
|
||||
|
@ -212,6 +217,10 @@
|
|||
<Path Width="16" Height="16" Data="{StaticResource Icons.Settings2}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Height="28" Click="OpenHotkeys" ToolTip.Tip="{DynamicResource Text.Hotkeys}">
|
||||
<Path Width="16" Height="16" Data="{StaticResource Icons.Hotkeys}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Height="28" Click="OpenAboutDialog" ToolTip.Tip="{DynamicResource Text.About}">
|
||||
<Path Width="16" Height="16" Data="{StaticResource Icons.Info}"/>
|
||||
</Button>
|
||||
|
|
|
@ -82,7 +82,25 @@ namespace SourceGit.Views {
|
|||
vm.GotoNextTab();
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
} else if (vm.ActivePage.Data is ViewModels.Repository repo) {
|
||||
if (e.Key == Key.D1 || e.Key == Key.NumPad1) {
|
||||
repo.SelectedViewIndex = 0;
|
||||
e.Handled = true;
|
||||
return;
|
||||
} else if (e.Key == Key.D2 || e.Key == Key.NumPad2) {
|
||||
repo.SelectedViewIndex = 1;
|
||||
e.Handled = true;
|
||||
return;
|
||||
} else if (e.Key == Key.D3 || e.Key == Key.NumPad3) {
|
||||
repo.SelectedViewIndex = 2;
|
||||
e.Handled = true;
|
||||
return;
|
||||
} else if (e.Key == Key.F) {
|
||||
repo.IsSearching = !repo.IsSearching;
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (e.Key == Key.Escape) {
|
||||
vm.ActivePage.CancelPopup();
|
||||
e.Handled = true;
|
||||
|
@ -213,6 +231,12 @@ namespace SourceGit.Views {
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private async void OpenHotkeys(object sender, RoutedEventArgs e) {
|
||||
var dialog = new Hotkeys();
|
||||
await dialog.ShowDialog(this);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private async void OpenAboutDialog(object sender, RoutedEventArgs e) {
|
||||
var dialog = new About();
|
||||
await dialog.ShowDialog(this);
|
||||
|
|
|
@ -45,18 +45,6 @@ namespace SourceGit.Views {
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e) {
|
||||
if (e.Key == Key.F && e.KeyModifiers == KeyModifiers.Control) {
|
||||
if (DataContext is ViewModels.Repository repo) {
|
||||
repo.IsSearching = true;
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
private void OnLocalBranchTreeLostFocus(object sender, RoutedEventArgs e) {
|
||||
if (sender is TreeView tree) tree.UnselectAll();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue