Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add DuplicateCustomAction(fixes #1632)
  • Loading branch information
heartacker committed Aug 4, 2025
commit f5418e1bd4bcae1322d37f5e08256a904179380e
35 changes: 35 additions & 0 deletions src/Models/CustomAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ public enum CustomActionControlType

public class CustomActionControl : ObservableObject
{
public CustomActionControl()
{
}

public CustomActionControl(CustomActionControl cac)
{
if (cac != null)
{
Type = cac.Type;
Description = cac.Description;
Label = cac.Label;
Description = cac.Description;
StringValue = cac.StringValue;
BoolValue = cac.BoolValue;
}
}

public CustomActionControlType Type
{
get => _type;
Expand Down Expand Up @@ -60,6 +77,24 @@ public bool BoolValue

public class CustomAction : ObservableObject
{
public CustomAction()
{
}

public CustomAction(CustomAction action)
{
if (action != null)
{
Name = action.Name;
Scope = action.Scope;
Executable = action.Executable;
Arguments = action.Arguments;
WaitForExit = action.WaitForExit;
foreach (var control in action.Controls)
Controls.Add(new CustomActionControl(control));
}
}

public string Name
{
get => _name;
Expand Down
10 changes: 10 additions & 0 deletions src/Models/RepositorySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ public CustomAction AddNewCustomAction()
return act;
}

public CustomAction DuplicateCustomAction(CustomAction baseAct)
{
var act = new CustomAction(baseAct)
{
Name = baseAct.Name + "(Duplicated)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest something like this (to match Windows Explorer behaviour), but use localizable string "{0} - Copy":

Suggested change
Name = baseAct.Name + "(Duplicated)"
Name = baseAct.Name + " - Copy"

};
CustomActions.Add(act);
return act;
}

public void RemoveCustomAction(CustomAction act)
{
if (act != null)
Expand Down
5 changes: 5 additions & 0 deletions src/ViewModels/RepositoryConfigure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ public void RemoveSelectedCustomAction()
SelectedCustomAction = null;
}

public void DuplicateSelectedCustomAction()
{
SelectedCustomAction = _repo.Settings.DuplicateCustomAction(_selectedCustomAction);
}

public void MoveSelectedCustomActionUp()
{
if (_selectedCustomAction != null)
Expand Down
12 changes: 9 additions & 3 deletions src/Views/RepositoryConfigure.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@

<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>

<Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
<Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
<Button Grid.Column="0"
Classes="icon_button"
Width="28" Height="28"
Expand All @@ -437,14 +437,20 @@
Command="{Binding RemoveSelectedCustomAction}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Minus}"/>
</Button>
<Button Grid.Column="3"
<Button Grid.Column="2"
Classes="icon_button"
Width="28" Height="28"
Command="{Binding DuplicateSelectedCustomAction}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Copy}"/>
</Button>
<Button Grid.Column="4"
Classes="icon_button"
Width="28" Height="28"
Command="{Binding MoveSelectedCustomActionUp}"
IsVisible="{Binding SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>
</Button>
<Button Grid.Column="4"
<Button Grid.Column="5"
Classes="icon_button"
Width="28" Height="28"
Command="{Binding MoveSelectedCustomActionDown}"
Expand Down