feature: use Ctrl + click to start fetch/pull/push automatically with default options (#351)

This commit is contained in:
leo 2024-08-12 15:01:00 +08:00
parent 2e12717235
commit 965a4b21ae
No known key found for this signature in database
7 changed files with 78 additions and 9 deletions

View file

@ -1,4 +1,5 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
namespace SourceGit.Views
@ -10,6 +11,18 @@ namespace SourceGit.Views
InitializeComponent();
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
_hasCtrl = e.KeyModifiers.HasFlag(KeyModifiers.Control);
}
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
_hasCtrl = false;
}
private void OpenWithExternalTools(object sender, RoutedEventArgs e)
{
if (sender is Button button && DataContext is ViewModels.Repository repo)
@ -40,6 +53,24 @@ namespace SourceGit.Views
}
}
private void Fetch(object _, RoutedEventArgs e)
{
(DataContext as ViewModels.Repository)?.Fetch(_hasCtrl);
e.Handled = true;
}
private void Pull(object _, RoutedEventArgs e)
{
(DataContext as ViewModels.Repository)?.Pull(_hasCtrl);
e.Handled = true;
}
private void Push(object _, RoutedEventArgs e)
{
(DataContext as ViewModels.Repository)?.Push(_hasCtrl);
e.Handled = true;
}
private void OpenGitFlowMenu(object sender, RoutedEventArgs e)
{
if (DataContext is ViewModels.Repository repo)
@ -61,6 +92,8 @@ namespace SourceGit.Views
e.Handled = true;
}
private bool _hasCtrl = false;
}
}