diff --git a/src/Models/Repository.cs b/src/Models/Repository.cs index ef1d9a9d..9f8cfedc 100644 --- a/src/Models/Repository.cs +++ b/src/Models/Repository.cs @@ -24,7 +24,16 @@ namespace SourceGit.Models { public class Repository { #region PROPERTIES_SAVED - public string Name { get; set; } = ""; + public string Name { + get => name; + set { + if (name != value) { + name = value; + Watcher.NotifyDisplayNameChanged(this); + } + } + } + public string Path { get; set; } = ""; public string GitDir { get; set; } = ""; public long LastOpenTime { get; set; } = 0; @@ -131,6 +140,7 @@ namespace SourceGit.Models { } private readonly object updateFilterLock = new object(); + private string name = string.Empty; private int bookmark = 0; } } diff --git a/src/Models/Watcher.cs b/src/Models/Watcher.cs index c05dadbf..090b512f 100644 --- a/src/Models/Watcher.cs +++ b/src/Models/Watcher.cs @@ -14,6 +14,11 @@ namespace SourceGit.Models { /// public static event Action Opened; + /// + /// 仓库的显示名变化了 + /// + public static event Action DisplayNameChanged; + /// /// 仓库的书签变化了 /// @@ -102,6 +107,14 @@ namespace SourceGit.Models { } } + /// + /// 通知仓库显示名变化 + /// + /// + public static void NotifyDisplayNameChanged(Repository repo) { + DisplayNameChanged?.Invoke(repo.Path, repo.Name); + } + /// /// 通知仓库标签变化 /// diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml index eeefefa8..1575c486 100644 --- a/src/Resources/Locales/en_US.xaml +++ b/src/Resources/Locales/en_US.xaml @@ -305,6 +305,8 @@ Search Repositories ... Sort DRAG & DROP FOLDER HERE + Edit Display Name + Display Name : Pull Pull (Fetch & Merge) diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml index 45d9b0ba..123f9cc0 100644 --- a/src/Resources/Locales/zh_CN.xaml +++ b/src/Resources/Locales/zh_CN.xaml @@ -304,6 +304,8 @@ 快速查找仓库 排序 支持拖放目录添加 + 修改显示名称 + 显示名称 : 拉回 拉回(拉取并合并) diff --git a/src/Views/EditRepositoryDisplayName.xaml b/src/Views/EditRepositoryDisplayName.xaml new file mode 100644 index 00000000..43d84f4c --- /dev/null +++ b/src/Views/EditRepositoryDisplayName.xaml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +