mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
feature: supports custom actions (#638)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
7c5de7e48c
commit
a36058ec51
17 changed files with 478 additions and 2 deletions
|
@ -1287,6 +1287,45 @@ namespace SourceGit.ViewModels
|
|||
return menu;
|
||||
}
|
||||
|
||||
public ContextMenu CreateContextMenuForCustomAction()
|
||||
{
|
||||
var actions = new List<Models.CustomAction>();
|
||||
foreach (var action in _settings.CustomActions)
|
||||
{
|
||||
if (action.Scope == Models.CustomActionScope.Repository)
|
||||
actions.Add(action);
|
||||
}
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Placement = PlacementMode.BottomEdgeAlignedLeft;
|
||||
|
||||
if (actions.Count > 0)
|
||||
{
|
||||
foreach (var action in actions)
|
||||
{
|
||||
var dup = action;
|
||||
var item = new MenuItem();
|
||||
item.Icon = App.CreateMenuIcon("Icons.Action");
|
||||
item.Header = dup.Name;
|
||||
item.Click += (_, e) =>
|
||||
{
|
||||
if (PopupHost.CanCreatePopup())
|
||||
PopupHost.ShowAndStartPopup(new ExecuteCustomAction(this, action, null));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.Items.Add(new MenuItem() { Header = App.Text("Repository.CustomActions.Empty") });
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
public ContextMenu CreateContextMenuForLocalBranch(Models.Branch branch)
|
||||
{
|
||||
var menu = new ContextMenu();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue