mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feature: double-click on single-selecte change tree or file tree will expand/collapse folder node
This commit is contained in:
parent
cce4e5348c
commit
9d13b17aaf
8 changed files with 70 additions and 12 deletions
|
@ -171,22 +171,27 @@ namespace SourceGit.Models
|
|||
if (!IsSelected(modelIndex))
|
||||
{
|
||||
PointerSelect(sender, row, e);
|
||||
_pressedPoint = s_InvalidPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
var point = e.GetCurrentPoint(sender);
|
||||
if (point.Properties.IsRightButtonPressed)
|
||||
{
|
||||
_pressedPoint = s_InvalidPoint;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.KeyModifiers == KeyModifiers.Control)
|
||||
{
|
||||
Deselect(modelIndex);
|
||||
}
|
||||
else if (e.ClickCount == 2)
|
||||
else if (e.ClickCount % 2 == 0)
|
||||
{
|
||||
_rowDoubleTapped?.Invoke(this, e);
|
||||
e.Handled = true;
|
||||
}
|
||||
else
|
||||
else if (sender.RowSelection.Count > 1)
|
||||
{
|
||||
using (BatchUpdate())
|
||||
{
|
||||
|
@ -194,10 +199,10 @@ namespace SourceGit.Models
|
|||
Select(modelIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_pressedPoint = s_InvalidPoint;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sender.TryGetRow(e.Source as Control, out var test))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationManifest>App.manifest</ApplicationManifest>
|
||||
|
|
|
@ -511,14 +511,22 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
};
|
||||
|
||||
source.Selection = new Models.TreeDataGridSelectionModel<FileTreeNode>(source, x => x.Children);
|
||||
source.RowSelection.SingleSelect = true;
|
||||
source.RowSelection.SelectionChanged += (s, _) =>
|
||||
var selection = new Models.TreeDataGridSelectionModel<FileTreeNode>(source, x => x.Children);
|
||||
selection.SingleSelect = true;
|
||||
selection.RowDoubleTapped += (s, e) =>
|
||||
{
|
||||
var model = s as Models.TreeDataGridSelectionModel<FileTreeNode>;
|
||||
var node = model.SelectedItem;
|
||||
if (node != null && node.IsFolder)
|
||||
node.IsExpanded = !node.IsExpanded;
|
||||
};
|
||||
selection.SelectionChanged += (s, _) =>
|
||||
{
|
||||
if (s is Models.TreeDataGridSelectionModel<FileTreeNode> selection)
|
||||
RefreshViewRevisionFile(selection.SelectedItem?.Backend as Models.Object);
|
||||
};
|
||||
|
||||
source.Selection = selection;
|
||||
RevisionFiles = source;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,14 @@
|
|||
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode}"
|
||||
Changes="{Binding VisibleChanges}"
|
||||
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"
|
||||
ContextRequested="OnChangeContextRequested"/>
|
||||
ContextRequested="OnChangeContextRequested"
|
||||
ChangeDoubleTapped="OnChangeDoubleTapped">
|
||||
<v:ChangeCollectionView.Styles>
|
||||
<Style Selector="TreeDataGridExpanderCell" x:DataType="vm:FileTreeNode">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</v:ChangeCollectionView.Styles>
|
||||
</v:ChangeCollectionView>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
|
@ -24,5 +24,17 @@ namespace SourceGit.Views
|
|||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnChangeDoubleTapped(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is ChangeCollectionView view)
|
||||
{
|
||||
var selected = view.tree?.RowSelection?.SelectedItem as ViewModels.FileTreeNode;
|
||||
if (selected != null && selected.IsFolder)
|
||||
selected.IsExpanded = !selected.IsExpanded;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,14 @@
|
|||
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode}"
|
||||
Changes="{Binding VisibleChanges}"
|
||||
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"
|
||||
ContextRequested="OnChangeContextRequested"/>
|
||||
ContextRequested="OnChangeContextRequested"
|
||||
ChangeDoubleTapped="OnChangeDoubleTapped">
|
||||
<v:ChangeCollectionView.Styles>
|
||||
<Style Selector="TreeDataGridExpanderCell" x:DataType="vm:FileTreeNode">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</v:ChangeCollectionView.Styles>
|
||||
</v:ChangeCollectionView>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
|
@ -21,6 +22,18 @@ namespace SourceGit.Views
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnChangeDoubleTapped(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is ChangeCollectionView view)
|
||||
{
|
||||
var selected = view.tree?.RowSelection?.SelectedItem as ViewModels.FileTreeNode;
|
||||
if (selected != null && selected.IsFolder)
|
||||
selected.IsExpanded = !selected.IsExpanded;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnPressedSHA(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.RevisionCompare vm && sender is TextBlock block)
|
||||
|
|
|
@ -56,6 +56,12 @@
|
|||
</Grid>
|
||||
</DataTemplate>
|
||||
</TreeDataGrid.Resources>
|
||||
|
||||
<TreeDataGrid.Styles>
|
||||
<Style Selector="TreeDataGridExpanderCell" x:DataType="vm:FileTreeNode">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</TreeDataGrid.Styles>
|
||||
</TreeDataGrid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
|
Loading…
Reference in a new issue