feature: add a context menu item to open all repositories in a group (#179)

This commit is contained in:
leo 2024-06-18 11:07:48 +08:00
parent 4217d62f47
commit 06245320a9
No known key found for this signature in database
GPG key ID: B528468E49CD0E58
4 changed files with 34 additions and 0 deletions

View file

@ -493,6 +493,7 @@
<x:String x:Key="Text.Welcome.Delete" xml:space="preserve">Delete</x:String> <x:String x:Key="Text.Welcome.Delete" xml:space="preserve">Delete</x:String>
<x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">DRAG &amp; DROP FOLDER SUPPORTED. CUSTOM GROUPING SUPPORTED.</x:String> <x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">DRAG &amp; DROP FOLDER SUPPORTED. CUSTOM GROUPING SUPPORTED.</x:String>
<x:String x:Key="Text.Welcome.Edit" xml:space="preserve">Edit</x:String> <x:String x:Key="Text.Welcome.Edit" xml:space="preserve">Edit</x:String>
<x:String x:Key="Text.Welcome.OpenAllInNode" xml:space="preserve">Open All Repositories</x:String>
<x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">Open Repository</x:String> <x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">Open Repository</x:String>
<x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">Open Terminal</x:String> <x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">Open Terminal</x:String>
<x:String x:Key="Text.Welcome.Search" xml:space="preserve">Search Repositories...</x:String> <x:String x:Key="Text.Welcome.Search" xml:space="preserve">Search Repositories...</x:String>

View file

@ -495,6 +495,7 @@
<x:String x:Key="Text.Welcome.Delete" xml:space="preserve">删除</x:String> <x:String x:Key="Text.Welcome.Delete" xml:space="preserve">删除</x:String>
<x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">支持拖放目录添加。支持自定义分组。</x:String> <x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">支持拖放目录添加。支持自定义分组。</x:String>
<x:String x:Key="Text.Welcome.Edit" xml:space="preserve">编辑</x:String> <x:String x:Key="Text.Welcome.Edit" xml:space="preserve">编辑</x:String>
<x:String x:Key="Text.Welcome.OpenAllInNode" xml:space="preserve">打开所有包含仓库</x:String>
<x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">打开本地仓库</x:String> <x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">打开本地仓库</x:String>
<x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">打开终端</x:String> <x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">打开终端</x:String>
<x:String x:Key="Text.Welcome.Search" xml:space="preserve">快速查找仓库...</x:String> <x:String x:Key="Text.Welcome.Search" xml:space="preserve">快速查找仓库...</x:String>

View file

@ -495,6 +495,7 @@
<x:String x:Key="Text.Welcome.Delete" xml:space="preserve">刪除</x:String> <x:String x:Key="Text.Welcome.Delete" xml:space="preserve">刪除</x:String>
<x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">支援拖放目錄新增。支援自定義分組。</x:String> <x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">支援拖放目錄新增。支援自定義分組。</x:String>
<x:String x:Key="Text.Welcome.Edit" xml:space="preserve">編輯</x:String> <x:String x:Key="Text.Welcome.Edit" xml:space="preserve">編輯</x:String>
<x:String x:Key="Text.Welcome.OpenAllInNode" xml:space="preserve">打開所有包含倉庫</x:String>
<x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">開啟本地倉庫</x:String> <x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">開啟本地倉庫</x:String>
<x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">開啟終端</x:String> <x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">開啟終端</x:String>
<x:String x:Key="Text.Welcome.Search" xml:space="preserve">快速查詢倉庫...</x:String> <x:String x:Key="Text.Welcome.Search" xml:space="preserve">快速查詢倉庫...</x:String>

View file

@ -92,6 +92,26 @@ namespace SourceGit.ViewModels
var menu = new ContextMenu(); var menu = new ContextMenu();
var hasRepo = Preference.FindRepository(node.Id) != null; var hasRepo = Preference.FindRepository(node.Id) != null;
if (!node.IsRepository && node.SubNodes.Count > 0)
{
var openAll = new MenuItem();
openAll.Header = App.Text("Welcome.OpenAllInNode");
openAll.Icon = App.CreateMenuIcon("Icons.Folder.Open");
openAll.Click += (_, e) =>
{
if (App.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
var launcher = desktop.MainWindow.DataContext as Launcher;
OpenAllInNode(launcher, node);
}
e.Handled = true;
};
menu.Items.Add(openAll);
menu.Items.Add(new MenuItem() { Header = "-" });
}
var edit = new MenuItem(); var edit = new MenuItem();
edit.Header = App.Text("Welcome.Edit"); edit.Header = App.Text("Welcome.Edit");
edit.Icon = App.CreateMenuIcon("Icons.Edit"); edit.Icon = App.CreateMenuIcon("Icons.Edit");
@ -201,6 +221,17 @@ namespace SourceGit.ViewModels
} }
} }
private void OpenAllInNode(Launcher launcher, RepositoryNode node)
{
foreach (var subNode in node.SubNodes)
{
if (subNode.IsRepository)
launcher.OpenRepositoryInTab(subNode, null);
else if (subNode.SubNodes.Count > 0)
OpenAllInNode(launcher, subNode);
}
}
private static Welcome _instance = new Welcome(); private static Welcome _instance = new Welcome();
private string _searchFilter = string.Empty; private string _searchFilter = string.Empty;
} }