feature: add button to navigate to current HEAD (#50)

This commit is contained in:
leo 2024-04-02 20:54:19 +08:00
parent 09720f81d4
commit d986aa7165
7 changed files with 32 additions and 1 deletions

View file

@ -87,4 +87,5 @@
<StreamGeometry x:Key="Icons.LayoutVertical">M875 117H149C109 117 75 151 75 192v640c0 41 34 75 75 75h725c41 0 75-34 75-75V192c0-41-34-75-75-75zm-725 64h725c6 0 11 4 11 11v288h-747V192c0-6 4-11 11-11zm725 661H149c-6 0-11-4-11-11V544h747V832c0 6-4 11-11 11z</StreamGeometry>
<StreamGeometry x:Key="Icons.SyntaxHighlight">M875 128h-725A107 107 0 0043 235v555A107 107 0 00149 896h725a107 107 0 00107-107v-555A107 107 0 00875 128zm-115 640h-183v-58l25-3c15 0 19-8 14-24l-22-61H419l-28 82 39 2V768h-166v-58l18-3c18-2 22-11 26-24l125-363-40-4V256h168l160 448 39 3zM506 340l-72 218h145l-71-218h-2z</StreamGeometry>
<StreamGeometry x:Key="Icons.SoftwareUpdate">M900 287c40 69 60 144 60 225s-20 156-60 225c-40 69-94 123-163 163-69 40-144 60-225 60s-156-20-225-60c-69-40-123-94-163-163C84 668 64 593 64 512s20-156 60-225 94-123 163-163c69-40 144-60 225-60s156 20 225 60 123 94 163 163zM762 512c0-9-3-16-9-22L578 315l-44-44c-6-6-13-9-22-9s-16 3-22 9l-44 44-176 176c-6 6-9 13-9 22s3 16 9 22l44 44c6 6 13 9 22 9s16-3 22-9l92-92v269c0 9 3 16 9 22 6 6 13 9 22 9h62c8 0 16-3 22-9 6-6 9-13 9-22V486l92 92c6 6 13 9 22 9 8 0 16-3 22-9l44-44c6-6 9-13 9-22z</StreamGeometry>
<StreamGeometry x:Key="Icons.Target">M765 555C747 661 661 747 555 765L555 683 469 683 469 765C363 747 277 661 259 555L341 555 341 469 259 469C277 363 363 277 469 259L469 341 555 341 555 259C661 277 747 363 765 469L683 469 683 555 765 555M851 469C832 315 709 192 555 173L555 85 469 85 469 173C315 192 192 315 173 469L85 469 85 555 173 555C192 709 315 832 469 851L469 939 555 939 555 851C709 832 832 709 851 555L939 555 939 469 851 469M512 427C559 427 597 465 597 512 597 559 559 597 512 597 465 597 427 559 427 512 427 465 465 427 512 427L512 427Z</StreamGeometry>
</ResourceDictionary>

View file

@ -3003,6 +3003,15 @@ namespace SourceGit.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Navigate To HEAD.
/// </summary>
public static string Text_Repository_NavigateToCurrentHead {
get {
return ResourceManager.GetString("Text.Repository.NavigateToCurrentHead", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to NEW BRANCH.
/// </summary>

View file

@ -1338,4 +1338,7 @@
<data name="Text.InProgress.Merge" xml:space="preserve">
<value>Merge request in progress. Press 'Abort' to restore original HEAD.</value>
</data>
<data name="Text.Repository.NavigateToCurrentHead" xml:space="preserve">
<value>Navigate To HEAD</value>
</data>
</root>

View file

@ -1338,4 +1338,7 @@
<data name="Text.InProgress.Merge" xml:space="preserve">
<value>Merge request in progress. Press 'Abort' to restore original HEAD.</value>
</data>
<data name="Text.Repository.NavigateToCurrentHead" xml:space="preserve">
<value>Navigate To HEAD</value>
</data>
</root>

View file

@ -1338,4 +1338,7 @@
<data name="Text.InProgress.Merge" xml:space="preserve">
<value>合并操作进行中。点击【终止】回滚到操作前的状态。</value>
</data>
<data name="Text.Repository.NavigateToCurrentHead" xml:space="preserve">
<value>定位HEAD</value>
</data>
</root>

View file

@ -414,6 +414,13 @@ namespace SourceGit.ViewModels
}
}
public void NavigateToCurrentHead()
{
var cur = Branches.Find(x => x.IsCurrent);
if (cur != null)
NavigateToCommit(cur.Head);
}
public void UpdateFilter(string filter, bool toggle)
{
var changed = false;

View file

@ -116,7 +116,12 @@
<!-- Left Normal Mode -->
<Grid Grid.Column="0" RowDefinitions="28,Auto,28,Auto,28,*,28,Auto,28,Auto" Margin="0,0,0,4" IsVisible="{Binding !IsSearching}">
<!-- WorkingCopy -->
<TextBlock Grid.Row="0" Classes="group_header_label" Text="{DynamicResource Text.Repository.Workspace}"/>
<Grid Grid.Row="0" ColumnDefinitions="*,Auto">
<TextBlock Grid.Column="0" Classes="group_header_label" Text="{DynamicResource Text.Repository.Workspace}"/>
<Button Grid.Column="1" Classes="icon_button" Width="14" Margin="8,0" Command="{Binding NavigateToCurrentHead}" ToolTip.Tip="{DynamicResource Text.Repository.NavigateToCurrentHead}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Target}"/>
</Button>
</Grid>
<ListBox Grid.Row="1" Classes="page_switcher" Background="Transparent" SelectedIndex="{Binding SelectedViewIndex, Mode=TwoWay}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>