mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
feature: double click on commit (#295)
* when commit is current branch head, do nothing * when commit is head of some local branch which is not current, try to checkout this branch * otherwise, ask user should checkout selected commit as deteched
This commit is contained in:
parent
b18f86dde9
commit
addfb449cc
3 changed files with 34 additions and 1 deletions
|
@ -142,6 +142,28 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DoubleTapped(Models.Commit commit)
|
||||||
|
{
|
||||||
|
if (commit == null || commit.IsCurrentHead)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var d in commit.Decorators)
|
||||||
|
{
|
||||||
|
if (d.Type == Models.DecoratorType.LocalBranchHead)
|
||||||
|
{
|
||||||
|
var b = _repo.Branches.Find(x => x.FriendlyName == d.Name);
|
||||||
|
if (b != null)
|
||||||
|
{
|
||||||
|
_repo.CheckoutBranch(b);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PopupHost.CanCreatePopup())
|
||||||
|
PopupHost.ShowPopup(new CheckoutCommit(_repo, commit));
|
||||||
|
}
|
||||||
|
|
||||||
public ContextMenu MakeContextMenu(DataGrid datagrid)
|
public ContextMenu MakeContextMenu(DataGrid datagrid)
|
||||||
{
|
{
|
||||||
if (datagrid.SelectedItems.Count != 1)
|
if (datagrid.SelectedItems.Count != 1)
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
VerticalScrollBarVisibility="Auto"
|
VerticalScrollBarVisibility="Auto"
|
||||||
LayoutUpdated="OnCommitDataGridLayoutUpdated"
|
LayoutUpdated="OnCommitDataGridLayoutUpdated"
|
||||||
SelectionChanged="OnCommitDataGridSelectionChanged"
|
SelectionChanged="OnCommitDataGridSelectionChanged"
|
||||||
ContextRequested="OnCommitDataGridContextRequested">
|
ContextRequested="OnCommitDataGridContextRequested"
|
||||||
|
DoubleTapped="OnCommitDataGridDoubleTapped">
|
||||||
<DataGrid.Styles>
|
<DataGrid.Styles>
|
||||||
<Style Selector="DataGridColumnHeader">
|
<Style Selector="DataGridColumnHeader">
|
||||||
<Setter Property="MinHeight" Value="24"/>
|
<Setter Property="MinHeight" Value="24"/>
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
@ -409,5 +410,14 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnCommitDataGridDoubleTapped(object sender, TappedEventArgs e)
|
||||||
|
{
|
||||||
|
if (DataContext is ViewModels.Histories histories && sender is DataGrid datagrid && datagrid.SelectedItems is { Count: 1 } selectedItems)
|
||||||
|
{
|
||||||
|
histories.DoubleTapped(selectedItems[0] as Models.Commit);
|
||||||
|
}
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue