Fix Plugin list unselected item bug

This commit is contained in:
Hongtao Zhang 2022-11-07 15:33:04 -06:00
parent 49b9e97fcd
commit ab97a5ccf0
No known key found for this signature in database
GPG key ID: 75F655B91C7AC9BB
4 changed files with 14 additions and 19 deletions

View file

@ -8,24 +8,17 @@ using Flow.Launcher.ViewModel;
namespace Flow.Launcher namespace Flow.Launcher
{ {
public partial class ActionKeywords : Window public partial class ActionKeywords
{ {
private readonly PluginPair plugin; private readonly PluginPair plugin;
private Settings settings;
private readonly Internationalization translater = InternationalizationManager.Instance; private readonly Internationalization translater = InternationalizationManager.Instance;
private readonly PluginViewModel pluginViewModel; private readonly PluginViewModel pluginViewModel;
public ActionKeywords(string pluginId, Settings settings, PluginViewModel pluginViewModel) public ActionKeywords(PluginViewModel pluginViewModel)
{ {
InitializeComponent(); InitializeComponent();
plugin = PluginManager.GetPluginForId(pluginId); plugin = pluginViewModel.PluginPair;
this.settings = settings;
this.pluginViewModel = pluginViewModel; this.pluginViewModel = pluginViewModel;
if (plugin == null)
{
MessageBox.Show(translater.GetTranslation("cannotFindSpecifiedPlugin"));
Close();
}
} }
private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e) private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e)

View file

@ -1192,8 +1192,8 @@
Height="34" Height="34"
Margin="5,0,0,0" Margin="5,0,0,0"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Click="OnPluginActionKeywordsClick"
Content="{Binding ActionKeywordsText}" Content="{Binding ActionKeywordsText}"
Command="{Binding SetActionKeywordsCommand}"
Cursor="Hand" Cursor="Hand"
DockPanel.Dock="Right" DockPanel.Dock="Right"
FontWeight="Bold" FontWeight="Bold"

View file

@ -194,13 +194,6 @@ namespace Flow.Launcher
} }
} }
private void OnPluginActionKeywordsClick(object sender, RoutedEventArgs e)
{
var id = viewModel.SelectedPlugin.PluginPair.Metadata.ID;
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, settings, viewModel.SelectedPlugin);
changeKeywordsWindow.ShowDialog();
}
private void OnPluginNameClick(object sender, MouseButtonEventArgs e) private void OnPluginNameClick(object sender, MouseButtonEventArgs e)
{ {
if (e.ChangedButton == MouseButton.Left) if (e.ChangedButton == MouseButton.Left)

View file

@ -4,10 +4,11 @@ using Flow.Launcher.Plugin;
using Flow.Launcher.Infrastructure.Image; using Flow.Launcher.Infrastructure.Image;
using Flow.Launcher.Core.Plugin; using Flow.Launcher.Core.Plugin;
using System.Windows.Controls; using System.Windows.Controls;
using CommunityToolkit.Mvvm.Input;
namespace Flow.Launcher.ViewModel namespace Flow.Launcher.ViewModel
{ {
public class PluginViewModel : BaseModel public partial class PluginViewModel : BaseModel
{ {
private readonly PluginPair _pluginPair; private readonly PluginPair _pluginPair;
public PluginPair PluginPair public PluginPair PluginPair
@ -36,6 +37,7 @@ namespace Flow.Launcher.ViewModel
set set
{ {
_isExpanded = value; _isExpanded = value;
OnPropertyChanged(); OnPropertyChanged();
OnPropertyChanged(nameof(SettingControl)); OnPropertyChanged(nameof(SettingControl));
} }
@ -70,6 +72,13 @@ namespace Flow.Launcher.ViewModel
} }
public static bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword); public static bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
[RelayCommand]
private void SetActionKeywords()
{
ActionKeywords changeKeywordsWindow = new ActionKeywords(this);
changeKeywordsWindow.ShowDialog();
}
} }
} }