Adjust priority to command and open directory to command

This commit is contained in:
Hongtao Zhang 2022-12-04 02:13:14 -06:00
parent 21ba7bfe47
commit 72159d4727
No known key found for this signature in database
GPG key ID: 75F655B91C7AC9BB
5 changed files with 31 additions and 14 deletions

View file

@ -1,6 +1,5 @@
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.ViewModel;
using System;
@ -23,14 +22,12 @@ namespace Flow.Launcher
public partial class PriorityChangeWindow : Window
{
private readonly PluginPair plugin;
private Settings settings;
private readonly Internationalization translater = InternationalizationManager.Instance;
private readonly PluginViewModel pluginViewModel;
public PriorityChangeWindow(string pluginId, Settings settings, PluginViewModel pluginViewModel)
public PriorityChangeWindow(string pluginId, PluginViewModel pluginViewModel)
{
InitializeComponent();
plugin = PluginManager.GetPluginForId(pluginId);
this.settings = settings;
this.pluginViewModel = pluginViewModel;
if (plugin == null)
{
@ -74,4 +71,4 @@ namespace Flow.Launcher
}
}
}
}
}

View file

@ -1355,9 +1355,14 @@
Cursor="Hand"
FontSize="11"
Foreground="{DynamicResource PluginInfoColor}"
MouseUp="OnPluginDirecotyClick"
Text="{DynamicResource pluginDirectory}"
TextDecorations="Underline" />
TextDecorations="Underline" >
<TextBlock.InputBindings>
<MouseBinding
Command="{Binding OpenPluginDirectoryCommand}"
MouseAction="LeftClick"/>
</TextBlock.InputBindings>
</TextBlock>
</StackPanel>
</ItemsControl>

View file

@ -189,7 +189,7 @@ namespace Flow.Launcher
{
if (sender is Control { DataContext: PluginViewModel pluginViewModel })
{
PriorityChangeWindow priorityChangeWindow = new PriorityChangeWindow(pluginViewModel.PluginPair.Metadata.ID, settings, pluginViewModel);
PriorityChangeWindow priorityChangeWindow = new PriorityChangeWindow(pluginViewModel.PluginPair.Metadata.ID, pluginViewModel);
priorityChangeWindow.ShowDialog();
}
}
@ -328,8 +328,6 @@ namespace Flow.Launcher
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)

View file

@ -54,7 +54,7 @@ namespace Flow.Launcher.ViewModel
set
{
_isExpanded = value;
OnPropertyChanged();
OnPropertyChanged(nameof(SettingControl));
}
@ -62,12 +62,12 @@ namespace Flow.Launcher.ViewModel
private Control _settingControl;
private bool _isExpanded;
public Control SettingControl
public Control SettingControl
=> IsExpanded
? _settingControl
??= PluginPair.Plugin is not ISettingProvider settingProvider
? new Control()
: settingProvider.CreateSettingPanel()
? new Control()
: settingProvider.CreateSettingPanel()
: null;
private ImageSource _image = ImageLoader.DefaultImage;
@ -89,6 +89,21 @@ namespace Flow.Launcher.ViewModel
OnPropertyChanged(nameof(Priority));
}
[RelayCommand]
private void EditPluginPriority()
{
PriorityChangeWindow priorityChangeWindow = new PriorityChangeWindow(PluginPair.Metadata.ID, this);
priorityChangeWindow.ShowDialog();
}
[RelayCommand]
private void OpenPluginDirectory()
{
var directory = PluginPair.Metadata.PluginDirectory;
if (!string.IsNullOrEmpty(directory))
PluginManager.API.OpenDirectory(directory);
}
public static bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
[RelayCommand]

View file

@ -356,6 +356,8 @@ namespace Flow.Launcher.ViewModel
await PluginsManifest.UpdateManifestAsync();
OnPropertyChanged(nameof(ExternalPlugins));
}
internal void DisplayPluginQuery(string queryToDisplay, PluginPair plugin, int actionKeywordPosition = 0)
{