File tree Expand file tree Collapse file tree 5 files changed +49
-2
lines changed Expand file tree Collapse file tree 5 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 114114 <x : String x : Key =" Text.Configure.User.Placeholder" xml : space =" preserve" >User name for this repository</x : String >
115115 <x : String x : Key =" Text.Copy" xml : space =" preserve" >Copy</x : String >
116116 <x : String x : Key =" Text.CopyPath" xml : space =" preserve" >Copy Path</x : String >
117+ <x : String x : Key =" Text.CopyFileName" xml : space =" preserve" >Copy File Name</x : String >
117118 <x : String x : Key =" Text.CreateBranch" xml : space =" preserve" >Create Branch</x : String >
118119 <x : String x : Key =" Text.CreateBranch.BasedOn" xml : space =" preserve" >Based On :</x : String >
119120 <x : String x : Key =" Text.CreateBranch.Checkout" xml : space =" preserve" >Check out after created</x : String >
Original file line number Diff line number Diff line change 117117 <x : String x : Key =" Text.Configure.User.Placeholder" xml : space =" preserve" >应用于本仓库的用户名</x : String >
118118 <x : String x : Key =" Text.Copy" xml : space =" preserve" >复制</x : String >
119119 <x : String x : Key =" Text.CopyPath" xml : space =" preserve" >复制路径</x : String >
120+ <x : String x : Key =" Text.CopyFileName" xml : space =" preserve" >复制文件名</x : String >
120121 <x : String x : Key =" Text.CreateBranch" xml : space =" preserve" >新建分支</x : String >
121122 <x : String x : Key =" Text.CreateBranch.BasedOn" xml : space =" preserve" >新分支基于 :</x : String >
122123 <x : String x : Key =" Text.CreateBranch.Checkout" xml : space =" preserve" >完成后切换到新分支</x : String >
Original file line number Diff line number Diff line change 1010using Avalonia . Threading ;
1111
1212using CommunityToolkit . Mvvm . ComponentModel ;
13+ using SourceGit . Models ;
1314
1415namespace SourceGit . ViewModels
1516{
@@ -218,7 +219,17 @@ public ContextMenu CreateChangeContextMenu(Models.Change change)
218219 ev . Handled = true ;
219220 } ;
220221 menu . Items . Add ( copyPath ) ;
221-
222+ var copyFileName = new MenuItem ( )
223+ {
224+ Header = App . Text ( "CopyFileName" ) ,
225+ Icon = App . CreateMenuIcon ( "Icon.Copy" ) ,
226+ } ;
227+ copyFileName . Click += ( _ , e ) =>
228+ {
229+ App . CopyText ( Path . GetFileName ( change . Path ) ) ;
230+ e . Handled = true ;
231+ } ;
232+ menu . Items . Add ( copyFileName ) ;
222233 return menu ;
223234 }
224235
@@ -284,12 +295,24 @@ public ContextMenu CreateRevisionFileContextMenu(Models.Object file)
284295 ev . Handled = true ;
285296 } ;
286297
298+ var copyFileName = new MenuItem ( )
299+ {
300+ Header = App . Text ( "CopyFileName" ) ,
301+ Icon = App . CreateMenuIcon ( "Icon.Copy" ) ,
302+ } ;
303+ copyFileName . Click += ( _ , e ) =>
304+ {
305+ App . CopyText ( Path . GetFileName ( file . Path ) ) ;
306+ e . Handled = true ;
307+ } ;
308+
287309 var menu = new ContextMenu ( ) ;
288310 menu . Items . Add ( history ) ;
289311 menu . Items . Add ( blame ) ;
290312 menu . Items . Add ( explore ) ;
291313 menu . Items . Add ( saveAs ) ;
292314 menu . Items . Add ( copyPath ) ;
315+ menu . Items . Add ( copyFileName ) ;
293316 return menu ;
294317 }
295318
Original file line number Diff line number Diff line change @@ -183,6 +183,17 @@ public ContextMenu CreateChangeContextMenu()
183183 } ;
184184
185185 menu . Items . Add ( copyPath ) ;
186+ var copyFileName = new MenuItem ( )
187+ {
188+ Header = App . Text ( "CopyFileName" ) ,
189+ Icon = App . CreateMenuIcon ( "Icon.Copy" ) ,
190+ } ;
191+ copyFileName . Click += ( _ , e ) =>
192+ {
193+ App . CopyText ( Path . GetFileName ( change . Path ) ) ;
194+ e . Handled = true ;
195+ } ;
196+ menu . Items . Add ( copyFileName ) ;
186197 return menu ;
187198 }
188199
Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ public void Cleanup()
209209 _unstaged . Clear ( ) ;
210210 OnPropertyChanged ( nameof ( Unstaged ) ) ;
211211 }
212-
212+
213213 if ( _staged != null )
214214 {
215215 _staged . Clear ( ) ;
@@ -584,6 +584,17 @@ public ContextMenu CreateContextMenuForUnstagedChanges()
584584 e . Handled = true ;
585585 } ;
586586 menu . Items . Add ( copy ) ;
587+ var copyFileName = new MenuItem ( )
588+ {
589+ Header = App . Text ( "CopyFileName" ) ,
590+ Icon = App . CreateMenuIcon ( "Icon.Copy" ) ,
591+ } ;
592+ copyFileName . Click += ( _ , e ) =>
593+ {
594+ App . CopyText ( Path . GetFileName ( change . Path ) ) ;
595+ e . Handled = true ;
596+ } ;
597+ menu . Items . Add ( copyFileName ) ;
587598 }
588599 else
589600 {
You can’t perform that action at this time.
0 commit comments