mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
Merge pull request #160 from workgroupengineering/feature/CopyFileName
feat: Allow Copy only file name with extension
This commit is contained in:
commit
04e6ed45a7
5 changed files with 49 additions and 2 deletions
|
@ -114,6 +114,7 @@
|
||||||
<x:String x:Key="Text.Configure.User.Placeholder" xml:space="preserve">User name for this repository</x:String>
|
<x:String x:Key="Text.Configure.User.Placeholder" xml:space="preserve">User name for this repository</x:String>
|
||||||
<x:String x:Key="Text.Copy" xml:space="preserve">Copy</x:String>
|
<x:String x:Key="Text.Copy" xml:space="preserve">Copy</x:String>
|
||||||
<x:String x:Key="Text.CopyPath" xml:space="preserve">Copy Path</x:String>
|
<x:String x:Key="Text.CopyPath" xml:space="preserve">Copy Path</x:String>
|
||||||
|
<x:String x:Key="Text.CopyFileName" xml:space="preserve">Copy File Name</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch" xml:space="preserve">Create Branch</x:String>
|
<x:String x:Key="Text.CreateBranch" xml:space="preserve">Create Branch</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">Based On :</x:String>
|
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">Based On :</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Check out after created</x:String>
|
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Check out after created</x:String>
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
<x:String x:Key="Text.Configure.User.Placeholder" xml:space="preserve">应用于本仓库的用户名</x:String>
|
<x:String x:Key="Text.Configure.User.Placeholder" xml:space="preserve">应用于本仓库的用户名</x:String>
|
||||||
<x:String x:Key="Text.Copy" xml:space="preserve">复制</x:String>
|
<x:String x:Key="Text.Copy" xml:space="preserve">复制</x:String>
|
||||||
<x:String x:Key="Text.CopyPath" xml:space="preserve">复制路径</x:String>
|
<x:String x:Key="Text.CopyPath" xml:space="preserve">复制路径</x:String>
|
||||||
|
<x:String x:Key="Text.CopyFileName" xml:space="preserve">复制文件名</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch" xml:space="preserve">新建分支</x:String>
|
<x:String x:Key="Text.CreateBranch" xml:space="preserve">新建分支</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">新分支基于 :</x:String>
|
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">新分支基于 :</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">完成后切换到新分支</x:String>
|
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">完成后切换到新分支</x:String>
|
||||||
|
|
|
@ -10,6 +10,7 @@ using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using SourceGit.Models;
|
||||||
|
|
||||||
namespace SourceGit.ViewModels
|
namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -218,7 +219,17 @@ namespace SourceGit.ViewModels
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
menu.Items.Add(copyPath);
|
menu.Items.Add(copyPath);
|
||||||
|
var copyFileName = new MenuItem()
|
||||||
|
{
|
||||||
|
Header = App.Text("CopyFileName"),
|
||||||
|
Icon = App.CreateMenuIcon("Icon.Copy"),
|
||||||
|
};
|
||||||
|
copyFileName.Click += (_, e) =>
|
||||||
|
{
|
||||||
|
App.CopyText(Path.GetFileName(change.Path));
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
menu.Items.Add(copyFileName);
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,12 +295,24 @@ namespace SourceGit.ViewModels
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var copyFileName = new MenuItem()
|
||||||
|
{
|
||||||
|
Header = App.Text("CopyFileName"),
|
||||||
|
Icon = App.CreateMenuIcon("Icon.Copy"),
|
||||||
|
};
|
||||||
|
copyFileName.Click += (_, e) =>
|
||||||
|
{
|
||||||
|
App.CopyText(Path.GetFileName(file.Path));
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
var menu = new ContextMenu();
|
var menu = new ContextMenu();
|
||||||
menu.Items.Add(history);
|
menu.Items.Add(history);
|
||||||
menu.Items.Add(blame);
|
menu.Items.Add(blame);
|
||||||
menu.Items.Add(explore);
|
menu.Items.Add(explore);
|
||||||
menu.Items.Add(saveAs);
|
menu.Items.Add(saveAs);
|
||||||
menu.Items.Add(copyPath);
|
menu.Items.Add(copyPath);
|
||||||
|
menu.Items.Add(copyFileName);
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,17 @@ namespace SourceGit.ViewModels
|
||||||
};
|
};
|
||||||
|
|
||||||
menu.Items.Add(copyPath);
|
menu.Items.Add(copyPath);
|
||||||
|
var copyFileName = new MenuItem()
|
||||||
|
{
|
||||||
|
Header = App.Text("CopyFileName"),
|
||||||
|
Icon = App.CreateMenuIcon("Icon.Copy"),
|
||||||
|
};
|
||||||
|
copyFileName.Click += (_, e) =>
|
||||||
|
{
|
||||||
|
App.CopyText(Path.GetFileName(change.Path));
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
menu.Items.Add(copyFileName);
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ namespace SourceGit.ViewModels
|
||||||
_unstaged.Clear();
|
_unstaged.Clear();
|
||||||
OnPropertyChanged(nameof(Unstaged));
|
OnPropertyChanged(nameof(Unstaged));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_staged != null)
|
if (_staged != null)
|
||||||
{
|
{
|
||||||
_staged.Clear();
|
_staged.Clear();
|
||||||
|
@ -584,6 +584,17 @@ namespace SourceGit.ViewModels
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
menu.Items.Add(copy);
|
menu.Items.Add(copy);
|
||||||
|
var copyFileName = new MenuItem()
|
||||||
|
{
|
||||||
|
Header = App.Text("CopyFileName"),
|
||||||
|
Icon = App.CreateMenuIcon("Icon.Copy"),
|
||||||
|
};
|
||||||
|
copyFileName.Click += (_, e) =>
|
||||||
|
{
|
||||||
|
App.CopyText(Path.GetFileName(change.Path));
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
menu.Items.Add(copyFileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue