From 23e578f35515dc577476eb5c6cba61a6f581501a Mon Sep 17 00:00:00 2001 From: Nathan Baulch Date: Wed, 9 Jul 2025 14:02:26 +1000 Subject: [PATCH] enhance: double tap stash to apply (#1546) --- src/ViewModels/StashesPage.cs | 14 ++++++++------ src/Views/StashesPage.axaml | 1 + src/Views/StashesPage.axaml.cs | 9 +++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/ViewModels/StashesPage.cs b/src/ViewModels/StashesPage.cs index 588a5bab..b9732f15 100644 --- a/src/ViewModels/StashesPage.cs +++ b/src/ViewModels/StashesPage.cs @@ -147,9 +147,7 @@ namespace SourceGit.ViewModels apply.Icon = App.CreateMenuIcon("Icons.CheckCircled"); apply.Click += (_, ev) => { - if (_repo.CanCreatePopup()) - _repo.ShowPopup(new ApplyStash(_repo, stash)); - + Apply(stash); ev.Handled = true; }; @@ -158,9 +156,7 @@ namespace SourceGit.ViewModels drop.Icon = App.CreateMenuIcon("Icons.Clear"); drop.Click += (_, ev) => { - if (_repo.CanCreatePopup()) - _repo.ShowPopup(new DropStash(_repo, stash)); - + Drop(stash); ev.Handled = true; }; @@ -310,6 +306,12 @@ namespace SourceGit.ViewModels SearchFilter = string.Empty; } + public void Apply(Models.Stash stash) + { + if (stash != null && _repo.CanCreatePopup()) + _repo.ShowPopup(new ApplyStash(_repo, stash)); + } + public void Drop(Models.Stash stash) { if (stash != null && _repo.CanCreatePopup()) diff --git a/src/Views/StashesPage.axaml b/src/Views/StashesPage.axaml index a61aad99..3bd95a12 100644 --- a/src/Views/StashesPage.axaml +++ b/src/Views/StashesPage.axaml @@ -65,6 +65,7 @@ ItemsSource="{Binding VisibleStashes}" SelectedItem="{Binding SelectedStash, Mode=TwoWay}" SelectionMode="Single" + DoubleTapped="OnStashListDoubleTapped" KeyDown="OnStashListKeyDown" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"> diff --git a/src/Views/StashesPage.axaml.cs b/src/Views/StashesPage.axaml.cs index 34c44214..4bddd3a6 100644 --- a/src/Views/StashesPage.axaml.cs +++ b/src/Views/StashesPage.axaml.cs @@ -23,6 +23,15 @@ namespace SourceGit.Views layout.StashesLeftWidth = new GridLength(maxLeft, GridUnitType.Pixel); } + private void OnStashListDoubleTapped(object _, TappedEventArgs e) + { + if (DataContext is not ViewModels.StashesPage vm) + return; + + vm.Apply(vm.SelectedStash); + e.Handled = true; + } + private void OnStashListKeyDown(object sender, KeyEventArgs e) { if (e.Key is not (Key.Delete or Key.Back))