mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 11:44:59 +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
|
@ -35,7 +35,7 @@ namespace SourceGit.Commands
|
|||
App.RaiseException(repo, $"Failed to discard changes. Reason: {e.Message}");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
new Restore(repo) { Log = log }.Exec();
|
||||
if (includeIgnored)
|
||||
new Clean(repo) { Log = log }.Exec();
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace SourceGit.Commands
|
|||
|
||||
Context = 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()
|
||||
|
@ -25,16 +25,17 @@ namespace SourceGit.Commands
|
|||
foreach (var record in records)
|
||||
{
|
||||
var subs = record.Split('\0', StringSplitOptions.None);
|
||||
if (subs.Length != 5)
|
||||
if (subs.Length != 6)
|
||||
continue;
|
||||
|
||||
var name = subs[0].Substring(10);
|
||||
var message = subs[4].Trim();
|
||||
var message = subs[5].Trim();
|
||||
tags.Add(new Models.Tag()
|
||||
{
|
||||
Name = name,
|
||||
SHA = string.IsNullOrEmpty(subs[2]) ? subs[1] : subs[2],
|
||||
CreatorDate = ulong.Parse(subs[3]),
|
||||
IsAnnotated = subs[1].Equals("tag", StringComparison.Ordinal),
|
||||
SHA = string.IsNullOrEmpty(subs[3]) ? subs[2] : subs[3],
|
||||
CreatorDate = ulong.Parse(subs[4]),
|
||||
Message = string.IsNullOrEmpty(message) ? name : message,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace SourceGit.Models
|
|||
public class Tag : ObservableObject
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public bool IsAnnotated { get; set; } = false;
|
||||
public string SHA { get; set; } = string.Empty;
|
||||
public ulong CreatorDate { get; set; } = 0;
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
|
|
@ -5,18 +5,28 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
|||
|
||||
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 string FullPath { get; set; }
|
||||
public int Depth { get; private set; } = 0;
|
||||
public Models.Tag Tag { get; private set; } = null;
|
||||
public TagTreeNodeToolTip ToolTip { get; private set; } = null;
|
||||
public List<TagTreeNode> Children { get; private set; } = [];
|
||||
|
||||
public object ToolTip
|
||||
{
|
||||
get => Tag?.Message;
|
||||
}
|
||||
|
||||
public bool IsFolder
|
||||
{
|
||||
get => Tag == null;
|
||||
|
@ -33,6 +43,7 @@ namespace SourceGit.ViewModels
|
|||
FullPath = t.Name;
|
||||
Depth = depth;
|
||||
Tag = t;
|
||||
ToolTip = new TagTreeNodeToolTip(t);
|
||||
IsExpanded = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,26 @@
|
|||
SelectionChanged="OnRowSelectionChanged">
|
||||
<ListBox.ItemTemplate>
|
||||
<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"
|
||||
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
|
||||
VerticalAlignment="Center"
|
||||
ToolTip.Tip="{Binding ToolTip}">
|
||||
VerticalAlignment="Center">
|
||||
<v:TagTreeNodeToggleButton Grid.Column="0"
|
||||
Classes="tree_expander"
|
||||
Focusable="False"
|
||||
|
@ -42,11 +57,10 @@
|
|||
Node="{Binding .}"
|
||||
IsExpanded="{Binding IsExpanded, Mode=OneWay}"/>
|
||||
|
||||
<Border Grid.Column="2" Background="Transparent">
|
||||
<TextBlock Classes="primary"
|
||||
Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"
|
||||
Margin="8,0,0,0"/>
|
||||
</Border>
|
||||
<TextBlock Grid.Column="2"
|
||||
Classes="primary"
|
||||
Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"
|
||||
Margin="8,0,0,0"/>
|
||||
|
||||
<ContentControl Grid.Column="3" Content="{Binding Tag}">
|
||||
<ContentControl.DataTemplates>
|
||||
|
@ -71,18 +85,31 @@
|
|||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="m:Tag">
|
||||
<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"
|
||||
Margin="8,0,0,0"
|
||||
Width="12" Height="12"
|
||||
Data="{StaticResource Icons.Tag}"/>
|
||||
|
||||
<Border Grid.Column="1" Background="Transparent">
|
||||
<TextBlock Classes="primary"
|
||||
Text="{Binding Name}"
|
||||
Margin="8,0,0,0"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
</Border>
|
||||
<TextBlock Grid.Column="1"
|
||||
Classes="primary"
|
||||
Text="{Binding Name}"
|
||||
Margin="8,0,0,0"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
|
||||
<v:FilterModeSwitchButton Grid.Column="2" Margin="0,0,12,0" Mode="{Binding FilterMode}"/>
|
||||
</Grid>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue