feature: supports custom actions (#638)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-01 17:23:31 +08:00
parent 7c5de7e48c
commit a36058ec51
No known key found for this signature in database
17 changed files with 478 additions and 2 deletions

View file

@ -1,4 +1,6 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
namespace SourceGit.Views
{
@ -14,5 +16,20 @@ namespace SourceGit.Views
(DataContext as ViewModels.RepositoryConfigure)?.Save();
base.OnClosing(e);
}
private async void SelectExecutableForCustomAction(object sender, RoutedEventArgs e)
{
var options = new FilePickerOpenOptions()
{
FileTypeFilter = [new FilePickerFileType("Executable file(script)") { Patterns = ["*.*"] }],
AllowMultiple = false,
};
var selected = await StorageProvider.OpenFilePickerAsync(options);
if (selected.Count == 1 && sender is Button { DataContext: Models.CustomAction action })
action.Executable = selected[0].Path.LocalPath;
e.Handled = true;
}
}
}