Merge pull request #1419 from onesounds/PluginUninstallButton

Add Uninstall Button
This commit is contained in:
Jeremy Wu 2022-10-03 08:54:33 +11:00 committed by GitHub
commit 6a3707473a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View file

@ -79,6 +79,7 @@
<system:String x:Key="plugin_query_time">Query time:</system:String>
<system:String x:Key="plugin_query_version">| Version</system:String>
<system:String x:Key="plugin_query_web">Website</system:String>
<system:String x:Key="plugin_uninstall">Uninstall</system:String>
<!-- Setting Plugin Store -->

View file

@ -1207,6 +1207,17 @@
</Hyperlink>
</TextBlock>
<TextBlock
Margin="10,0,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Cursor="Hand"
FontSize="11"
Foreground="{DynamicResource PluginInfoColor}"
MouseUp="OnExternalPluginUninstallClick"
Text="{DynamicResource plugin_uninstall}"
TextDecorations="Underline" />
<TextBlock
Margin="10,0,0,0"
HorizontalAlignment="Right"

View file

@ -1,4 +1,5 @@
using Flow.Launcher.Core.ExternalPlugins;
using Droplex;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Helper;
@ -348,5 +349,17 @@ namespace Flow.Launcher
{
Plugins.ScrollIntoView(Plugins.SelectedItem);
}
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();
}
}
}
}