mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
feat: context menu for a commit in commit message (#734)
* feat: context menu for a commit in commit message When a commit message happens to contain a commit link and the user elects to right-click it, instead of navigating them to the commit, present a menu with options to navigate to it or to copy SHA. * feat: show commit tooltip as well `_lastHover` in the `if` is also swapped for `match`for consistency with the block body
This commit is contained in:
parent
693940368b
commit
12f75315bd
9 changed files with 51 additions and 2 deletions
|
@ -597,6 +597,7 @@
|
|||
<x:String x:Key="Text.SelfUpdate.IgnoreThisVersion" xml:space="preserve">Diese Version überspringen</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.Title" xml:space="preserve">Software Update</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.UpToDate" xml:space="preserve">Es sind momentan kein Updates verfügbar.</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.CopySHA" xml:space="preserve">SHA kopieren</x:String>
|
||||
<x:String x:Key="Text.Squash" xml:space="preserve">Squash Commits</x:String>
|
||||
<x:String x:Key="Text.Squash.Into" xml:space="preserve">In:</x:String>
|
||||
<x:String x:Key="Text.SSHKey" xml:space="preserve">SSH privater Schlüssel:</x:String>
|
||||
|
|
|
@ -601,6 +601,8 @@
|
|||
<x:String x:Key="Text.SelfUpdate.IgnoreThisVersion" xml:space="preserve">Skip This Version</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.Title" xml:space="preserve">Software Update</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.UpToDate" xml:space="preserve">There are currently no updates available.</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.CopySHA" xml:space="preserve">Copy SHA</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.NavigateTo" xml:space="preserve">Go to</x:String>
|
||||
<x:String x:Key="Text.Squash" xml:space="preserve">Squash Commits</x:String>
|
||||
<x:String x:Key="Text.Squash.Into" xml:space="preserve">Into:</x:String>
|
||||
<x:String x:Key="Text.SSHKey" xml:space="preserve">SSH Private Key:</x:String>
|
||||
|
|
|
@ -592,6 +592,7 @@
|
|||
<x:String x:Key="Text.SelfUpdate.IgnoreThisVersion" xml:space="preserve">Omitir Esta Versión</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.Title" xml:space="preserve">Actualización de Software</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.UpToDate" xml:space="preserve">Actualmente no hay actualizaciones disponibles.</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.CopySHA" xml:space="preserve">Copiar SHA</x:String>
|
||||
<x:String x:Key="Text.Squash" xml:space="preserve">Squash Commits</x:String>
|
||||
<x:String x:Key="Text.Squash.Into" xml:space="preserve">En:</x:String>
|
||||
<x:String x:Key="Text.SSHKey" xml:space="preserve">Clave Privada SSH:</x:String>
|
||||
|
|
|
@ -590,6 +590,7 @@
|
|||
<x:String x:Key="Text.SelfUpdate.IgnoreThisVersion" xml:space="preserve">Passer cette version</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.Title" xml:space="preserve">Mise à jour du logiciel</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.UpToDate" xml:space="preserve">Il n'y a pas de mise à jour pour le moment.</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.CopySHA" xml:space="preserve">Copier le SHA</x:String>
|
||||
<x:String x:Key="Text.Squash" xml:space="preserve">Squash Commits</x:String>
|
||||
<x:String x:Key="Text.Squash.Into" xml:space="preserve">Dans :</x:String>
|
||||
<x:String x:Key="Text.SSHKey" xml:space="preserve">SSH Private Key:</x:String>
|
||||
|
|
|
@ -625,6 +625,7 @@
|
|||
<x:String x:Key="Text.SelfUpdate.IgnoreThisVersion" xml:space="preserve">Ignorar esta versão</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.Title" xml:space="preserve">Atualização de Software</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.UpToDate" xml:space="preserve">Não há atualizações disponíveis no momento.</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.CopySHA" xml:space="preserve">Copiar SHA</x:String>
|
||||
<x:String x:Key="Text.Squash" xml:space="preserve">Squash Commits</x:String>
|
||||
<x:String x:Key="Text.Squash.Into" xml:space="preserve">Squash commits em:</x:String>
|
||||
<x:String x:Key="Text.SSHKey" xml:space="preserve">Chave SSH Privada:</x:String>
|
||||
|
|
|
@ -592,6 +592,8 @@
|
|||
<x:String x:Key="Text.SaveAsPatchSuccess" xml:space="preserve">Исправление успешно сохранено!</x:String>
|
||||
<x:String x:Key="Text.ScanRepositories" xml:space="preserve">Сканирование хранилищ</x:String>
|
||||
<x:String x:Key="Text.ScanRepositories.RootDir" xml:space="preserve">Корневой каталог:</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.CopySHA" xml:space="preserve">Копировать SHA</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.NavigateTo" xml:space="preserve">Перейти</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate" xml:space="preserve">Проверка для обновления...</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.Available" xml:space="preserve">Доступна новая версия этого программного обеспечения: </x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.Error" xml:space="preserve">Не удалось проверить наличие обновлений!</x:String>
|
||||
|
|
|
@ -605,6 +605,7 @@
|
|||
<x:String x:Key="Text.SelfUpdate.IgnoreThisVersion" xml:space="preserve">忽略此版本</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.Title" xml:space="preserve">软件更新</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.UpToDate" xml:space="preserve">当前已是最新版本。</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.CopySHA" xml:space="preserve">复制提交指纹</x:String>
|
||||
<x:String x:Key="Text.Squash" xml:space="preserve">压缩为单个提交</x:String>
|
||||
<x:String x:Key="Text.Squash.Into" xml:space="preserve">合并入:</x:String>
|
||||
<x:String x:Key="Text.SSHKey" xml:space="preserve">SSH密钥 :</x:String>
|
||||
|
|
|
@ -604,6 +604,7 @@
|
|||
<x:String x:Key="Text.SelfUpdate.IgnoreThisVersion" xml:space="preserve">忽略此版本</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.Title" xml:space="preserve">軟體更新</x:String>
|
||||
<x:String x:Key="Text.SelfUpdate.UpToDate" xml:space="preserve">目前已是最新版本。</x:String>
|
||||
<x:String x:Key="Text.SHALinkCM.CopySHA" xml:space="preserve">複製提交編號</x:String>
|
||||
<x:String x:Key="Text.Squash" xml:space="preserve">壓縮為單個提交</x:String>
|
||||
<x:String x:Key="Text.Squash.Into" xml:space="preserve">合併入:</x:String>
|
||||
<x:String x:Key="Text.SSHKey" xml:space="preserve">SSH 金鑰:</x:String>
|
||||
|
|
|
@ -7,6 +7,7 @@ using Avalonia.Collections;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Documents;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace SourceGit.Views
|
||||
|
@ -149,11 +150,16 @@ namespace SourceGit.Views
|
|||
SetCurrentValue(CursorProperty, Cursor.Parse("Hand"));
|
||||
|
||||
_lastHover = match;
|
||||
if (!_lastHover.IsCommitSHA)
|
||||
if (!match.IsCommitSHA)
|
||||
{
|
||||
ToolTip.SetTip(this, match.Link);
|
||||
ToolTip.SetIsOpen(this, true);
|
||||
}
|
||||
else if (this.FindAncestorOfType<CommitBaseInfo>() is { DataContext: ViewModels.CommitDetail detail } && detail.GetParent(match.Link) is Models.Commit c)
|
||||
{
|
||||
ToolTip.SetTip(this, c);
|
||||
ToolTip.SetIsOpen(this, true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -172,7 +178,40 @@ namespace SourceGit.Views
|
|||
{
|
||||
var parentView = this.FindAncestorOfType<CommitBaseInfo>();
|
||||
if (parentView is { DataContext: ViewModels.CommitDetail detail })
|
||||
detail.NavigateTo(_lastHover.Link);
|
||||
{
|
||||
var point = e.GetCurrentPoint(this);
|
||||
var link = _lastHover.Link;
|
||||
|
||||
if (point.Properties.IsLeftButtonPressed)
|
||||
{
|
||||
detail.NavigateTo(_lastHover.Link);
|
||||
}
|
||||
else if (point.Properties.IsRightButtonPressed)
|
||||
{
|
||||
var open = new MenuItem();
|
||||
open.Header = App.Text("SHALinkCM.NavigateTo");
|
||||
open.Icon = App.CreateMenuIcon("Icons.Commit");
|
||||
open.Click += (_, ev) =>
|
||||
{
|
||||
detail.NavigateTo(_lastHover.Link);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var copy = new MenuItem();
|
||||
copy.Header = App.Text("SHALinkCM.CopySHA");
|
||||
copy.Icon = App.CreateMenuIcon("Icons.Copy");
|
||||
copy.Click += (_, ev) =>
|
||||
{
|
||||
App.CopyText(link);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(open);
|
||||
menu.Items.Add(copy);
|
||||
menu.Open(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue