mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 19:55:00 +00:00
ux: new style for tag's tooltip (#1305)
This commit is contained in:
parent
8a45e25106
commit
afc8a772dd
5 changed files with 66 additions and 26 deletions
|
@ -11,7 +11,7 @@ namespace SourceGit.Commands
|
||||||
|
|
||||||
Context = repo;
|
Context = repo;
|
||||||
WorkingDirectory = repo;
|
WorkingDirectory = repo;
|
||||||
Args = $"tag -l --format=\"{_boundary}%(refname)%00%(objectname)%00%(*objectname)%00%(creatordate:unix)%00%(contents:subject)%0a%0a%(contents:body)\"";
|
Args = $"tag -l --format=\"{_boundary}%(refname)%00%(objecttype)%00%(objectname)%00%(*objectname)%00%(creatordate:unix)%00%(contents:subject)%0a%0a%(contents:body)\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Models.Tag> Result()
|
public List<Models.Tag> Result()
|
||||||
|
@ -25,16 +25,17 @@ namespace SourceGit.Commands
|
||||||
foreach (var record in records)
|
foreach (var record in records)
|
||||||
{
|
{
|
||||||
var subs = record.Split('\0', StringSplitOptions.None);
|
var subs = record.Split('\0', StringSplitOptions.None);
|
||||||
if (subs.Length != 5)
|
if (subs.Length != 6)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var name = subs[0].Substring(10);
|
var name = subs[0].Substring(10);
|
||||||
var message = subs[4].Trim();
|
var message = subs[5].Trim();
|
||||||
tags.Add(new Models.Tag()
|
tags.Add(new Models.Tag()
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
SHA = string.IsNullOrEmpty(subs[2]) ? subs[1] : subs[2],
|
IsAnnotated = subs[1].Equals("tag", StringComparison.Ordinal),
|
||||||
CreatorDate = ulong.Parse(subs[3]),
|
SHA = string.IsNullOrEmpty(subs[3]) ? subs[2] : subs[3],
|
||||||
|
CreatorDate = ulong.Parse(subs[4]),
|
||||||
Message = string.IsNullOrEmpty(message) ? name : message,
|
Message = string.IsNullOrEmpty(message) ? name : message,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace SourceGit.Models
|
||||||
public class Tag : ObservableObject
|
public class Tag : ObservableObject
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public bool IsAnnotated { get; set; } = false;
|
||||||
public string SHA { get; set; } = string.Empty;
|
public string SHA { get; set; } = string.Empty;
|
||||||
public ulong CreatorDate { get; set; } = 0;
|
public ulong CreatorDate { get; set; } = 0;
|
||||||
public string Message { get; set; } = string.Empty;
|
public string Message { get; set; } = string.Empty;
|
||||||
|
|
|
@ -5,18 +5,28 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
namespace SourceGit.ViewModels
|
namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
|
public class TagTreeNodeToolTip
|
||||||
|
{
|
||||||
|
public string Name { get; private set; }
|
||||||
|
public bool IsAnnotated { get; private set; }
|
||||||
|
public string Message { get; private set; }
|
||||||
|
|
||||||
|
public TagTreeNodeToolTip(Models.Tag t)
|
||||||
|
{
|
||||||
|
Name = t.Name;
|
||||||
|
IsAnnotated = t.IsAnnotated;
|
||||||
|
Message = t.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class TagTreeNode : ObservableObject
|
public class TagTreeNode : ObservableObject
|
||||||
{
|
{
|
||||||
public string FullPath { get; set; }
|
public string FullPath { get; set; }
|
||||||
public int Depth { get; private set; } = 0;
|
public int Depth { get; private set; } = 0;
|
||||||
public Models.Tag Tag { get; private set; } = null;
|
public Models.Tag Tag { get; private set; } = null;
|
||||||
|
public TagTreeNodeToolTip ToolTip { get; private set; } = null;
|
||||||
public List<TagTreeNode> Children { get; private set; } = [];
|
public List<TagTreeNode> Children { get; private set; } = [];
|
||||||
|
|
||||||
public object ToolTip
|
|
||||||
{
|
|
||||||
get => Tag?.Message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsFolder
|
public bool IsFolder
|
||||||
{
|
{
|
||||||
get => Tag == null;
|
get => Tag == null;
|
||||||
|
@ -33,6 +43,7 @@ namespace SourceGit.ViewModels
|
||||||
FullPath = t.Name;
|
FullPath = t.Name;
|
||||||
Depth = depth;
|
Depth = depth;
|
||||||
Tag = t;
|
Tag = t;
|
||||||
|
ToolTip = new TagTreeNodeToolTip(t);
|
||||||
IsExpanded = false;
|
IsExpanded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,26 @@
|
||||||
SelectionChanged="OnRowSelectionChanged">
|
SelectionChanged="OnRowSelectionChanged">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate DataType="vm:TagTreeNode">
|
<DataTemplate DataType="vm:TagTreeNode">
|
||||||
<Border Height="24" Background="Transparent" PointerPressed="OnRowPointerPressed" DoubleTapped="OnDoubleTappedNode" ContextRequested="OnRowContextRequested">
|
<Border Height="24" Background="Transparent" PointerPressed="OnRowPointerPressed" DoubleTapped="OnDoubleTappedNode" ContextRequested="OnRowContextRequested" ToolTip.Tip="{Binding ToolTip}">
|
||||||
|
<Border.DataTemplates>
|
||||||
|
<DataTemplate DataType="vm:TagTreeNodeToolTip">
|
||||||
|
<StackPanel Orientation="Vertical" MinWidth="200">
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,6">
|
||||||
|
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}"/>
|
||||||
|
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Name}"/>
|
||||||
|
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" IsVisible="{Binding IsAnnotated}">
|
||||||
|
<TextBlock Text="annotated" Classes="primary" Margin="4,0" Foreground="#FFDDDDDD"/>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<TextBlock Text="{Binding Message}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</Border.DataTemplates>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="16,Auto,*,Auto"
|
<Grid ColumnDefinitions="16,Auto,*,Auto"
|
||||||
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
|
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center">
|
||||||
ToolTip.Tip="{Binding ToolTip}">
|
|
||||||
<v:TagTreeNodeToggleButton Grid.Column="0"
|
<v:TagTreeNodeToggleButton Grid.Column="0"
|
||||||
Classes="tree_expander"
|
Classes="tree_expander"
|
||||||
Focusable="False"
|
Focusable="False"
|
||||||
|
@ -42,11 +57,10 @@
|
||||||
Node="{Binding .}"
|
Node="{Binding .}"
|
||||||
IsExpanded="{Binding IsExpanded, Mode=OneWay}"/>
|
IsExpanded="{Binding IsExpanded, Mode=OneWay}"/>
|
||||||
|
|
||||||
<Border Grid.Column="2" Background="Transparent">
|
<TextBlock Grid.Column="2"
|
||||||
<TextBlock Classes="primary"
|
Classes="primary"
|
||||||
Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"
|
Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"
|
||||||
Margin="8,0,0,0"/>
|
Margin="8,0,0,0"/>
|
||||||
</Border>
|
|
||||||
|
|
||||||
<ContentControl Grid.Column="3" Content="{Binding Tag}">
|
<ContentControl Grid.Column="3" Content="{Binding Tag}">
|
||||||
<ContentControl.DataTemplates>
|
<ContentControl.DataTemplates>
|
||||||
|
@ -71,18 +85,31 @@
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate DataType="m:Tag">
|
<DataTemplate DataType="m:Tag">
|
||||||
<Border Height="24" Background="Transparent" PointerPressed="OnRowPointerPressed" ContextRequested="OnRowContextRequested">
|
<Border Height="24" Background="Transparent" PointerPressed="OnRowPointerPressed" ContextRequested="OnRowContextRequested">
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto" VerticalAlignment="Center" ToolTip.Tip="{Binding Message}">
|
<ToolTip.Tip>
|
||||||
|
<StackPanel Orientation="Vertical" MinWidth="200">
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,6">
|
||||||
|
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}"/>
|
||||||
|
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Name}"/>
|
||||||
|
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" IsVisible="{Binding IsAnnotated}">
|
||||||
|
<TextBlock Text="annotated" Classes="primary" Margin="4,0" Foreground="#FFDDDDDD"/>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<TextBlock Text="{Binding Message}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ToolTip.Tip>
|
||||||
|
|
||||||
|
<Grid ColumnDefinitions="Auto,*,Auto" VerticalAlignment="Center">
|
||||||
<Path Grid.Column="0"
|
<Path Grid.Column="0"
|
||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
Width="12" Height="12"
|
Width="12" Height="12"
|
||||||
Data="{StaticResource Icons.Tag}"/>
|
Data="{StaticResource Icons.Tag}"/>
|
||||||
|
|
||||||
<Border Grid.Column="1" Background="Transparent">
|
<TextBlock Grid.Column="1"
|
||||||
<TextBlock Classes="primary"
|
Classes="primary"
|
||||||
Text="{Binding Name}"
|
Text="{Binding Name}"
|
||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
TextTrimming="CharacterEllipsis"/>
|
TextTrimming="CharacterEllipsis"/>
|
||||||
</Border>
|
|
||||||
|
|
||||||
<v:FilterModeSwitchButton Grid.Column="2" Margin="0,0,12,0" Mode="{Binding FilterMode}"/>
|
<v:FilterModeSwitchButton Grid.Column="2" Margin="0,0,12,0" Mode="{Binding FilterMode}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue