|
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 BranchCompare : ObservableObject |
14 | 10 | { |
| 11 | + public string RepositoryPath |
| 12 | + { |
| 13 | + get => _repo; |
| 14 | + } |
| 15 | + |
15 | 16 | public bool IsLoading |
16 | 17 | { |
17 | 18 | get => _isLoading; |
@@ -127,70 +128,6 @@ public string GetAbsPath(string path) |
127 | 128 | return Native.OS.GetAbsPath(_repo, path); |
128 | 129 | } |
129 | 130 |
|
130 | | - public ContextMenu CreateChangeContextMenu() |
131 | | - { |
132 | | - if (_selectedChanges is not { Count: 1 }) |
133 | | - return null; |
134 | | - |
135 | | - var change = _selectedChanges[0]; |
136 | | - var menu = new ContextMenu(); |
137 | | - |
138 | | - var openWithMerger = new MenuItem(); |
139 | | - openWithMerger.Header = App.Text("OpenInExternalMergeTool"); |
140 | | - openWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith"); |
141 | | - openWithMerger.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+D" : "Ctrl+Shift+D"; |
142 | | - openWithMerger.Click += (_, ev) => |
143 | | - { |
144 | | - var toolType = Preferences.Instance.ExternalMergeToolType; |
145 | | - var toolPath = Preferences.Instance.ExternalMergeToolPath; |
146 | | - var opt = new Models.DiffOption(_based.Head, _to.Head, change); |
147 | | - |
148 | | - new Commands.DiffTool(_repo, toolType, toolPath, opt).Open(); |
149 | | - ev.Handled = true; |
150 | | - }; |
151 | | - menu.Items.Add(openWithMerger); |
152 | | - |
153 | | - if (change.Index != Models.ChangeState.Deleted) |
154 | | - { |
155 | | - var full = Path.GetFullPath(Path.Combine(_repo, change.Path)); |
156 | | - var explore = new MenuItem(); |
157 | | - explore.Header = App.Text("RevealFile"); |
158 | | - explore.Icon = App.CreateMenuIcon("Icons.Explore"); |
159 | | - explore.IsEnabled = File.Exists(full); |
160 | | - explore.Click += (_, ev) => |
161 | | - { |
162 | | - Native.OS.OpenInFileManager(full, true); |
163 | | - ev.Handled = true; |
164 | | - }; |
165 | | - menu.Items.Add(explore); |
166 | | - } |
167 | | - |
168 | | - var copyPath = new MenuItem(); |
169 | | - copyPath.Header = App.Text("CopyPath"); |
170 | | - copyPath.Icon = App.CreateMenuIcon("Icons.Copy"); |
171 | | - copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C"; |
172 | | - copyPath.Click += async (_, ev) => |
173 | | - { |
174 | | - await App.CopyTextAsync(change.Path); |
175 | | - ev.Handled = true; |
176 | | - }; |
177 | | - menu.Items.Add(new MenuItem() { Header = "-" }); |
178 | | - menu.Items.Add(copyPath); |
179 | | - |
180 | | - var copyFullPath = new MenuItem(); |
181 | | - copyFullPath.Header = App.Text("CopyFullPath"); |
182 | | - copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy"); |
183 | | - copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C"; |
184 | | - copyFullPath.Click += async (_, e) => |
185 | | - { |
186 | | - await App.CopyTextAsync(Native.OS.GetAbsPath(_repo, change.Path)); |
187 | | - e.Handled = true; |
188 | | - }; |
189 | | - menu.Items.Add(copyFullPath); |
190 | | - |
191 | | - return menu; |
192 | | - } |
193 | | - |
194 | 131 | private void Refresh() |
195 | 132 | { |
196 | 133 | IsLoading = true; |
|
0 commit comments