diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index c309e2965..fc6be5d04 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -312,13 +312,32 @@ namespace Flow.Launcher { if (sender is Button { DataContext: PluginStoreItemViewModel plugin }) { - var pluginsManagerPlugin = PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"); - var actionKeyword = pluginsManagerPlugin.Metadata.ActionKeywords.Count == 0 ? "" : pluginsManagerPlugin.Metadata.ActionKeywords[0]; - API.ChangeQuery($"{actionKeyword} install {plugin.Name}"); - API.ShowMainWindow(); + viewModel.DisplayPluginQuery($"install {plugin.Name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7")); } } + private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs e) + { + if (e.ChangedButton == MouseButton.Left) + { + var name = viewModel.SelectedPlugin.PluginPair.Metadata.Name; + viewModel.DisplayPluginQuery($"uninstall {name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7")); + } + + } + + private void OnExternalPluginUninstallClick(object sender, RoutedEventArgs e) + { + if (sender is Button { DataContext: PluginStoreItemViewModel plugin }) + viewModel.DisplayPluginQuery($"uninstall {plugin.Name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7")); + } + + private void OnExternalPluginUpdateClick(object sender, RoutedEventArgs e) + { + if (sender is Button { DataContext: PluginStoreItemViewModel plugin }) + viewModel.DisplayPluginQuery($"update {plugin.Name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7")); + } + private void window_MouseDown(object sender, MouseButtonEventArgs e) /* for close hotkey popup */ { if (Keyboard.FocusedElement is not TextBox textBox) @@ -477,39 +496,6 @@ namespace Flow.Launcher var top = (dip2.Y - this.ActualHeight) / 2 + dip1.Y - 20; return top; } - private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs e) - { - if (e.ChangedButton == MouseButton.Left) - { - var id = viewModel.SelectedPlugin.PluginPair.Metadata.Name; - var pluginsManagerPlugin = PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"); - var actionKeyword = pluginsManagerPlugin.Metadata.ActionKeywords.Count == 0 ? "" : pluginsManagerPlugin.Metadata.ActionKeywords[0]; - API.ChangeQuery($"{actionKeyword} uninstall {id}"); - API.ShowMainWindow(); - } - } - - private void OnExternalPluginUninstallClick(object sender, RoutedEventArgs e) - { - if (sender is Button { DataContext: PluginStoreItemViewModel plugin }) - { - var pluginsManagerPlugin = PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"); - var actionKeyword = pluginsManagerPlugin.Metadata.ActionKeywords.Count == 0 ? "" : pluginsManagerPlugin.Metadata.ActionKeywords[0]; - API.ChangeQuery($"{actionKeyword} uninstall {plugin.Name}"); - API.ShowMainWindow(); - } - } - - private void OnExternalPluginUpdateClick(object sender, RoutedEventArgs e) - { - if (sender is Button { DataContext: PluginStoreItemViewModel plugin }) - { - var pluginsManagerPlugin = PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"); - var actionKeyword = pluginsManagerPlugin.Metadata.ActionKeywords.Count == 0 ? "" : pluginsManagerPlugin.Metadata.ActionKeywords[0]; - API.ChangeQuery($"{actionKeyword} update {plugin.Name}"); - API.ShowMainWindow(); - } - } } } diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index d9c61986e..432699c4b 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -321,6 +321,16 @@ namespace Flow.Launcher.ViewModel OnPropertyChanged(nameof(ExternalPlugins)); } + internal void DisplayPluginQuery(string queryToDisplay, PluginPair plugin, int actionKeywordPosition = 0) + { + var actionKeyword = plugin.Metadata.ActionKeywords.Count == 0 + ? string.Empty + : plugin.Metadata.ActionKeywords[actionKeywordPosition]; + + App.API.ChangeQuery($"{actionKeyword} {queryToDisplay}"); + App.API.ShowMainWindow(); + } + #endregion