mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-23 10:22:13 +08:00
feature: allows to go back to repository command palette from sub command
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -9,16 +9,15 @@
|
||||
x:Class="SourceGit.Views.BlameCommandPalette"
|
||||
x:DataType="vm:BlameCommandPalette">
|
||||
<Grid RowDefinitions="Auto,Auto">
|
||||
<TextBox Grid.Row="0"
|
||||
x:Name="FilterTextBox"
|
||||
Height="24"
|
||||
Margin="4,8,4,0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12"
|
||||
Text="{Binding Filter, Mode=TwoWay}"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
VerticalContentAlignment="Center"
|
||||
v:AutoFocusBehaviour.IsEnabled="True">
|
||||
<v:RepositoryCommandPaletteTextBox Grid.Row="0"
|
||||
x:Name="FilterTextBox"
|
||||
Height="24"
|
||||
Margin="4,8,4,0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12"
|
||||
Text="{Binding Filter, Mode=TwoWay}"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
VerticalContentAlignment="Center">
|
||||
<TextBox.InnerLeftContent>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="14" Height="14"
|
||||
@@ -29,7 +28,7 @@
|
||||
Background="{DynamicResource Brush.Badge}"
|
||||
Height="18"
|
||||
CornerRadius="4"
|
||||
Margin="4,0" Padding="4,0">
|
||||
Margin="4,0,0,0" Padding="4,0">
|
||||
<TextBlock Text="{DynamicResource Text.Blame}"
|
||||
Foreground="Black"
|
||||
FontWeight="Bold"/>
|
||||
@@ -50,7 +49,7 @@
|
||||
Data="{StaticResource Icons.Clear}"/>
|
||||
</Button>
|
||||
</TextBox.InnerRightContent>
|
||||
</TextBox>
|
||||
</v:RepositoryCommandPaletteTextBox>
|
||||
|
||||
<ListBox Grid.Row="1"
|
||||
x:Name="FileListBox"
|
||||
|
||||
@@ -9,16 +9,15 @@
|
||||
x:Class="SourceGit.Views.FileHistoryCommandPalette"
|
||||
x:DataType="vm:FileHistoryCommandPalette">
|
||||
<Grid RowDefinitions="Auto,Auto">
|
||||
<TextBox Grid.Row="0"
|
||||
x:Name="FilterTextBox"
|
||||
Height="24"
|
||||
Margin="4,8,4,0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12"
|
||||
Text="{Binding Filter, Mode=TwoWay}"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
VerticalContentAlignment="Center"
|
||||
v:AutoFocusBehaviour.IsEnabled="True">
|
||||
<v:RepositoryCommandPaletteTextBox Grid.Row="0"
|
||||
x:Name="FilterTextBox"
|
||||
Height="24"
|
||||
Margin="4,8,4,0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12"
|
||||
Text="{Binding Filter, Mode=TwoWay}"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
VerticalContentAlignment="Center">
|
||||
<TextBox.InnerLeftContent>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="14" Height="14"
|
||||
@@ -29,7 +28,7 @@
|
||||
Background="{DynamicResource Brush.Badge}"
|
||||
Height="18"
|
||||
CornerRadius="4"
|
||||
Margin="4,0" Padding="4,0">
|
||||
Margin="4,0,0,0" Padding="4,0">
|
||||
<TextBlock Text="{DynamicResource Text.FileHistory}"
|
||||
Foreground="Black"
|
||||
FontWeight="Bold"/>
|
||||
@@ -50,7 +49,7 @@
|
||||
Data="{StaticResource Icons.Clear}"/>
|
||||
</Button>
|
||||
</TextBox.InnerRightContent>
|
||||
</TextBox>
|
||||
</v:RepositoryCommandPaletteTextBox>
|
||||
|
||||
<ListBox Grid.Row="1"
|
||||
x:Name="FileListBox"
|
||||
|
||||
@@ -10,16 +10,15 @@
|
||||
x:Class="SourceGit.Views.MergeCommandPalette"
|
||||
x:DataType="vm:MergeCommandPalette">
|
||||
<Grid RowDefinitions="Auto,Auto">
|
||||
<TextBox Grid.Row="0"
|
||||
x:Name="FilterTextBox"
|
||||
Height="24"
|
||||
Margin="4,8,4,0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12"
|
||||
Text="{Binding Filter, Mode=TwoWay}"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
VerticalContentAlignment="Center"
|
||||
v:AutoFocusBehaviour.IsEnabled="True">
|
||||
<v:RepositoryCommandPaletteTextBox Grid.Row="0"
|
||||
x:Name="FilterTextBox"
|
||||
Height="24"
|
||||
Margin="4,8,4,0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12"
|
||||
Text="{Binding Filter, Mode=TwoWay}"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
VerticalContentAlignment="Center">
|
||||
<TextBox.InnerLeftContent>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="14" Height="14"
|
||||
@@ -30,7 +29,7 @@
|
||||
Background="{DynamicResource Brush.Badge}"
|
||||
Height="18"
|
||||
CornerRadius="4"
|
||||
Margin="4,0" Padding="4,0">
|
||||
Margin="4,0,0,0" Padding="4,0">
|
||||
<TextBlock Text="{DynamicResource Text.Merge}"
|
||||
Foreground="Black"
|
||||
FontWeight="Bold"/>
|
||||
@@ -51,7 +50,7 @@
|
||||
Data="{StaticResource Icons.Clear}"/>
|
||||
</Button>
|
||||
</TextBox.InnerRightContent>
|
||||
</TextBox>
|
||||
</v:RepositoryCommandPaletteTextBox>
|
||||
|
||||
<ListBox Grid.Row="1"
|
||||
x:Name="BranchListBox"
|
||||
|
||||
36
src/Views/RepositoryCommandPaletteTextBox.cs
Normal file
36
src/Views/RepositoryCommandPaletteTextBox.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public class RepositoryCommandPaletteTextBox : TextBox
|
||||
{
|
||||
protected override Type StyleKeyOverride => typeof(TextBox);
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Back && string.IsNullOrEmpty(Text))
|
||||
{
|
||||
var launcherView = this.FindAncestorOfType<Launcher>(false);
|
||||
if (launcherView is { DataContext: ViewModels.Launcher launcher } &&
|
||||
launcher.ActivePage is { Data: ViewModels.Repository repo })
|
||||
{
|
||||
launcher.OpenCommandPalette(new ViewModels.RepositoryCommandPalette(launcher, repo));
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user