diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 1ebe69e80..63fbd305b 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -607,7 +607,8 @@ @@ -1515,7 +1517,8 @@ HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" BorderThickness="0" - FocusVisualStyle="{StaticResource StoreItemFocusVisualStyleKey}"> + FocusVisualStyle="{StaticResource StoreItemFocusVisualStyleKey}" + Click="StoreListItem_Click"> @@ -1675,7 +1678,8 @@ @@ -2252,7 +2256,8 @@ @@ -2547,7 +2552,8 @@ @@ -2720,7 +2726,8 @@ (DependencyObject child) where T : DependencyObject { - _ = viewModel.RefreshExternalPluginsAsync(); - } + //get parent item + DependencyObject parentObject = VisualTreeHelper.GetParent(child); + //we've reached the end of the tree + if (parentObject == null) return null; + + //check if the parent matches the type we're looking for + T parent = parentObject as T; + if (parent != null) + return parent; + else + return FindParent(parentObject); + } + private void OnExternalPluginInstallClick(object sender, RoutedEventArgs e) { - if (sender is Button { DataContext: PluginStoreItemViewModel plugin }) + if (sender is not Button { DataContext: PluginStoreItemViewModel plugin } button) { - viewModel.DisplayPluginQuery($"install {plugin.Name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7")); + return; } + + if (storeClickedButton != null) + { + FlyoutService.GetFlyout(storeClickedButton).Hide(); + } + + viewModel.DisplayPluginQuery($"install {plugin.Name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7")); } private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs e) @@ -545,5 +564,21 @@ namespace Flow.Launcher return top; } + private Button storeClickedButton; + + private void StoreListItem_Click(object sender, RoutedEventArgs e) + { + if (sender is not Button button) + return; + + storeClickedButton = button; + + var flyout = FlyoutService.GetFlyout(button); + flyout.Closed += (_, _) => + { + storeClickedButton = null; + }; + + } } } diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 6e7a07e5f..fa6520523 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -20,10 +20,11 @@ using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.Input; namespace Flow.Launcher.ViewModel { - public class SettingWindowViewModel : BaseModel + public partial class SettingWindowViewModel : BaseModel { private readonly Updater _updater; private readonly IPortable _portable; @@ -330,7 +331,8 @@ namespace Flow.Launcher.ViewModel } } - public async Task RefreshExternalPluginsAsync() + [RelayCommand] + private async Task RefreshExternalPluginsAsync() { await PluginsManifest.UpdateManifestAsync(); OnPropertyChanged(nameof(ExternalPlugins));