From afc8a772dd582a2eaaa1b1100a8bd70614418a0a Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 13 May 2025 12:26:33 +0800 Subject: [PATCH] ux: new style for tag's tooltip (#1305) --- src/Commands/Discard.cs | 2 +- src/Commands/QueryTags.cs | 11 ++++--- src/Models/Tag.cs | 1 + src/ViewModels/TagCollection.cs | 21 +++++++++--- src/Views/TagsView.axaml | 57 ++++++++++++++++++++++++--------- 5 files changed, 66 insertions(+), 26 deletions(-) diff --git a/src/Commands/Discard.cs b/src/Commands/Discard.cs index fcbe8591..e61fe1e6 100644 --- a/src/Commands/Discard.cs +++ b/src/Commands/Discard.cs @@ -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(); diff --git a/src/Commands/QueryTags.cs b/src/Commands/QueryTags.cs index b0264beb..f830a189 100644 --- a/src/Commands/QueryTags.cs +++ b/src/Commands/QueryTags.cs @@ -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 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, }); } diff --git a/src/Models/Tag.cs b/src/Models/Tag.cs index 51681d93..20678530 100644 --- a/src/Models/Tag.cs +++ b/src/Models/Tag.cs @@ -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; diff --git a/src/ViewModels/TagCollection.cs b/src/ViewModels/TagCollection.cs index cecb41d5..2f503a83 100644 --- a/src/ViewModels/TagCollection.cs +++ b/src/ViewModels/TagCollection.cs @@ -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 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; } diff --git a/src/Views/TagsView.axaml b/src/Views/TagsView.axaml index 53b325d3..0c66e8a6 100644 --- a/src/Views/TagsView.axaml +++ b/src/Views/TagsView.axaml @@ -26,11 +26,26 @@ SelectionChanged="OnRowSelectionChanged"> - + + + + + + + + + + + + + + + + + + VerticalAlignment="Center"> - - - + @@ -71,18 +85,31 @@ - + + + + + + + + + + + + + + + - - - +