mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
Adding hotkeys for creating branch, pushing and pulling (#657)
This commit is contained in:
parent
fdf30aa7cc
commit
2e6eca26f7
5 changed files with 47 additions and 12 deletions
|
@ -371,6 +371,9 @@
|
|||
<x:String x:Key="Text.Hotkeys.Repo.ViewChanges" xml:space="preserve">Switch to 'Changes'</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.ViewHistories" xml:space="preserve">Switch to 'Histories'</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.ViewStashes" xml:space="preserve">Switch to 'Stashes'</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.Pull" xml:space="preserve">Pull, starts directly</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.Push" xml:space="preserve">Push, starts directly</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.CreateBranchOnCommit" xml:space="preserve">Creates a new branch based on selected commit</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.TextEditor" xml:space="preserve">TEXT EDITOR</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.TextEditor.CloseSearch" xml:space="preserve">Close search panel</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.TextEditor.GotoNextMatch" xml:space="preserve">Find next match</x:String>
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Platform.Storage;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
@ -544,6 +545,7 @@ namespace SourceGit.ViewModels
|
|||
var createBranch = new MenuItem();
|
||||
createBranch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
|
||||
createBranch.Header = App.Text("CreateBranch");
|
||||
createBranch.HotKey = new KeyGesture(Key.B, KeyModifiers.Control);
|
||||
createBranch.Click += (_, e) =>
|
||||
{
|
||||
if (PopupHost.CanCreatePopup())
|
||||
|
|
|
@ -12,6 +12,7 @@ using Avalonia.Interactivity;
|
|||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
using SourceGit.ViewModels;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
|
@ -722,9 +723,12 @@ namespace SourceGit.Views
|
|||
|
||||
private void OnCommitListKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
// These shortcuts are not mentioned in the Shortcut Reference window. Is this expected?
|
||||
if (sender is ListBox { SelectedItems: { Count: > 0 } selected } &&
|
||||
e.Key == Key.C &&
|
||||
e.KeyModifiers.HasFlag(KeyModifiers.Control))
|
||||
{
|
||||
// CTRL + C -> Copy selected commit SHA and subject.
|
||||
if (e.Key == Key.C)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
foreach (var item in selected)
|
||||
|
@ -735,6 +739,22 @@ namespace SourceGit.Views
|
|||
|
||||
App.CopyText(builder.ToString());
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// CTRL + B -> shows Create Branch pop-up at selected commit.
|
||||
if (e.Key == Key.B)
|
||||
{
|
||||
if (selected.Count == 1 &&
|
||||
selected[0] is Models.Commit commit &&
|
||||
DataContext is ViewModels.Histories histories &&
|
||||
PopupHost.CanCreatePopup())
|
||||
{
|
||||
PopupHost.ShowPopup(new ViewModels.CreateBranch(histories.Repo, commit));
|
||||
e.Handled = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Increase}}"
|
||||
Margin="0,8"/>
|
||||
|
||||
<Grid RowDefinitions="20,20,20,20,20,20,20,20,20,20,20" ColumnDefinitions="150,*">
|
||||
<Grid RowDefinitions="20,20,20,20,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+H, macOS=⌘+⇧+H}"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.GoHome}" />
|
||||
|
||||
|
@ -102,8 +102,17 @@
|
|||
<TextBlock Grid.Row="9" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Alt+Enter, macOS=⌥+Enter}"/>
|
||||
<TextBlock Grid.Row="9" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.CommitAndPush}" />
|
||||
|
||||
<TextBlock Grid.Row="10" Grid.Column="0" Classes="primary bold" Text="F5"/>
|
||||
<TextBlock Grid.Row="10" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.Refresh}" />
|
||||
<TextBlock Grid.Row="10" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+Down, macOS=⌘+Shift+Down}"/>
|
||||
<TextBlock Grid.Row="10" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.Pull}" />
|
||||
|
||||
<TextBlock Grid.Row="11" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+Up, macOS=⌘+Shift+Up}"/>
|
||||
<TextBlock Grid.Row="11" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.Push}" />
|
||||
|
||||
<TextBlock Grid.Row="12" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+B, macOS=⌘+B}"/>
|
||||
<TextBlock Grid.Row="12" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.CreateBranchOnCommit}" />
|
||||
|
||||
<TextBlock Grid.Row="13" Grid.Column="0" Classes="primary bold" Text="F5"/>
|
||||
<TextBlock Grid.Row="13" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.Refresh}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="{DynamicResource Text.Hotkeys.TextEditor}"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<Path Width="14" Height="14" Data="{StaticResource Icons.Fetch}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Click="Pull">
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Click="Pull" HotKey="{OnPlatform Ctrl+Shift+Down, macOS=⌘+Shift+Down}">
|
||||
<ToolTip.Tip>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="{DynamicResource Text.Pull}"/>
|
||||
|
@ -53,7 +53,7 @@
|
|||
<Path Width="14" Height="14" Data="{StaticResource Icons.Pull}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Click="Push">
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Click="Push" HotKey="{OnPlatform Ctrl+Shift+Up, macOS=⌘+Shift+Up}">
|
||||
<ToolTip.Tip>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="{DynamicResource Text.Push}"/>
|
||||
|
@ -85,6 +85,7 @@
|
|||
Fill="{DynamicResource Brush.Border2}"/>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Command="{Binding CreateNewBranch}" ToolTip.Tip="{DynamicResource Text.Repository.NewBranch}">
|
||||
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Branch.Add}"/>
|
||||
</Button>
|
||||
|
||||
|
|
Loading…
Reference in a new issue