mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-15 23:54:58 +00:00
feature: supports re-order custom actions (#1346)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
ee2e7d0127
commit
98041c803e
5 changed files with 98 additions and 18 deletions
|
@ -453,5 +453,19 @@ namespace SourceGit.Models
|
||||||
if (act != null)
|
if (act != null)
|
||||||
CustomActions.Remove(act);
|
CustomActions.Remove(act);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MoveCustomActionUp(CustomAction act)
|
||||||
|
{
|
||||||
|
var idx = CustomActions.IndexOf(act);
|
||||||
|
if (idx > 0)
|
||||||
|
CustomActions.Move(idx - 1, idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveCustomActionDown(CustomAction act)
|
||||||
|
{
|
||||||
|
var idx = CustomActions.IndexOf(act);
|
||||||
|
if (idx < CustomActions.Count - 1)
|
||||||
|
CustomActions.Move(idx + 1, idx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,6 +304,18 @@ namespace SourceGit.ViewModels
|
||||||
SelectedCustomAction = null;
|
SelectedCustomAction = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MoveSelectedCustomActionUp()
|
||||||
|
{
|
||||||
|
if (_selectedCustomAction != null)
|
||||||
|
_repo.Settings.MoveCustomActionUp(_selectedCustomAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveSelectedCustomActionDown()
|
||||||
|
{
|
||||||
|
if (_selectedCustomAction != null)
|
||||||
|
_repo.Settings.MoveCustomActionDown(_selectedCustomAction);
|
||||||
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
SetIfChanged("user.name", UserName, "");
|
SetIfChanged("user.name", UserName, "");
|
||||||
|
|
|
@ -583,19 +583,34 @@
|
||||||
|
|
||||||
<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
||||||
|
|
||||||
<StackPanel Grid.Row="2" Orientation="Horizontal" Background="{DynamicResource Brush.ToolBar}">
|
<Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
|
||||||
<Button Classes="icon_button" Click="OnAddCustomAction">
|
<Button Grid.Column="0"
|
||||||
|
Classes="icon_button"
|
||||||
|
Width="28" Height="28"
|
||||||
|
Click="OnAddCustomAction">
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button Grid.Column="1"
|
||||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
Classes="icon_button"
|
||||||
|
Width="28" Height="28"
|
||||||
<Button Classes="icon_button" Click="OnRemoveSelectedCustomAction">
|
Click="OnRemoveSelectedCustomAction">
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Window.Minimize}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Window.Minimize}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button Grid.Column="3"
|
||||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
Classes="icon_button"
|
||||||
</StackPanel>
|
Width="28" Height="28"
|
||||||
|
Click="OnMoveSelectedCustomActionUp"
|
||||||
|
IsVisible="{Binding #ThisControl.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"
|
||||||
|
Classes="icon_button"
|
||||||
|
Width="28" Height="28"
|
||||||
|
Click="OnMoveSelectedCustomActionDown"
|
||||||
|
IsVisible="{Binding #ThisControl.SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||||
|
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|
|
@ -415,6 +415,30 @@ namespace SourceGit.Views
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnMoveSelectedCustomActionUp(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (SelectedCustomAction == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var idx = ViewModels.Preferences.Instance.CustomActions.IndexOf(SelectedCustomAction);
|
||||||
|
if (idx > 0)
|
||||||
|
ViewModels.Preferences.Instance.CustomActions.Move(idx - 1, idx);
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMoveSelectedCustomActionDown(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (SelectedCustomAction == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var idx = ViewModels.Preferences.Instance.CustomActions.IndexOf(SelectedCustomAction);
|
||||||
|
if (idx < ViewModels.Preferences.Instance.CustomActions.Count - 1)
|
||||||
|
ViewModels.Preferences.Instance.CustomActions.Move(idx + 1, idx);
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateGitVersion()
|
private void UpdateGitVersion()
|
||||||
{
|
{
|
||||||
GitVersion = Native.OS.GitVersionString;
|
GitVersion = Native.OS.GitVersionString;
|
||||||
|
|
|
@ -417,19 +417,34 @@
|
||||||
|
|
||||||
<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
||||||
|
|
||||||
<StackPanel Grid.Row="2" Orientation="Horizontal" Background="{DynamicResource Brush.ToolBar}">
|
<Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
|
||||||
<Button Classes="icon_button" Command="{Binding AddNewCustomAction}">
|
<Button Grid.Column="0"
|
||||||
|
Classes="icon_button"
|
||||||
|
Width="28" Height="28"
|
||||||
|
Command="{Binding AddNewCustomAction}">
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button Grid.Column="1"
|
||||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
Classes="icon_button"
|
||||||
|
Width="28" Height="28"
|
||||||
<Button Classes="icon_button" Command="{Binding RemoveSelectedCustomAction}">
|
Command="{Binding RemoveSelectedCustomAction}">
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Window.Minimize}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Window.Minimize}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button Grid.Column="3"
|
||||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
Classes="icon_button"
|
||||||
</StackPanel>
|
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"
|
||||||
|
Classes="icon_button"
|
||||||
|
Width="28" Height="28"
|
||||||
|
Command="{Binding MoveSelectedCustomActionDown}"
|
||||||
|
IsVisible="{Binding SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||||
|
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue