mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 11:44:59 +00:00
feature: supports display tags in a tree (#350)
This commit is contained in:
parent
f59af0afcf
commit
de2f70b8ea
11 changed files with 652 additions and 113 deletions
|
@ -2,7 +2,6 @@ using System;
|
|||
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
|
@ -30,6 +29,9 @@ namespace SourceGit.Views
|
|||
private void OnSearchKeyDown(object _, KeyEventArgs e)
|
||||
{
|
||||
var repo = DataContext as ViewModels.Repository;
|
||||
if (repo == null)
|
||||
return;
|
||||
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(repo.SearchCommitFilter))
|
||||
|
@ -79,46 +81,25 @@ namespace SourceGit.Views
|
|||
private void OnLocalBranchTreeSelectionChanged(object _1, RoutedEventArgs _2)
|
||||
{
|
||||
RemoteBranchTree.UnselectAll();
|
||||
TagsList.SelectedItem = null;
|
||||
TagsList.UnselectAll();
|
||||
}
|
||||
|
||||
private void OnRemoteBranchTreeSelectionChanged(object _1, RoutedEventArgs _2)
|
||||
{
|
||||
LocalBranchTree.UnselectAll();
|
||||
TagsList.SelectedItem = null;
|
||||
TagsList.UnselectAll();
|
||||
}
|
||||
|
||||
private void OnTagDataGridSelectionChanged(object sender, SelectionChangedEventArgs _)
|
||||
private void OnTagsRowsChanged(object _, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is DataGrid { SelectedItem: Models.Tag tag })
|
||||
{
|
||||
LocalBranchTree.UnselectAll();
|
||||
RemoteBranchTree.UnselectAll();
|
||||
|
||||
if (DataContext is ViewModels.Repository repo)
|
||||
repo.NavigateToCommit(tag.SHA);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTagContextRequested(object sender, ContextRequestedEventArgs e)
|
||||
{
|
||||
if (sender is DataGrid { SelectedItem: Models.Tag tag } grid && DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForTag(tag);
|
||||
grid.OpenContextMenu(menu);
|
||||
}
|
||||
|
||||
UpdateLeftSidebarLayout();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnTagFilterIsCheckedChanged(object sender, RoutedEventArgs e)
|
||||
private void OnTagsSelectionChanged(object _1, RoutedEventArgs _2)
|
||||
{
|
||||
if (sender is ToggleButton { DataContext: Models.Tag tag } toggle && DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
repo.UpdateFilter(tag.Name, toggle.IsChecked == true);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
LocalBranchTree.UnselectAll();
|
||||
RemoteBranchTree.UnselectAll();
|
||||
}
|
||||
|
||||
private void OnSubmoduleContextRequested(object sender, ContextRequestedEventArgs e)
|
||||
|
@ -188,7 +169,7 @@ namespace SourceGit.Views
|
|||
var localBranchRows = vm.IsLocalBranchGroupExpanded ? LocalBranchTree.Rows.Count : 0;
|
||||
var remoteBranchRows = vm.IsRemoteGroupExpanded ? RemoteBranchTree.Rows.Count : 0;
|
||||
var desiredBranches = (localBranchRows + remoteBranchRows) * 24.0;
|
||||
var desiredTag = vm.IsTagGroupExpanded ? TagsList.RowHeight * vm.VisibleTags.Count : 0;
|
||||
var desiredTag = vm.IsTagGroupExpanded ? 24.0 * TagsList.Rows : 0;
|
||||
var desiredSubmodule = vm.IsSubmoduleGroupExpanded ? SubmoduleList.RowHeight * vm.Submodules.Count : 0;
|
||||
var desiredWorktree = vm.IsWorktreeGroupExpanded ? WorktreeList.RowHeight * vm.Worktrees.Count : 0;
|
||||
var desiredOthers = desiredTag + desiredSubmodule + desiredWorktree;
|
||||
|
@ -295,9 +276,12 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private void OnSearchSuggestionBoxKeyDown(object sender, KeyEventArgs e)
|
||||
private void OnSearchSuggestionBoxKeyDown(object _, KeyEventArgs e)
|
||||
{
|
||||
var repo = DataContext as ViewModels.Repository;
|
||||
if (repo == null)
|
||||
return;
|
||||
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
repo.IsSearchCommitSuggestionOpen = false;
|
||||
|
@ -317,6 +301,9 @@ namespace SourceGit.Views
|
|||
private void OnSearchSuggestionDoubleTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
var repo = DataContext as ViewModels.Repository;
|
||||
if (repo == null)
|
||||
return;
|
||||
|
||||
var content = (sender as StackPanel)?.DataContext as string;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue