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.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.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.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" 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.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>
|
<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 System.Text;
|
||||||
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
@ -544,6 +545,7 @@ namespace SourceGit.ViewModels
|
||||||
var createBranch = new MenuItem();
|
var createBranch = new MenuItem();
|
||||||
createBranch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
|
createBranch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
|
||||||
createBranch.Header = App.Text("CreateBranch");
|
createBranch.Header = App.Text("CreateBranch");
|
||||||
|
createBranch.HotKey = new KeyGesture(Key.B, KeyModifiers.Control);
|
||||||
createBranch.Click += (_, e) =>
|
createBranch.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
|
|
|
@ -12,6 +12,7 @@ using Avalonia.Interactivity;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Avalonia.VisualTree;
|
using Avalonia.VisualTree;
|
||||||
|
using SourceGit.ViewModels;
|
||||||
|
|
||||||
namespace SourceGit.Views
|
namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
|
@ -722,19 +723,38 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
private void OnCommitListKeyDown(object sender, KeyEventArgs e)
|
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 } &&
|
if (sender is ListBox { SelectedItems: { Count: > 0 } selected } &&
|
||||||
e.Key == Key.C &&
|
|
||||||
e.KeyModifiers.HasFlag(KeyModifiers.Control))
|
e.KeyModifiers.HasFlag(KeyModifiers.Control))
|
||||||
{
|
{
|
||||||
var builder = new StringBuilder();
|
// CTRL + C -> Copy selected commit SHA and subject.
|
||||||
foreach (var item in selected)
|
if (e.Key == Key.C)
|
||||||
{
|
{
|
||||||
if (item is Models.Commit commit)
|
var builder = new StringBuilder();
|
||||||
builder.AppendLine($"{commit.SHA.Substring(0, 10)} - {commit.Subject}");
|
foreach (var item in selected)
|
||||||
|
{
|
||||||
|
if (item is Models.Commit commit)
|
||||||
|
builder.AppendLine($"{commit.SHA.Substring(0, 10)} - {commit.Subject}");
|
||||||
|
}
|
||||||
|
|
||||||
|
App.CopyText(builder.ToString());
|
||||||
|
e.Handled = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
App.CopyText(builder.ToString());
|
// CTRL + B -> shows Create Branch pop-up at selected commit.
|
||||||
e.Handled = true;
|
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}}"
|
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Increase}}"
|
||||||
Margin="0,8"/>
|
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="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}" />
|
<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="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="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="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.Refresh}" />
|
<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>
|
</Grid>
|
||||||
|
|
||||||
<TextBlock Text="{DynamicResource Text.Hotkeys.TextEditor}"
|
<TextBlock Text="{DynamicResource Text.Hotkeys.TextEditor}"
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Fetch}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Fetch}"/>
|
||||||
</Button>
|
</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>
|
<ToolTip.Tip>
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<TextBlock Text="{DynamicResource Text.Pull}"/>
|
<TextBlock Text="{DynamicResource Text.Pull}"/>
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Pull}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Pull}"/>
|
||||||
</Button>
|
</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>
|
<ToolTip.Tip>
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<TextBlock Text="{DynamicResource Text.Push}"/>
|
<TextBlock Text="{DynamicResource Text.Push}"/>
|
||||||
|
@ -85,6 +85,7 @@
|
||||||
Fill="{DynamicResource Brush.Border2}"/>
|
Fill="{DynamicResource Brush.Border2}"/>
|
||||||
|
|
||||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Command="{Binding CreateNewBranch}" ToolTip.Tip="{DynamicResource Text.Repository.NewBranch}">
|
<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}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Branch.Add}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue