mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 19:55:00 +00:00
feature: supports to show submodules as tree or list (#1307)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
d299469613
commit
ed1351b1f7
10 changed files with 302 additions and 152 deletions
|
@ -617,6 +617,7 @@
|
||||||
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">Message</x:String>
|
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">Message</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">SHA</x:String>
|
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">SHA</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.InCurrentBranch" xml:space="preserve">Current Branch</x:String>
|
<x:String x:Key="Text.Repository.Search.InCurrentBranch" xml:space="preserve">Current Branch</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.ShowSubmodulesAsTree" xml:space="preserve">Show Submodules as Tree</x:String>
|
||||||
<x:String x:Key="Text.Repository.ShowTagsAsTree" xml:space="preserve">Show Tags as Tree</x:String>
|
<x:String x:Key="Text.Repository.ShowTagsAsTree" xml:space="preserve">Show Tags as Tree</x:String>
|
||||||
<x:String x:Key="Text.Repository.Skip" xml:space="preserve">SKIP</x:String>
|
<x:String x:Key="Text.Repository.Skip" xml:space="preserve">SKIP</x:String>
|
||||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">Statistics</x:String>
|
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">Statistics</x:String>
|
||||||
|
|
|
@ -621,6 +621,7 @@
|
||||||
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">提交信息</x:String>
|
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">提交信息</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">提交指纹</x:String>
|
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">提交指纹</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.InCurrentBranch" xml:space="preserve">仅在当前分支中查找</x:String>
|
<x:String x:Key="Text.Repository.Search.InCurrentBranch" xml:space="preserve">仅在当前分支中查找</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.ShowSubmodulesAsTree" xml:space="preserve">以树型结构展示</x:String>
|
||||||
<x:String x:Key="Text.Repository.ShowTagsAsTree" xml:space="preserve">以树型结构展示</x:String>
|
<x:String x:Key="Text.Repository.ShowTagsAsTree" xml:space="preserve">以树型结构展示</x:String>
|
||||||
<x:String x:Key="Text.Repository.Skip" xml:space="preserve">跳过此提交</x:String>
|
<x:String x:Key="Text.Repository.Skip" xml:space="preserve">跳过此提交</x:String>
|
||||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交统计</x:String>
|
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交统计</x:String>
|
||||||
|
|
|
@ -621,6 +621,7 @@
|
||||||
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">提交訊息</x:String>
|
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">提交訊息</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">提交編號</x:String>
|
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">提交編號</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.InCurrentBranch" xml:space="preserve">僅搜尋目前分支</x:String>
|
<x:String x:Key="Text.Repository.Search.InCurrentBranch" xml:space="preserve">僅搜尋目前分支</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.ShowSubmodulesAsTree" xml:space="preserve">以樹型結構展示</x:String>
|
||||||
<x:String x:Key="Text.Repository.ShowTagsAsTree" xml:space="preserve">以樹型結構展示</x:String>
|
<x:String x:Key="Text.Repository.ShowTagsAsTree" xml:space="preserve">以樹型結構展示</x:String>
|
||||||
<x:String x:Key="Text.Repository.Skip" xml:space="preserve">跳過此提交</x:String>
|
<x:String x:Key="Text.Repository.Skip" xml:space="preserve">跳過此提交</x:String>
|
||||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交統計</x:String>
|
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交統計</x:String>
|
||||||
|
|
|
@ -1235,7 +1235,7 @@
|
||||||
<Setter Property="Opacity" Value="1"/>
|
<Setter Property="Opacity" Value="1"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="ToggleButton.tag_display_mode">
|
<Style Selector="ToggleButton.show_as_tree">
|
||||||
<Setter Property="Margin" Value="0" />
|
<Setter Property="Margin" Value="0" />
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
|
|
|
@ -188,6 +188,12 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _showTagsInGraph, value);
|
set => SetProperty(ref _showTagsInGraph, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShowSubmodulesAsTree
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = false;
|
||||||
|
|
||||||
public bool UseTwoColumnsLayoutInHistories
|
public bool UseTwoColumnsLayoutInHistories
|
||||||
{
|
{
|
||||||
get => _useTwoColumnsLayoutInHistories;
|
get => _useTwoColumnsLayoutInHistories;
|
||||||
|
|
|
@ -210,7 +210,21 @@ namespace SourceGit.ViewModels
|
||||||
private set => SetProperty(ref _submodules, value);
|
private set => SetProperty(ref _submodules, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubmoduleCollection VisibleSubmodules
|
public bool ShowSubmodulesAsTree
|
||||||
|
{
|
||||||
|
get => Preferences.Instance.ShowSubmodulesAsTree;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != Preferences.Instance.ShowSubmodulesAsTree)
|
||||||
|
{
|
||||||
|
Preferences.Instance.ShowSubmodulesAsTree = value;
|
||||||
|
VisibleSubmodules = BuildVisibleSubmodules();
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object VisibleSubmodules
|
||||||
{
|
{
|
||||||
get => _visibleSubmodules;
|
get => _visibleSubmodules;
|
||||||
private set => SetProperty(ref _visibleSubmodules, value);
|
private set => SetProperty(ref _visibleSubmodules, value);
|
||||||
|
@ -536,7 +550,7 @@ namespace SourceGit.ViewModels
|
||||||
_tags.Clear();
|
_tags.Clear();
|
||||||
_visibleTags.Clear();
|
_visibleTags.Clear();
|
||||||
_submodules.Clear();
|
_submodules.Clear();
|
||||||
_visibleSubmodules.Clear();
|
_visibleSubmodules = null;
|
||||||
_searchedCommits.Clear();
|
_searchedCommits.Clear();
|
||||||
_selectedSearchedCommit = null;
|
_selectedSearchedCommit = null;
|
||||||
|
|
||||||
|
@ -2512,7 +2526,7 @@ namespace SourceGit.ViewModels
|
||||||
return visible;
|
return visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SubmoduleCollection BuildVisibleSubmodules()
|
private object BuildVisibleSubmodules()
|
||||||
{
|
{
|
||||||
var visible = new List<Models.Submodule>();
|
var visible = new List<Models.Submodule>();
|
||||||
if (string.IsNullOrEmpty(_filter))
|
if (string.IsNullOrEmpty(_filter))
|
||||||
|
@ -2528,7 +2542,10 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SubmoduleCollection.Build(visible, _visibleSubmodules);
|
if (Preferences.Instance.ShowSubmodulesAsTree)
|
||||||
|
return SubmoduleCollectionAsTree.Build(visible, _visibleSubmodules as SubmoduleCollectionAsTree);
|
||||||
|
else
|
||||||
|
return new SubmoduleCollectionAsList() { Submodules = visible };
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshHistoriesFilters(bool refresh)
|
private void RefreshHistoriesFilters(bool refresh)
|
||||||
|
@ -2760,7 +2777,7 @@ namespace SourceGit.ViewModels
|
||||||
private List<Models.Tag> _tags = new List<Models.Tag>();
|
private List<Models.Tag> _tags = new List<Models.Tag>();
|
||||||
private List<Models.Tag> _visibleTags = new List<Models.Tag>();
|
private List<Models.Tag> _visibleTags = new List<Models.Tag>();
|
||||||
private List<Models.Submodule> _submodules = new List<Models.Submodule>();
|
private List<Models.Submodule> _submodules = new List<Models.Submodule>();
|
||||||
private SubmoduleCollection _visibleSubmodules = new SubmoduleCollection();
|
private object _visibleSubmodules = null;
|
||||||
|
|
||||||
private bool _isAutoFetching = false;
|
private bool _isAutoFetching = false;
|
||||||
private Timer _autoFetchTimer = null;
|
private Timer _autoFetchTimer = null;
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace SourceGit.ViewModels
|
||||||
private bool _isExpanded = false;
|
private bool _isExpanded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SubmoduleCollection
|
public class SubmoduleCollectionAsTree
|
||||||
{
|
{
|
||||||
public List<SubmoduleTreeNode> Tree
|
public List<SubmoduleTreeNode> Tree
|
||||||
{
|
{
|
||||||
|
@ -134,16 +134,19 @@ namespace SourceGit.ViewModels
|
||||||
set;
|
set;
|
||||||
} = [];
|
} = [];
|
||||||
|
|
||||||
public static SubmoduleCollection Build(List<Models.Submodule> submodules, SubmoduleCollection old)
|
public static SubmoduleCollectionAsTree Build(List<Models.Submodule> submodules, SubmoduleCollectionAsTree old)
|
||||||
{
|
{
|
||||||
var oldExpanded = new HashSet<string>();
|
var oldExpanded = new HashSet<string>();
|
||||||
|
if (old != null)
|
||||||
|
{
|
||||||
foreach (var row in old.Rows)
|
foreach (var row in old.Rows)
|
||||||
{
|
{
|
||||||
if (row.IsFolder && row.IsExpanded)
|
if (row.IsFolder && row.IsExpanded)
|
||||||
oldExpanded.Add(row.FullPath);
|
oldExpanded.Add(row.FullPath);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var collection = new SubmoduleCollection();
|
var collection = new SubmoduleCollectionAsTree();
|
||||||
collection.Tree = SubmoduleTreeNode.Build(submodules, oldExpanded);
|
collection.Tree = SubmoduleTreeNode.Build(submodules, oldExpanded);
|
||||||
|
|
||||||
var rows = new List<SubmoduleTreeNode>();
|
var rows = new List<SubmoduleTreeNode>();
|
||||||
|
@ -203,4 +206,13 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SubmoduleCollectionAsList
|
||||||
|
{
|
||||||
|
public List<Models.Submodule> Submodules
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = [];
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -269,7 +269,7 @@
|
||||||
<Run Text="{Binding Tags, Converter={x:Static c:ListConverters.ToCount}}"/>
|
<Run Text="{Binding Tags, Converter={x:Static c:ListConverters.ToCount}}"/>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<ToggleButton Grid.Column="2"
|
<ToggleButton Grid.Column="2"
|
||||||
Classes="tag_display_mode"
|
Classes="show_as_tree"
|
||||||
Width="14"
|
Width="14"
|
||||||
IsChecked="{Binding Source={x:Static vm:Preferences.Instance}, Path=ShowTagsAsTree, Mode=TwoWay}"
|
IsChecked="{Binding Source={x:Static vm:Preferences.Instance}, Path=ShowTagsAsTree, Mode=TwoWay}"
|
||||||
ToolTip.Tip="{DynamicResource Text.Repository.ShowTagsAsTree}"/>
|
ToolTip.Tip="{DynamicResource Text.Repository.ShowTagsAsTree}"/>
|
||||||
|
@ -305,13 +305,19 @@
|
||||||
|
|
||||||
<!-- Submodules -->
|
<!-- Submodules -->
|
||||||
<ToggleButton Grid.Row="6" Classes="group_expander" IsChecked="{Binding IsSubmoduleGroupExpanded, Mode=TwoWay}">
|
<ToggleButton Grid.Row="6" Classes="group_expander" IsChecked="{Binding IsSubmoduleGroupExpanded, Mode=TwoWay}">
|
||||||
<Grid ColumnDefinitions="16,*,Auto,Auto">
|
<Grid ColumnDefinitions="16,*,Auto,Auto,Auto">
|
||||||
<Path Grid.Column="0" Width="10" Height="10" Margin="2,0,0,0" HorizontalAlignment="Left" Data="{StaticResource Icons.Submodules}" Fill="{DynamicResource Brush.FG2}"/>
|
<Path Grid.Column="0" Width="10" Height="10" Margin="2,0,0,0" HorizontalAlignment="Left" Data="{StaticResource Icons.Submodules}" Fill="{DynamicResource Brush.FG2}"/>
|
||||||
<TextBlock Grid.Column="1" Classes="group_header_label" Margin="0">
|
<TextBlock Grid.Column="1" Classes="group_header_label" Margin="0">
|
||||||
<Run Text="{DynamicResource Text.Repository.Submodules}"/>
|
<Run Text="{DynamicResource Text.Repository.Submodules}"/>
|
||||||
<Run Text="{Binding Submodules, Converter={x:Static c:ListConverters.ToCount}}"/>
|
<Run Text="{Binding Submodules, Converter={x:Static c:ListConverters.ToCount}}"/>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<Button Grid.Column="2"
|
<ToggleButton Grid.Column="2"
|
||||||
|
Classes="show_as_tree"
|
||||||
|
Width="14"
|
||||||
|
IsChecked="{Binding ShowSubmodulesAsTree, Mode=TwoWay}"
|
||||||
|
IsVisible="{Binding Submodules, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}"
|
||||||
|
ToolTip.Tip="{DynamicResource Text.Repository.ShowSubmodulesAsTree}"/>
|
||||||
|
<Button Grid.Column="3"
|
||||||
Classes="icon_button"
|
Classes="icon_button"
|
||||||
Width="14"
|
Width="14"
|
||||||
Margin="8,0"
|
Margin="8,0"
|
||||||
|
@ -320,7 +326,7 @@
|
||||||
ToolTip.Tip="{DynamicResource Text.Repository.Submodules.Update}">
|
ToolTip.Tip="{DynamicResource Text.Repository.Submodules.Update}">
|
||||||
<Path Width="12" Height="12" Data="{StaticResource Icons.Loading}"/>
|
<Path Width="12" Height="12" Data="{StaticResource Icons.Loading}"/>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Column="3"
|
<Button Grid.Column="4"
|
||||||
Classes="icon_button"
|
Classes="icon_button"
|
||||||
Width="14"
|
Width="14"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
|
@ -334,7 +340,7 @@
|
||||||
x:Name="SubmoduleList"
|
x:Name="SubmoduleList"
|
||||||
Height="0"
|
Height="0"
|
||||||
Margin="8,0,4,0"
|
Margin="8,0,4,0"
|
||||||
Submodules="{Binding VisibleSubmodules}"
|
Content="{Binding VisibleSubmodules}"
|
||||||
RowsChanged="OnSubmodulesRowsChanged"
|
RowsChanged="OnSubmodulesRowsChanged"
|
||||||
Focusable="False"
|
Focusable="False"
|
||||||
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}"/>
|
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}"/>
|
||||||
|
|
|
@ -7,9 +7,17 @@
|
||||||
xmlns:vm="using:SourceGit.ViewModels"
|
xmlns:vm="using:SourceGit.ViewModels"
|
||||||
xmlns:c="using:SourceGit.Converters"
|
xmlns:c="using:SourceGit.Converters"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="SourceGit.Views.SubmodulesView"
|
x:Class="SourceGit.Views.SubmodulesView">
|
||||||
x:Name="ThisControl">
|
|
||||||
<UserControl.DataTemplates>
|
<UserControl.DataTemplates>
|
||||||
|
<DataTemplate DataType="vm:SubmoduleCollectionAsTree">
|
||||||
|
<ListBox Classes="repo_left_content_list" ItemsSource="{Binding Rows}" SelectionMode="Single">
|
||||||
|
<ListBox.Styles>
|
||||||
|
<Style Selector="ListBoxItem">
|
||||||
|
<Setter Property="CornerRadius" Value="4"/>
|
||||||
|
</Style>
|
||||||
|
</ListBox.Styles>
|
||||||
|
|
||||||
|
<ListBox.DataTemplates>
|
||||||
<DataTemplate DataType="m:Submodule">
|
<DataTemplate DataType="m:Submodule">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
@ -73,21 +81,14 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</UserControl.DataTemplates>
|
</ListBox.DataTemplates>
|
||||||
|
|
||||||
<ListBox Classes="repo_left_content_list" ItemsSource="{Binding #ThisControl.Submodules.Rows}" SelectionMode="Single">
|
|
||||||
<ListBox.Styles>
|
|
||||||
<Style Selector="ListBoxItem">
|
|
||||||
<Setter Property="CornerRadius" Value="4"/>
|
|
||||||
</Style>
|
|
||||||
</ListBox.Styles>
|
|
||||||
|
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate DataType="vm:SubmoduleTreeNode">
|
<DataTemplate DataType="vm:SubmoduleTreeNode">
|
||||||
<Border Height="24"
|
<Border Height="24"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
DoubleTapped="OnDoubleTappedNode"
|
DoubleTapped="OnItemDoubleTapped"
|
||||||
ContextRequested="OnRowContextRequested"
|
ContextRequested="OnItemContextRequested"
|
||||||
ToolTip.Tip="{Binding Module}"
|
ToolTip.Tip="{Binding Module}"
|
||||||
ToolTip.Placement="Right">
|
ToolTip.Placement="Right">
|
||||||
<Grid ColumnDefinitions="16,Auto,*,Auto,Auto"
|
<Grid ColumnDefinitions="16,Auto,*,Auto,Auto"
|
||||||
|
@ -122,4 +123,101 @@
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
|
</DataTemplate>
|
||||||
|
|
||||||
|
<DataTemplate DataType="vm:SubmoduleCollectionAsList">
|
||||||
|
<ListBox Classes="repo_left_content_list" ItemsSource="{Binding Submodules}" SelectionMode="Single">
|
||||||
|
<ListBox.Styles>
|
||||||
|
<Style Selector="ListBoxItem">
|
||||||
|
<Setter Property="CornerRadius" Value="4"/>
|
||||||
|
</Style>
|
||||||
|
</ListBox.Styles>
|
||||||
|
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate DataType="m:Submodule">
|
||||||
|
<Border Height="24"
|
||||||
|
Background="Transparent"
|
||||||
|
DoubleTapped="OnItemDoubleTapped"
|
||||||
|
ContextRequested="OnItemContextRequested"
|
||||||
|
ToolTip.Placement="Right">
|
||||||
|
<ToolTip.Tip>
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Path Width="10" Height="10" Data="{StaticResource Icons.Submodule}"/>
|
||||||
|
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Path}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Grid RowDefinitions="24,24" ColumnDefinitions="Auto,Auto" Margin="0,8,0,0">
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||||
|
Classes="info_label"
|
||||||
|
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||||
|
Text="{DynamicResource Text.CommitDetail.Info.SHA}"/>
|
||||||
|
<StackPanel Grid.Row="0" Grid.Column="1"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Margin="8,0,0,0">
|
||||||
|
<TextBlock Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
|
||||||
|
<Path Margin="6,0,0,0"
|
||||||
|
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||||
|
Width="12" Height="12"
|
||||||
|
Data="{StaticResource Icons.Check}"
|
||||||
|
Fill="Green"
|
||||||
|
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}"/>
|
||||||
|
<Border Height="16"
|
||||||
|
Margin="6,0,0,0" Padding="4,0"
|
||||||
|
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||||
|
Background="DarkOrange"
|
||||||
|
CornerRadius="4"
|
||||||
|
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.NotEqual}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}">
|
||||||
|
<Grid>
|
||||||
|
<TextBlock VerticalAlignment="Center"
|
||||||
|
Text="{DynamicResource Text.Submodule.Status.NotInited}"
|
||||||
|
Foreground="White"
|
||||||
|
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.NotInited}}"/>
|
||||||
|
<TextBlock VerticalAlignment="Center"
|
||||||
|
Text="{DynamicResource Text.Submodule.Status.Modified}"
|
||||||
|
Foreground="White"
|
||||||
|
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Modified}}"/>
|
||||||
|
<TextBlock VerticalAlignment="Center"
|
||||||
|
Text="{DynamicResource Text.Submodule.Status.RevisionChanged}"
|
||||||
|
Foreground="White"
|
||||||
|
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.RevisionChanged}}"/>
|
||||||
|
<TextBlock VerticalAlignment="Center"
|
||||||
|
Text="{DynamicResource Text.Submodule.Status.Unmerged}"
|
||||||
|
Foreground="White"
|
||||||
|
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Unmerged}}"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||||
|
Classes="info_label"
|
||||||
|
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||||
|
Text="{DynamicResource Text.Submodule.URL}"/>
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="1"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Text="{Binding URL}"
|
||||||
|
Foreground="{DynamicResource Brush.Link}"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
</ToolTip.Tip>
|
||||||
|
|
||||||
|
<Grid ColumnDefinitions="16,*,Auto" Margin="8,0,0,0" VerticalAlignment="Center">
|
||||||
|
<Path Grid.Column="0" Width="10" Height="10" Margin="8,0" Data="{StaticResource Icons.Submodule}"/>
|
||||||
|
<TextBlock Grid.Column="1" Text="{Binding Path}" ClipToBounds="True" Classes="primary" TextTrimming="CharacterEllipsis"/>
|
||||||
|
<Path Grid.Column="2"
|
||||||
|
Width="8" Height="8"
|
||||||
|
Margin="8,0,12,0"
|
||||||
|
Fill="Goldenrod"
|
||||||
|
Data="{StaticResource Icons.Modified}"
|
||||||
|
IsVisible="{Binding IsDirty}"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</DataTemplate>
|
||||||
|
</UserControl.DataTemplates>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -89,15 +89,6 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
public partial class SubmodulesView : UserControl
|
public partial class SubmodulesView : UserControl
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<ViewModels.SubmoduleCollection> SubmodulesProperty =
|
|
||||||
AvaloniaProperty.Register<SubmodulesView, ViewModels.SubmoduleCollection>(nameof(Submodules));
|
|
||||||
|
|
||||||
public ViewModels.SubmoduleCollection Submodules
|
|
||||||
{
|
|
||||||
get => GetValue(SubmodulesProperty);
|
|
||||||
set => SetValue(SubmodulesProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly RoutedEvent<RoutedEventArgs> RowsChangedEvent =
|
public static readonly RoutedEvent<RoutedEventArgs> RowsChangedEvent =
|
||||||
RoutedEvent.Register<TagsView, RoutedEventArgs>(nameof(RowsChanged), RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
|
RoutedEvent.Register<TagsView, RoutedEventArgs>(nameof(RowsChanged), RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
|
||||||
|
|
||||||
|
@ -120,11 +111,10 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
public void ToggleNodeIsExpanded(ViewModels.SubmoduleTreeNode node)
|
public void ToggleNodeIsExpanded(ViewModels.SubmoduleTreeNode node)
|
||||||
{
|
{
|
||||||
var submodules = Submodules;
|
if (Content is ViewModels.SubmoduleCollectionAsTree tree)
|
||||||
if (submodules != null)
|
|
||||||
{
|
{
|
||||||
submodules.ToggleExpand(node);
|
tree.ToggleExpand(node);
|
||||||
Rows = submodules.Rows.Count;
|
Rows = tree.Rows.Count;
|
||||||
RaiseEvent(new RoutedEventArgs(RowsChangedEvent));
|
RaiseEvent(new RoutedEventArgs(RowsChangedEvent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,9 +123,15 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
base.OnPropertyChanged(change);
|
base.OnPropertyChanged(change);
|
||||||
|
|
||||||
if (change.Property == SubmodulesProperty)
|
if (change.Property == ContentProperty)
|
||||||
{
|
{
|
||||||
Rows = Submodules?.Rows.Count ?? 0;
|
if (Content is ViewModels.SubmoduleCollectionAsTree tree)
|
||||||
|
Rows = tree.Rows.Count;
|
||||||
|
else if (Content is ViewModels.SubmoduleCollectionAsList list)
|
||||||
|
Rows = list.Submodules.Count;
|
||||||
|
else
|
||||||
|
Rows = 0;
|
||||||
|
|
||||||
RaiseEvent(new RoutedEventArgs(RowsChangedEvent));
|
RaiseEvent(new RoutedEventArgs(RowsChangedEvent));
|
||||||
}
|
}
|
||||||
else if (change.Property == IsVisibleProperty)
|
else if (change.Property == IsVisibleProperty)
|
||||||
|
@ -144,29 +140,41 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDoubleTappedNode(object sender, TappedEventArgs e)
|
private void OnItemDoubleTapped(object sender, TappedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Control { DataContext: ViewModels.SubmoduleTreeNode node } &&
|
if (sender is Control control && DataContext is ViewModels.Repository repo)
|
||||||
DataContext is ViewModels.Repository repo)
|
{
|
||||||
|
if (control.DataContext is ViewModels.SubmoduleTreeNode node)
|
||||||
{
|
{
|
||||||
if (node.IsFolder)
|
if (node.IsFolder)
|
||||||
ToggleNodeIsExpanded(node);
|
ToggleNodeIsExpanded(node);
|
||||||
else if (node.Module.Status != Models.SubmoduleStatus.NotInited)
|
else if (node.Module.Status != Models.SubmoduleStatus.NotInited)
|
||||||
repo.OpenSubmodule(node.Module.Path);
|
repo.OpenSubmodule(node.Module.Path);
|
||||||
}
|
}
|
||||||
|
else if (control.DataContext is Models.Submodule m && m.Status != Models.SubmoduleStatus.NotInited)
|
||||||
|
{
|
||||||
|
repo.OpenSubmodule(m.Path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRowContextRequested(object sender, ContextRequestedEventArgs e)
|
private void OnItemContextRequested(object sender, ContextRequestedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Control { DataContext: ViewModels.SubmoduleTreeNode node } control &&
|
if (sender is Control control && DataContext is ViewModels.Repository repo)
|
||||||
node.Module != null &&
|
{
|
||||||
DataContext is ViewModels.Repository repo)
|
if (control.DataContext is ViewModels.SubmoduleTreeNode node && node.Module != null)
|
||||||
{
|
{
|
||||||
var menu = repo.CreateContextMenuForSubmodule(node.Module);
|
var menu = repo.CreateContextMenuForSubmodule(node.Module);
|
||||||
menu?.Open(control);
|
menu?.Open(control);
|
||||||
}
|
}
|
||||||
|
else if (control.DataContext is Models.Submodule m)
|
||||||
|
{
|
||||||
|
var menu = repo.CreateContextMenuForSubmodule(m);
|
||||||
|
menu?.Open(control);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue