mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
feature: supports to visit remote repository in web browser (#1265)
- combine `Open in File Manager`, `Open in Terminal` and `Open with external editor` into one dropdown menu - add `Visit $REMOTE in Browser` Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
e4e2f7b3a7
commit
93a5d7baea
5 changed files with 73 additions and 36 deletions
|
@ -626,6 +626,7 @@
|
||||||
<x:String x:Key="Text.Repository.Terminal" xml:space="preserve">Open in Terminal</x:String>
|
<x:String x:Key="Text.Repository.Terminal" xml:space="preserve">Open in Terminal</x:String>
|
||||||
<x:String x:Key="Text.Repository.UseRelativeTimeInHistories" xml:space="preserve">Use relative time in histories</x:String>
|
<x:String x:Key="Text.Repository.UseRelativeTimeInHistories" xml:space="preserve">Use relative time in histories</x:String>
|
||||||
<x:String x:Key="Text.Repository.ViewLogs" xml:space="preserve">View Logs</x:String>
|
<x:String x:Key="Text.Repository.ViewLogs" xml:space="preserve">View Logs</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Visit" xml:space="preserve">Visit '{0}' in Browser</x:String>
|
||||||
<x:String x:Key="Text.Repository.Worktrees" xml:space="preserve">WORKTREES</x:String>
|
<x:String x:Key="Text.Repository.Worktrees" xml:space="preserve">WORKTREES</x:String>
|
||||||
<x:String x:Key="Text.Repository.Worktrees.Add" xml:space="preserve">ADD WORKTREE</x:String>
|
<x:String x:Key="Text.Repository.Worktrees.Add" xml:space="preserve">ADD WORKTREE</x:String>
|
||||||
<x:String x:Key="Text.Repository.Worktrees.Prune" xml:space="preserve">PRUNE</x:String>
|
<x:String x:Key="Text.Repository.Worktrees.Prune" xml:space="preserve">PRUNE</x:String>
|
||||||
|
|
|
@ -630,6 +630,7 @@
|
||||||
<x:String x:Key="Text.Repository.Terminal" xml:space="preserve">在终端中打开</x:String>
|
<x:String x:Key="Text.Repository.Terminal" xml:space="preserve">在终端中打开</x:String>
|
||||||
<x:String x:Key="Text.Repository.UseRelativeTimeInHistories" xml:space="preserve">在提交列表中使用相对时间</x:String>
|
<x:String x:Key="Text.Repository.UseRelativeTimeInHistories" xml:space="preserve">在提交列表中使用相对时间</x:String>
|
||||||
<x:String x:Key="Text.Repository.ViewLogs" xml:space="preserve">查看命令日志</x:String>
|
<x:String x:Key="Text.Repository.ViewLogs" xml:space="preserve">查看命令日志</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Visit" xml:space="preserve">访问远程仓库 '{0}'</x:String>
|
||||||
<x:String x:Key="Text.Repository.Worktrees" xml:space="preserve">工作树列表</x:String>
|
<x:String x:Key="Text.Repository.Worktrees" xml:space="preserve">工作树列表</x:String>
|
||||||
<x:String x:Key="Text.Repository.Worktrees.Add" xml:space="preserve">新增工作树</x:String>
|
<x:String x:Key="Text.Repository.Worktrees.Add" xml:space="preserve">新增工作树</x:String>
|
||||||
<x:String x:Key="Text.Repository.Worktrees.Prune" xml:space="preserve">清理</x:String>
|
<x:String x:Key="Text.Repository.Worktrees.Prune" xml:space="preserve">清理</x:String>
|
||||||
|
|
|
@ -630,6 +630,7 @@
|
||||||
<x:String x:Key="Text.Repository.Terminal" xml:space="preserve">在終端機中開啟</x:String>
|
<x:String x:Key="Text.Repository.Terminal" xml:space="preserve">在終端機中開啟</x:String>
|
||||||
<x:String x:Key="Text.Repository.UseRelativeTimeInHistories" xml:space="preserve">在提交列表中使用相對時間</x:String>
|
<x:String x:Key="Text.Repository.UseRelativeTimeInHistories" xml:space="preserve">在提交列表中使用相對時間</x:String>
|
||||||
<x:String x:Key="Text.Repository.ViewLogs" xml:space="preserve">檢視 Git 指令記錄</x:String>
|
<x:String x:Key="Text.Repository.ViewLogs" xml:space="preserve">檢視 Git 指令記錄</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Visit" xml:space="preserve">檢視遠端存放庫 '{0}'</x:String>
|
||||||
<x:String x:Key="Text.Repository.Worktrees" xml:space="preserve">工作區列表</x:String>
|
<x:String x:Key="Text.Repository.Worktrees" xml:space="preserve">工作區列表</x:String>
|
||||||
<x:String x:Key="Text.Repository.Worktrees.Add" xml:space="preserve">新增工作區</x:String>
|
<x:String x:Key="Text.Repository.Worktrees.Add" xml:space="preserve">新增工作區</x:String>
|
||||||
<x:String x:Key="Text.Repository.Worktrees.Prune" xml:space="preserve">清理</x:String>
|
<x:String x:Key="Text.Repository.Worktrees.Prune" xml:space="preserve">清理</x:String>
|
||||||
|
|
|
@ -583,45 +583,87 @@ namespace SourceGit.ViewModels
|
||||||
Task.Run(RefreshStashes);
|
Task.Run(RefreshStashes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenInFileManager()
|
|
||||||
{
|
|
||||||
Native.OS.OpenInFileManager(_fullpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenInTerminal()
|
|
||||||
{
|
|
||||||
Native.OS.OpenTerminal(_fullpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContextMenu CreateContextMenuForExternalTools()
|
public ContextMenu CreateContextMenuForExternalTools()
|
||||||
{
|
{
|
||||||
var tools = Native.OS.ExternalTools;
|
|
||||||
if (tools.Count == 0)
|
|
||||||
{
|
|
||||||
App.RaiseException(_fullpath, "No available external editors found!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var menu = new ContextMenu();
|
var menu = new ContextMenu();
|
||||||
menu.Placement = PlacementMode.BottomEdgeAlignedLeft;
|
menu.Placement = PlacementMode.BottomEdgeAlignedLeft;
|
||||||
|
|
||||||
RenderOptions.SetBitmapInterpolationMode(menu, BitmapInterpolationMode.HighQuality);
|
RenderOptions.SetBitmapInterpolationMode(menu, BitmapInterpolationMode.HighQuality);
|
||||||
|
RenderOptions.SetEdgeMode(menu, EdgeMode.Antialias);
|
||||||
|
RenderOptions.SetTextRenderingMode(menu, TextRenderingMode.Antialias);
|
||||||
|
|
||||||
foreach (var tool in tools)
|
var explore = new MenuItem();
|
||||||
|
explore.Header = App.Text("Repository.Explore");
|
||||||
|
explore.Icon = App.CreateMenuIcon("Icons.Explore");
|
||||||
|
explore.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
var dupTool = tool;
|
Native.OS.OpenInFileManager(_fullpath);
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
var item = new MenuItem();
|
var terminal = new MenuItem();
|
||||||
item.Header = App.Text("Repository.OpenIn", dupTool.Name);
|
terminal.Header = App.Text("Repository.Terminal");
|
||||||
item.Icon = new Image { Width = 16, Height = 16, Source = dupTool.IconImage };
|
terminal.Icon = App.CreateMenuIcon("Icons.Terminal");
|
||||||
item.Click += (_, e) =>
|
terminal.Click += (_, e) =>
|
||||||
|
{
|
||||||
|
Native.OS.OpenTerminal(_fullpath);
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
menu.Items.Add(explore);
|
||||||
|
menu.Items.Add(terminal);
|
||||||
|
|
||||||
|
var tools = Native.OS.ExternalTools;
|
||||||
|
if (tools.Count > 0)
|
||||||
|
{
|
||||||
|
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||||
|
|
||||||
|
foreach (var tool in Native.OS.ExternalTools)
|
||||||
{
|
{
|
||||||
dupTool.Open(_fullpath);
|
var dupTool = tool;
|
||||||
e.Handled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
menu.Items.Add(item);
|
var item = new MenuItem();
|
||||||
|
item.Header = App.Text("Repository.OpenIn", dupTool.Name);
|
||||||
|
item.Icon = new Image { Width = 16, Height = 16, Source = dupTool.IconImage };
|
||||||
|
item.Click += (_, e) =>
|
||||||
|
{
|
||||||
|
dupTool.Open(_fullpath);
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
menu.Items.Add(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var urls = new Dictionary<string, string>();
|
||||||
|
foreach (var r in _remotes)
|
||||||
|
{
|
||||||
|
if (r.TryGetVisitURL(out var visit))
|
||||||
|
urls.Add(r.Name, visit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (urls.Count > 0)
|
||||||
|
{
|
||||||
|
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||||
|
|
||||||
|
foreach (var url in urls)
|
||||||
|
{
|
||||||
|
var name = url.Key;
|
||||||
|
var addr = url.Value;
|
||||||
|
|
||||||
|
var item = new MenuItem();
|
||||||
|
item.Header = App.Text("Repository.Visit", name);
|
||||||
|
item.Icon = App.CreateMenuIcon("Icons.Remotes");
|
||||||
|
item.Click += (_, e) =>
|
||||||
|
{
|
||||||
|
Native.OS.OpenBrowser(addr);
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
menu.Items.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,8 @@
|
||||||
x:DataType="vm:Repository">
|
x:DataType="vm:Repository">
|
||||||
<Grid ColumnDefinitions="*,Auto,*">
|
<Grid ColumnDefinitions="*,Auto,*">
|
||||||
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="4,0,0,0">
|
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="4,0,0,0">
|
||||||
<Button Classes="icon_button" Width="32" Command="{Binding OpenInFileManager}" ToolTip.Tip="{DynamicResource Text.Repository.Explore}">
|
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Explore}" Margin="0,2,0,0"/>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button Classes="icon_button" Width="32" Click="OpenWithExternalTools" IsVisible="{Binding !IsBare}" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
|
<Button Classes="icon_button" Width="32" Click="OpenWithExternalTools" IsVisible="{Binding !IsBare}" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
|
||||||
<Path Width="13" Height="13" Data="{StaticResource Icons.OpenWith}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Explore}" Margin="0,2,0,0"/>
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button Classes="icon_button" Width="32" Command="{Binding OpenInTerminal}" ToolTip.Tip="{DynamicResource Text.Repository.Terminal}">
|
|
||||||
<Path Width="13" Height="13" Data="{StaticResource Icons.Terminal}"/>
|
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button Classes="icon_button" Width="32" Click="OpenGitLogs" ToolTip.Tip="{DynamicResource Text.Repository.ViewLogs}">
|
<Button Classes="icon_button" Width="32" Click="OpenGitLogs" ToolTip.Tip="{DynamicResource Text.Repository.ViewLogs}">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue