mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
Merge pull request #191 from ennerperez/feature/q-open-submodule
Quick open submodule
This commit is contained in:
commit
02ace694d0
3 changed files with 34 additions and 17 deletions
|
@ -1538,16 +1538,12 @@ namespace SourceGit.ViewModels
|
|||
return menu;
|
||||
}
|
||||
|
||||
public ContextMenu CreateContextMenuForSubmodule(string submodule)
|
||||
{
|
||||
var open = new MenuItem();
|
||||
open.Header = App.Text("Submodule.Open");
|
||||
open.Icon = App.CreateMenuIcon("Icons.Folder.Open");
|
||||
open.Click += (o, ev) =>
|
||||
public void OpenSubmodule(string submodule)
|
||||
{
|
||||
var root = Path.GetFullPath(Path.Combine(_fullpath, submodule));
|
||||
var gitDir = new Commands.QueryGitDir(root).Result();
|
||||
var repo = Preference.AddRepository(root, gitDir);
|
||||
|
||||
var node = new RepositoryNode()
|
||||
{
|
||||
Id = repo.FullPath,
|
||||
|
@ -1561,7 +1557,16 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
launcher.OpenRepositoryInTab(node, null);
|
||||
}
|
||||
}
|
||||
|
||||
public ContextMenu CreateContextMenuForSubmodule(string submodule)
|
||||
{
|
||||
var open = new MenuItem();
|
||||
open.Header = App.Text("Submodule.Open");
|
||||
open.Icon = App.CreateMenuIcon("Icons.Folder.Open");
|
||||
open.Click += (o, ev) =>
|
||||
{
|
||||
OpenSubmodule(submodule);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
|
|
|
@ -457,6 +457,7 @@
|
|||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
ContextRequested="OnSubmoduleContextRequested"
|
||||
DoubleTapped="OnDoubleTappedSubmodule"
|
||||
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}">
|
||||
<DataGrid.Styles>
|
||||
<Style Selector="DataGridRow">
|
||||
|
|
|
@ -332,5 +332,16 @@ namespace SourceGit.Views
|
|||
outs.Add(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDoubleTappedSubmodule(object sender, TappedEventArgs e)
|
||||
{
|
||||
if (sender is DataGrid datagrid && datagrid.SelectedItem != null && DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var submodule = datagrid.SelectedItem as string;
|
||||
(DataContext as ViewModels.Repository).OpenSubmodule(submodule);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue