|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | | -using System.IO; |
4 | 3 | using System.Threading.Tasks; |
5 | | - |
6 | | -using Avalonia.Controls; |
7 | 4 | using Avalonia.Threading; |
8 | | - |
9 | 5 | using CommunityToolkit.Mvvm.ComponentModel; |
10 | 6 |
|
11 | 7 | namespace SourceGit.ViewModels |
12 | 8 | { |
13 | 9 | public class RevisionCompare : ObservableObject, IDisposable |
14 | 10 | { |
| 11 | + public string RepositoryPath |
| 12 | + { |
| 13 | + get => _repo; |
| 14 | + } |
| 15 | + |
15 | 16 | public bool IsLoading |
16 | 17 | { |
17 | 18 | get => _isLoading; |
@@ -96,6 +97,14 @@ public void Dispose() |
96 | 97 | _diffContext = null; |
97 | 98 | } |
98 | 99 |
|
| 100 | + public void OpenChangeWithExternalDiffTool(Models.Change change) |
| 101 | + { |
| 102 | + var opt = new Models.DiffOption(GetSHA(_startPoint), GetSHA(_endPoint), change); |
| 103 | + var toolType = Preferences.Instance.ExternalMergeToolType; |
| 104 | + var toolPath = Preferences.Instance.ExternalMergeToolPath; |
| 105 | + new Commands.DiffTool(_repo, toolType, toolPath, opt).Open(); |
| 106 | + } |
| 107 | + |
99 | 108 | public void NavigateTo(string commitSHA) |
100 | 109 | { |
101 | 110 | var launcher = App.GetLauncher(); |
@@ -136,68 +145,6 @@ public void ClearSearchFilter() |
136 | 145 | SearchFilter = string.Empty; |
137 | 146 | } |
138 | 147 |
|
139 | | - public ContextMenu CreateChangeContextMenu() |
140 | | - { |
141 | | - if (_selectedChanges is not { Count: 1 }) |
142 | | - return null; |
143 | | - |
144 | | - var change = _selectedChanges[0]; |
145 | | - var menu = new ContextMenu(); |
146 | | - |
147 | | - var openWithMerger = new MenuItem(); |
148 | | - openWithMerger.Header = App.Text("OpenInExternalMergeTool"); |
149 | | - openWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith"); |
150 | | - openWithMerger.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+D" : "Ctrl+Shift+D"; |
151 | | - openWithMerger.Click += (_, ev) => |
152 | | - { |
153 | | - var opt = new Models.DiffOption(GetSHA(_startPoint), GetSHA(_endPoint), change); |
154 | | - var toolType = Preferences.Instance.ExternalMergeToolType; |
155 | | - var toolPath = Preferences.Instance.ExternalMergeToolPath; |
156 | | - new Commands.DiffTool(_repo, toolType, toolPath, opt).Open(); |
157 | | - ev.Handled = true; |
158 | | - }; |
159 | | - menu.Items.Add(openWithMerger); |
160 | | - |
161 | | - if (change.Index != Models.ChangeState.Deleted) |
162 | | - { |
163 | | - var full = Path.GetFullPath(Path.Combine(_repo, change.Path)); |
164 | | - var explore = new MenuItem(); |
165 | | - explore.Header = App.Text("RevealFile"); |
166 | | - explore.Icon = App.CreateMenuIcon("Icons.Explore"); |
167 | | - explore.IsEnabled = File.Exists(full); |
168 | | - explore.Click += (_, ev) => |
169 | | - { |
170 | | - Native.OS.OpenInFileManager(full, true); |
171 | | - ev.Handled = true; |
172 | | - }; |
173 | | - menu.Items.Add(explore); |
174 | | - } |
175 | | - |
176 | | - var copyPath = new MenuItem(); |
177 | | - copyPath.Header = App.Text("CopyPath"); |
178 | | - copyPath.Icon = App.CreateMenuIcon("Icons.Copy"); |
179 | | - copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C"; |
180 | | - copyPath.Click += async (_, ev) => |
181 | | - { |
182 | | - await App.CopyTextAsync(change.Path); |
183 | | - ev.Handled = true; |
184 | | - }; |
185 | | - menu.Items.Add(copyPath); |
186 | | - |
187 | | - var copyFullPath = new MenuItem(); |
188 | | - copyFullPath.Header = App.Text("CopyFullPath"); |
189 | | - copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy"); |
190 | | - copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C"; |
191 | | - copyFullPath.Click += async (_, e) => |
192 | | - { |
193 | | - await App.CopyTextAsync(Native.OS.GetAbsPath(_repo, change.Path)); |
194 | | - e.Handled = true; |
195 | | - }; |
196 | | - menu.Items.Add(copyFullPath); |
197 | | - |
198 | | - return menu; |
199 | | - } |
200 | | - |
201 | 148 | private void RefreshVisible() |
202 | 149 | { |
203 | 150 | if (_changes == null) |
|
0 commit comments