diff --git a/Plugins/Wox.Plugin.PluginManagement/Main.cs b/Plugins/Wox.Plugin.PluginManagement/Main.cs index 4e7a68c42c..934caea04a 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Main.cs +++ b/Plugins/Wox.Plugin.PluginManagement/Main.cs @@ -230,7 +230,7 @@ namespace Wox.Plugin.PluginManagement List results = new List(); foreach (PluginMetadata plugin in context.API.GetAllPlugins().Select(o => o.Metadata)) { - string actionKeywordString = string.Join(" or ", plugin.ActionKeywords); + string actionKeywordString = string.Join(" or ", plugin.ActionKeywords.ToArray()); results.Add(new Result { Title = $"{plugin.Name} - Action Keywords: {actionKeywordString}", diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs index e0a8eea541..d91577d4bd 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs @@ -104,6 +104,7 @@ namespace Wox.Plugin.WebSearch Url = url, Title = title }); + context.CurrentPluginMetadata.ActionKeywords.Add(action); string msg = context.API.GetTranslation("wox_plugin_websearch_succeed"); MessageBox.Show(msg); } @@ -120,10 +121,12 @@ namespace Wox.Plugin.WebSearch updateWebSearch.Enabled = cbEnable.IsChecked ?? false; updateWebSearch.Url = url; updateWebSearch.Title= title; + context.CurrentPluginMetadata.ActionKeywords.Add(action); string msg = context.API.GetTranslation("wox_plugin_websearch_succeed"); MessageBox.Show(msg); } WebSearchStorage.Instance.Save(); + settingWindow.ReloadWebSearchView(); Close(); } diff --git a/Wox.Core/Plugin/PluginConfig.cs b/Wox.Core/Plugin/PluginConfig.cs index a2f34fd79d..63abe41ff4 100644 --- a/Wox.Core/Plugin/PluginConfig.cs +++ b/Wox.Core/Plugin/PluginConfig.cs @@ -73,7 +73,7 @@ namespace Wox.Core.Plugin metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); metadata.PluginDirectory = pluginDirectory; // for plugins which doesn't has ActionKeywords key - metadata.ActionKeywords = metadata.ActionKeywords ?? new[] {metadata.ActionKeyword}; + metadata.ActionKeywords = metadata.ActionKeywords ?? new List {metadata.ActionKeyword}; // for plugin still use old ActionKeyword metadata.ActionKeyword = metadata.ActionKeywords?[0]; } @@ -116,7 +116,7 @@ namespace Wox.Core.Plugin //replace action keyword if user customized it. var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID); - if (customizedPluginConfig?.ActionKeywords?.Length > 0) + if (customizedPluginConfig?.ActionKeywords?.Count > 0) { metadata.ActionKeywords = customizedPluginConfig.ActionKeywords; metadata.ActionKeyword = customizedPluginConfig.ActionKeywords[0]; diff --git a/Wox.Core/UserSettings/CustomizedPluginConfig.cs b/Wox.Core/UserSettings/CustomizedPluginConfig.cs index 7bb40c60e3..bce1fd9bc8 100644 --- a/Wox.Core/UserSettings/CustomizedPluginConfig.cs +++ b/Wox.Core/UserSettings/CustomizedPluginConfig.cs @@ -10,7 +10,7 @@ namespace Wox.Core.UserSettings public string Name { get; set; } - public string[] ActionKeywords { get; set; } + public List ActionKeywords { get; set; } public bool Disabled { get; set; } } diff --git a/Wox.Plugin/PluginMetadata.cs b/Wox.Plugin/PluginMetadata.cs index ad27a8ea3e..0aa27f6ea1 100644 --- a/Wox.Plugin/PluginMetadata.cs +++ b/Wox.Plugin/PluginMetadata.cs @@ -27,7 +27,7 @@ namespace Wox.Plugin [Obsolete("Use ActionKeywords instead, because Wox now support multiple action keywords. This will be remove in v1.3.0")] public string ActionKeyword { get; set; } - public string[] ActionKeywords { get; set; } + public List ActionKeywords { get; set; } public string IcoPath { get; set; } diff --git a/Wox/ActionKeywords.xaml.cs b/Wox/ActionKeywords.xaml.cs index 9fc60979fa..06a70fdfb6 100644 --- a/Wox/ActionKeywords.xaml.cs +++ b/Wox/ActionKeywords.xaml.cs @@ -28,7 +28,7 @@ namespace Wox private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e) { - tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeperater, pluginMetadata.ActionKeywords); + tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeperater, pluginMetadata.ActionKeywords.ToArray()); tbAction.Focus(); } @@ -45,7 +45,7 @@ namespace Wox return; } - var actionKeywords = tbAction.Text.Trim().Split(new[] { Query.ActionKeywordSeperater }, StringSplitOptions.RemoveEmptyEntries).ToArray(); + var actionKeywords = tbAction.Text.Trim().Split(new[] { Query.ActionKeywordSeperater }, StringSplitOptions.RemoveEmptyEntries).ToList(); //check new action keyword didn't used by other plugin if (actionKeywords[0] != Query.GlobalPluginWildcardSign && PluginManager.AllPlugins. SelectMany(p => p.Metadata.ActionKeywords). diff --git a/Wox/Languages/en.xaml b/Wox/Languages/en.xaml index 28e0a4830d..71b8cccf6a 100644 --- a/Wox/Languages/en.xaml +++ b/Wox/Languages/en.xaml @@ -29,7 +29,7 @@ Plugin Browse more plugins Disable - Action keyword + Action keywords Plugin Directory Author Init time: {0}ms diff --git a/Wox/Languages/ru.xaml b/Wox/Languages/ru.xaml index a5f5520475..13a7be86cc 100644 --- a/Wox/Languages/ru.xaml +++ b/Wox/Languages/ru.xaml @@ -29,7 +29,7 @@ Плагины Найти больше плагинов Отключить - Ключевое слово + Ключевое слово Папка Автор Инициализация: {0}ms diff --git a/Wox/Languages/zh-cn.xaml b/Wox/Languages/zh-cn.xaml index d75714e9f9..0823b5f3e0 100644 --- a/Wox/Languages/zh-cn.xaml +++ b/Wox/Languages/zh-cn.xaml @@ -29,7 +29,7 @@ 插件 浏览更多插件 禁用 - 触发关键字 + 触发关键字 插件目录 作者 加载耗时 {0}ms diff --git a/Wox/Languages/zh-tw.xaml b/Wox/Languages/zh-tw.xaml index 22562e170b..5d8907fe7a 100644 --- a/Wox/Languages/zh-tw.xaml +++ b/Wox/Languages/zh-tw.xaml @@ -29,7 +29,7 @@ 插件 瀏覽更多插件 禁用 - 觸發關鍵字 + 觸發關鍵字 插件目錄 作者 加載耗時:{0}ms diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 5d5384101f..3d94b8fd5b 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -106,10 +106,10 @@ - - + + - + diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index a387914653..e96720ae2f 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -117,7 +117,8 @@ namespace Wox cbEnableProxy.Unchecked += (o, e) => DisableProxy(); cbEnableProxy.IsChecked = UserSettingStorage.Instance.ProxyEnabled; tbProxyServer.Text = UserSettingStorage.Instance.ProxyServer; - if (UserSettingStorage.Instance.ProxyPort != 0) { + if (UserSettingStorage.Instance.ProxyPort != 0) + { tbProxyPort.Text = UserSettingStorage.Instance.ProxyPort.ToString(); } tbProxyUserName.Text = UserSettingStorage.Instance.ProxyUserName; @@ -187,6 +188,23 @@ namespace Wox { OnHotkeyTabSelected(); } + + // save multiple action keywords settings, todo: this hack is ugly + var tab = e.RemovedItems.Count > 0 ? e.RemovedItems[0] : null; + if (ReferenceEquals(tab, tabPlugin)) + { + var metadata = (lbPlugins.SelectedItem as PluginPair)?.Metadata; + if (metadata != null) + { + var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID); + if (customizedPluginConfig != null && !customizedPluginConfig.Disabled) + { + customizedPluginConfig.ActionKeywords = metadata.ActionKeywords; + UserSettingStorage.Instance.Save(); + } + + } + } } #region General @@ -527,16 +545,24 @@ namespace Wox { provider = pair.Plugin as ISettingProvider; pluginAuthor.Visibility = Visibility.Visible; - pluginActionKeywords.Visibility = Visibility.Visible; pluginInitTime.Text = string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime); pluginQueryTime.Text = string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"), pair.AvgQueryTime); - pluginActionKeywordTitle.Visibility = Visibility.Visible; + if (pair.Metadata.ActionKeywords.Count > 0) + { + pluginActionKeywordsTitle.Visibility = Visibility.Collapsed; + pluginActionKeywords.Visibility = Visibility.Collapsed; + } + else + { + pluginActionKeywordsTitle.Visibility = Visibility.Visible; + pluginActionKeywords.Visibility = Visibility.Visible; + } tbOpenPluginDirecoty.Visibility = Visibility.Visible; pluginTitle.Text = pair.Metadata.Name; pluginTitle.Cursor = Cursors.Hand; - pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, pair.Metadata.ActionKeywords); + pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, pair.Metadata.ActionKeywords.ToArray()); pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author; pluginSubTitle.Text = pair.Metadata.Description; pluginId = pair.Metadata.ID; @@ -606,7 +632,7 @@ namespace Wox ActionKeywords changeKeywordsWindow = new ActionKeywords(id); changeKeywordsWindow.ShowDialog(); PluginPair plugin = PluginManager.GetPluginForId(id); - if (plugin != null) pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, pair.Metadata.ActionKeywords); + if (plugin != null) pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, pair.Metadata.ActionKeywords.ToArray()); } } }