Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Resources/Locales/en_US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,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>
Expand Down
2 changes: 2 additions & 0 deletions src/ViewModels/Histories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;

using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Platform.Storage;

using CommunityToolkit.Mvvm.ComponentModel;
Expand Down Expand Up @@ -544,6 +545,7 @@ public ContextMenu MakeContextMenu(ListBox list)
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())
Expand Down
34 changes: 27 additions & 7 deletions src/Views/Histories.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Avalonia.Media;
using Avalonia.Threading;
using Avalonia.VisualTree;
using SourceGit.ViewModels;

namespace SourceGit.Views
{
Expand Down Expand Up @@ -722,19 +723,38 @@ private void OnCommitListDoubleTapped(object sender, TappedEventArgs 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 } &&
e.Key == Key.C &&
e.KeyModifiers.HasFlag(KeyModifiers.Control))
{
var builder = new StringBuilder();
foreach (var item in selected)
// CTRL + C -> Copy selected commit SHA and subject.
if (e.Key == Key.C)
{
if (item is Models.Commit commit)
builder.AppendLine($"{commit.SHA.Substring(0, 10)} - {commit.Subject}");
var builder = new StringBuilder();
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());
e.Handled = true;
// 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;

}
}
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/Views/Hotkeys.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}" />

Expand Down Expand Up @@ -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}"
Expand Down
5 changes: 3 additions & 2 deletions src/Views/RepositoryToolbar.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"/>
Expand All @@ -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}"/>
Expand Down Expand Up @@ -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>

Expand Down