mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
move plugin install/uninstall/update calls from View to ViewModel
This commit is contained in:
parent
8dd24de0c0
commit
3fcae23c58
2 changed files with 33 additions and 37 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue