feature: hover on tag view shows the message of it (#567)

This commit is contained in:
leo 2024-10-17 14:57:05 +08:00
parent 9ed5226eab
commit f6e0b0b1c0
No known key found for this signature in database
5 changed files with 67 additions and 57 deletions

View file

@ -7,9 +7,11 @@ namespace SourceGit.Commands
{ {
public QueryTags(string repo) public QueryTags(string repo)
{ {
_boundary = $"----- BOUNDARY OF TAGS {Guid.NewGuid()} -----";
Context = repo; Context = repo;
WorkingDirectory = repo; WorkingDirectory = repo;
Args = "tag -l --sort=-creatordate --format=\"%(refname)%00%(objectname)%00%(*objectname)\""; Args = $"tag -l --sort=-creatordate --format=\"{_boundary}%(refname)%00%(objectname)%00%(*objectname)%00%(contents:subject)%0a%0a%(contents:body)\"";
} }
public List<Models.Tag> Result() public List<Models.Tag> Result()
@ -19,27 +21,25 @@ namespace SourceGit.Commands
if (!rs.IsSuccess) if (!rs.IsSuccess)
return tags; return tags;
var lines = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries); var records = rs.StdOut.Split(_boundary, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines) foreach (var record in records)
{ {
var tag = ParseLine(line); var subs = record.Split('\0', StringSplitOptions.None);
if (tag != null) if (subs.Length != 4)
tags.Add(tag); continue;
var message = subs[3].Trim();
tags.Add(new Models.Tag()
{
Name = subs[0].Substring(10),
SHA = string.IsNullOrEmpty(subs[2]) ? subs[1] : subs[2],
Message = string.IsNullOrEmpty(message) ? null : message,
});
} }
return tags; return tags;
} }
private Models.Tag ParseLine(string line) private string _boundary = string.Empty;
{
var subs = line.Split('\0');
if (subs.Length != 3)
return null;
var tag = new Models.Tag();
tag.Name = subs[0].Substring(10);
tag.SHA = string.IsNullOrEmpty(subs[2]) ? subs[1] : subs[2];
return tag;
}
} }
} }

View file

@ -4,6 +4,7 @@
{ {
public string Name { get; set; } public string Name { get; set; }
public string SHA { get; set; } public string SHA { get; set; }
public string Message { get; set; }
public bool IsFiltered { get; set; } public bool IsFiltered { get; set; }
} }
} }

View file

@ -12,6 +12,11 @@ namespace SourceGit.ViewModels
public Models.Tag Tag { get; private set; } = null; public Models.Tag Tag { 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;

View file

@ -33,49 +33,49 @@
ColumnDefinitions="16,*" ColumnDefinitions="16,*"
ToolTip.Tip="{Binding Tooltip}"> ToolTip.Tip="{Binding Tooltip}">
<!-- Tree Expander --> <!-- Tree Expander -->
<v:BranchTreeNodeToggleButton Grid.Column="0" <v:BranchTreeNodeToggleButton Grid.Column="0"
Classes="tree_expander" Classes="tree_expander"
Focusable="False" Focusable="False"
HorizontalAlignment="Center" HorizontalAlignment="Center"
IsChecked="{Binding IsExpanded, Mode=OneWay}" IsChecked="{Binding IsExpanded, Mode=OneWay}"
IsVisible="{Binding !IsBranch}"/> IsVisible="{Binding !IsBranch}"/>
<!-- Content Area (allows double-click) --> <!-- Content Area (allows double-click) -->
<Grid Grid.Column="1" <Grid Grid.Column="1"
Background="Transparent" Background="Transparent"
ColumnDefinitions="18,*,Auto,Auto" ColumnDefinitions="18,*,Auto,Auto"
DoubleTapped="OnDoubleTappedBranchNode"> DoubleTapped="OnDoubleTappedBranchNode">
<!-- Icon --> <!-- Icon -->
<v:BranchTreeNodeIcon Grid.Column="0" <v:BranchTreeNodeIcon Grid.Column="0"
Node="{Binding}" Node="{Binding}"
IsExpanded="{Binding IsExpanded}"/> IsExpanded="{Binding IsExpanded}"/>
<!-- Name --> <!-- Name -->
<TextBlock Grid.Column="1" <TextBlock Grid.Column="1"
Text="{Binding Name}" Text="{Binding Name}"
Classes="primary" Classes="primary"
FontWeight="{Binding NameFontWeight}" FontWeight="{Binding NameFontWeight}"
TextTrimming="CharacterEllipsis"/> TextTrimming="CharacterEllipsis"/>
<!-- Tracking status --> <!-- Tracking status -->
<v:BranchTreeNodeTrackStatusPresenter Grid.Column="2" <v:BranchTreeNodeTrackStatusPresenter Grid.Column="2"
VerticalAlignment="Center" VerticalAlignment="Center"
FontFamily="{DynamicResource Fonts.Monospace}" FontFamily="{DynamicResource Fonts.Monospace}"
FontSize="10" FontSize="10"
Foreground="{DynamicResource Brush.BadgeFG}" Foreground="{DynamicResource Brush.BadgeFG}"
Background="{DynamicResource Brush.Badge}"/> Background="{DynamicResource Brush.Badge}"/>
<!-- Filter Toggle Button --> <!-- Filter Toggle Button -->
<ToggleButton Grid.Column="3" <ToggleButton Grid.Column="3"
Classes="filter" Classes="filter"
Margin="0,0,8,0" Margin="0,0,8,0"
Background="Transparent" Background="Transparent"
IsVisible="{Binding IsBranch}" IsVisible="{Binding IsBranch}"
IsChecked="{Binding IsFiltered}" IsChecked="{Binding IsFiltered}"
Click="OnToggleFilterClicked" Click="OnToggleFilterClicked"
ToolTip.Tip="{DynamicResource Text.Filter}"/> ToolTip.Tip="{DynamicResource Text.Filter}"/>
</Grid> </Grid>
</Grid> </Grid>
</DataTemplate> </DataTemplate>

View file

@ -26,7 +26,8 @@
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}" Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
Background="Transparent" Background="Transparent"
ContextRequested="OnRowContextRequested" ContextRequested="OnRowContextRequested"
DoubleTapped="OnDoubleTappedNode"> DoubleTapped="OnDoubleTappedNode"
ToolTip.Tip="{Binding ToolTip}">
<v:TagTreeNodeToggleButton Grid.Column="0" <v:TagTreeNodeToggleButton Grid.Column="0"
Classes="tree_expander" Classes="tree_expander"
Focusable="False" Focusable="False"
@ -64,7 +65,10 @@
SelectionChanged="OnRowSelectionChanged"> SelectionChanged="OnRowSelectionChanged">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate DataType="m:Tag"> <DataTemplate DataType="m:Tag">
<Grid ColumnDefinitions="Auto,*,Auto" Background="Transparent" ContextRequested="OnRowContextRequested"> <Grid ColumnDefinitions="Auto,*,Auto"
Background="Transparent"
ContextRequested="OnRowContextRequested"
ToolTip.Tip="{Binding Message}">
<Path Grid.Column="0" <Path Grid.Column="0"
Width="10" Height="10" Width="10" Height="10"
Margin="8,0,0,0" Margin="8,0,0,0"