|
| 1 | +using System; |
| 2 | + |
1 | 3 | using Avalonia.Controls; |
2 | 4 | using Avalonia.Input; |
3 | 5 | using Avalonia.Interactivity; |
@@ -45,22 +47,43 @@ private async void OpenConfigure(object sender, RoutedEventArgs e) |
45 | 47 | private void Fetch(object _, RoutedEventArgs e) |
46 | 48 | { |
47 | 49 | var launcher = this.FindAncestorOfType<Launcher>(); |
48 | | - (DataContext as ViewModels.Repository)?.Fetch(launcher?.HasKeyModifier(KeyModifiers.Control) ?? false); |
49 | | - e.Handled = true; |
| 50 | + if (launcher is not null && DataContext is ViewModels.Repository repo) |
| 51 | + { |
| 52 | + var startDirectly = launcher.HasKeyModifier(KeyModifiers.Control); |
| 53 | + if (!startDirectly && OperatingSystem.IsMacOS()) |
| 54 | + startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta); |
| 55 | + |
| 56 | + repo.Fetch(startDirectly); |
| 57 | + e.Handled = true; |
| 58 | + } |
50 | 59 | } |
51 | 60 |
|
52 | 61 | private void Pull(object _, RoutedEventArgs e) |
53 | 62 | { |
54 | 63 | var launcher = this.FindAncestorOfType<Launcher>(); |
55 | | - (DataContext as ViewModels.Repository)?.Pull(launcher?.HasKeyModifier(KeyModifiers.Control) ?? false); |
56 | | - e.Handled = true; |
| 64 | + if (launcher is not null && DataContext is ViewModels.Repository repo) |
| 65 | + { |
| 66 | + var startDirectly = launcher.HasKeyModifier(KeyModifiers.Control); |
| 67 | + if (!startDirectly && OperatingSystem.IsMacOS()) |
| 68 | + startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta); |
| 69 | + |
| 70 | + repo.Pull(startDirectly); |
| 71 | + e.Handled = true; |
| 72 | + } |
57 | 73 | } |
58 | 74 |
|
59 | 75 | private void Push(object _, RoutedEventArgs e) |
60 | 76 | { |
61 | 77 | var launcher = this.FindAncestorOfType<Launcher>(); |
62 | | - (DataContext as ViewModels.Repository)?.Push(launcher?.HasKeyModifier(KeyModifiers.Control) ?? false); |
63 | | - e.Handled = true; |
| 78 | + if (launcher is not null && DataContext is ViewModels.Repository repo) |
| 79 | + { |
| 80 | + var startDirectly = launcher.HasKeyModifier(KeyModifiers.Control); |
| 81 | + if (!startDirectly && OperatingSystem.IsMacOS()) |
| 82 | + startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta); |
| 83 | + |
| 84 | + repo.Push(startDirectly); |
| 85 | + e.Handled = true; |
| 86 | + } |
64 | 87 | } |
65 | 88 |
|
66 | 89 | private void StashAll(object _, RoutedEventArgs e) |
|
0 commit comments