mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feature<CommitDetail>: add copy path contextmenu while multi-selecting changed items
This commit is contained in:
parent
37ce2cdba6
commit
5acc768478
1 changed files with 66 additions and 42 deletions
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
@ -116,15 +117,22 @@ namespace SourceGit.Views.Widgets {
|
|||
var row = sender as DataGridRow;
|
||||
if (row == null) return;
|
||||
|
||||
var change = row.DataContext as Models.Change;
|
||||
if (!row.IsSelected) {
|
||||
changeList.UnselectAll();
|
||||
row.IsSelected = true;
|
||||
}
|
||||
|
||||
var selectedCount = changeList.SelectedItems.Count;
|
||||
var menu = new ContextMenu();
|
||||
if (selectedCount == 1) {
|
||||
var change = changeList.SelectedItems[0] as Models.Change;
|
||||
if (change == null) return;
|
||||
|
||||
var menu = new ContextMenu();
|
||||
if (change.Index != Models.Change.Status.Deleted) {
|
||||
var history = new MenuItem();
|
||||
history.Header = App.Text("FileHistory");
|
||||
history.IsEnabled = change.Index != Models.Change.Status.Deleted;
|
||||
history.Click += (o, ev) => {
|
||||
history.Click += (_, ev) => {
|
||||
var viewer = new Views.Histories(repo, change.Path);
|
||||
viewer.Show();
|
||||
ev.Handled = true;
|
||||
|
@ -133,7 +141,7 @@ namespace SourceGit.Views.Widgets {
|
|||
var blame = new MenuItem();
|
||||
blame.Header = App.Text("Blame");
|
||||
blame.IsEnabled = change.Index != Models.Change.Status.Deleted;
|
||||
blame.Click += (obj, ev) => {
|
||||
blame.Click += (_, ev) => {
|
||||
var viewer = new Blame(repo, change.Path, commit.SHA);
|
||||
viewer.Show();
|
||||
ev.Handled = true;
|
||||
|
@ -142,7 +150,7 @@ namespace SourceGit.Views.Widgets {
|
|||
var explore = new MenuItem();
|
||||
explore.Header = App.Text("RevealFile");
|
||||
explore.IsEnabled = change.Index != Models.Change.Status.Deleted;
|
||||
explore.Click += (o, ev) => {
|
||||
explore.Click += (_, ev) => {
|
||||
var full = Path.GetFullPath(repo + "\\" + change.Path);
|
||||
Process.Start("explorer", $"/select,{full}");
|
||||
ev.Handled = true;
|
||||
|
@ -155,11 +163,27 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
var copyPath = new MenuItem();
|
||||
copyPath.Header = App.Text("CopyPath");
|
||||
copyPath.Click += (obj, ev) => {
|
||||
copyPath.Click += (_, ev) => {
|
||||
Clipboard.SetDataObject(change.Path, true);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(copyPath);
|
||||
} else {
|
||||
var copyPath = new MenuItem();
|
||||
copyPath.Header = App.Text("CopyPath");
|
||||
copyPath.Click += (_, ev) => {
|
||||
var builder = new StringBuilder();
|
||||
foreach (var obj in changeList.SelectedItems) {
|
||||
builder.Append((obj as Models.Change).Path);
|
||||
builder.Append("\n");
|
||||
}
|
||||
Clipboard.SetDataObject(builder.ToString(), true);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(copyPath);
|
||||
}
|
||||
|
||||
menu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
|
|
Loading…
Reference in a new issue