From ab97a5ccf0430162641ca42e703248129ec12c6f Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Mon, 7 Nov 2022 15:33:04 -0600 Subject: [PATCH] Fix Plugin list unselected item bug --- Flow.Launcher/ActionKeywords.xaml.cs | 13 +++---------- Flow.Launcher/SettingWindow.xaml | 2 +- Flow.Launcher/SettingWindow.xaml.cs | 7 ------- Flow.Launcher/ViewModel/PluginViewModel.cs | 11 ++++++++++- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Flow.Launcher/ActionKeywords.xaml.cs b/Flow.Launcher/ActionKeywords.xaml.cs index e116e6f4d..012c9ff4e 100644 --- a/Flow.Launcher/ActionKeywords.xaml.cs +++ b/Flow.Launcher/ActionKeywords.xaml.cs @@ -8,24 +8,17 @@ using Flow.Launcher.ViewModel; namespace Flow.Launcher { - public partial class ActionKeywords : Window + public partial class ActionKeywords { private readonly PluginPair plugin; - private Settings settings; private readonly Internationalization translater = InternationalizationManager.Instance; private readonly PluginViewModel pluginViewModel; - public ActionKeywords(string pluginId, Settings settings, PluginViewModel pluginViewModel) + public ActionKeywords(PluginViewModel pluginViewModel) { InitializeComponent(); - plugin = PluginManager.GetPluginForId(pluginId); - this.settings = settings; + plugin = pluginViewModel.PluginPair; this.pluginViewModel = pluginViewModel; - if (plugin == null) - { - MessageBox.Show(translater.GetTranslation("cannotFindSpecifiedPlugin")); - Close(); - } } private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 808531765..168b96245 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1192,8 +1192,8 @@ Height="34" Margin="5,0,0,0" HorizontalAlignment="Right" - Click="OnPluginActionKeywordsClick" Content="{Binding ActionKeywordsText}" + Command="{Binding SetActionKeywordsCommand}" Cursor="Hand" DockPanel.Dock="Right" FontWeight="Bold" diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index a7f2114ed..edb0f9189 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -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) { if (e.ChangedButton == MouseButton.Left) diff --git a/Flow.Launcher/ViewModel/PluginViewModel.cs b/Flow.Launcher/ViewModel/PluginViewModel.cs index 2294681b4..6345f986f 100644 --- a/Flow.Launcher/ViewModel/PluginViewModel.cs +++ b/Flow.Launcher/ViewModel/PluginViewModel.cs @@ -4,10 +4,11 @@ using Flow.Launcher.Plugin; using Flow.Launcher.Infrastructure.Image; using Flow.Launcher.Core.Plugin; using System.Windows.Controls; +using CommunityToolkit.Mvvm.Input; namespace Flow.Launcher.ViewModel { - public class PluginViewModel : BaseModel + public partial class PluginViewModel : BaseModel { private readonly PluginPair _pluginPair; public PluginPair PluginPair @@ -36,6 +37,7 @@ namespace Flow.Launcher.ViewModel set { _isExpanded = value; + OnPropertyChanged(); OnPropertyChanged(nameof(SettingControl)); } @@ -70,6 +72,13 @@ namespace Flow.Launcher.ViewModel } public static bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword); + + [RelayCommand] + private void SetActionKeywords() + { + ActionKeywords changeKeywordsWindow = new ActionKeywords(this); + changeKeywordsWindow.ShowDialog(); + } } }