mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 21:41:51 +02:00
@@ -230,7 +230,7 @@ namespace Wox.Plugin.PluginManagement
|
|||||||
List<Result> results = new List<Result>();
|
List<Result> results = new List<Result>();
|
||||||
foreach (PluginMetadata plugin in context.API.GetAllPlugins().Select(o => o.Metadata))
|
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
|
results.Add(new Result
|
||||||
{
|
{
|
||||||
Title = $"{plugin.Name} - Action Keywords: {actionKeywordString}",
|
Title = $"{plugin.Name} - Action Keywords: {actionKeywordString}",
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ namespace Wox.Plugin.WebSearch
|
|||||||
Url = url,
|
Url = url,
|
||||||
Title = title
|
Title = title
|
||||||
});
|
});
|
||||||
|
context.CurrentPluginMetadata.ActionKeywords.Add(action);
|
||||||
string msg = context.API.GetTranslation("wox_plugin_websearch_succeed");
|
string msg = context.API.GetTranslation("wox_plugin_websearch_succeed");
|
||||||
MessageBox.Show(msg);
|
MessageBox.Show(msg);
|
||||||
}
|
}
|
||||||
@@ -120,10 +121,12 @@ namespace Wox.Plugin.WebSearch
|
|||||||
updateWebSearch.Enabled = cbEnable.IsChecked ?? false;
|
updateWebSearch.Enabled = cbEnable.IsChecked ?? false;
|
||||||
updateWebSearch.Url = url;
|
updateWebSearch.Url = url;
|
||||||
updateWebSearch.Title= title;
|
updateWebSearch.Title= title;
|
||||||
|
context.CurrentPluginMetadata.ActionKeywords.Add(action);
|
||||||
string msg = context.API.GetTranslation("wox_plugin_websearch_succeed");
|
string msg = context.API.GetTranslation("wox_plugin_websearch_succeed");
|
||||||
MessageBox.Show(msg);
|
MessageBox.Show(msg);
|
||||||
}
|
}
|
||||||
WebSearchStorage.Instance.Save();
|
WebSearchStorage.Instance.Save();
|
||||||
|
|
||||||
settingWindow.ReloadWebSearchView();
|
settingWindow.ReloadWebSearchView();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace Wox.Core.Plugin
|
|||||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||||
metadata.PluginDirectory = pluginDirectory;
|
metadata.PluginDirectory = pluginDirectory;
|
||||||
// for plugins which doesn't has ActionKeywords key
|
// for plugins which doesn't has ActionKeywords key
|
||||||
metadata.ActionKeywords = metadata.ActionKeywords ?? new[] {metadata.ActionKeyword};
|
metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> {metadata.ActionKeyword};
|
||||||
// for plugin still use old ActionKeyword
|
// for plugin still use old ActionKeyword
|
||||||
metadata.ActionKeyword = metadata.ActionKeywords?[0];
|
metadata.ActionKeyword = metadata.ActionKeywords?[0];
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ namespace Wox.Core.Plugin
|
|||||||
|
|
||||||
//replace action keyword if user customized it.
|
//replace action keyword if user customized it.
|
||||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID);
|
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.ActionKeywords = customizedPluginConfig.ActionKeywords;
|
||||||
metadata.ActionKeyword = customizedPluginConfig.ActionKeywords[0];
|
metadata.ActionKeyword = customizedPluginConfig.ActionKeywords[0];
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Wox.Core.UserSettings
|
|||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public string[] ActionKeywords { get; set; }
|
public List<string> ActionKeywords { get; set; }
|
||||||
|
|
||||||
public bool Disabled { get; set; }
|
public bool Disabled { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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")]
|
[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 ActionKeyword { get; set; }
|
||||||
|
|
||||||
public string[] ActionKeywords { get; set; }
|
public List<string> ActionKeywords { get; set; }
|
||||||
|
|
||||||
public string IcoPath { get; set; }
|
public string IcoPath { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Wox
|
|||||||
|
|
||||||
private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e)
|
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();
|
tbAction.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ namespace Wox
|
|||||||
return;
|
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
|
//check new action keyword didn't used by other plugin
|
||||||
if (actionKeywords[0] != Query.GlobalPluginWildcardSign && PluginManager.AllPlugins.
|
if (actionKeywords[0] != Query.GlobalPluginWildcardSign && PluginManager.AllPlugins.
|
||||||
SelectMany(p => p.Metadata.ActionKeywords).
|
SelectMany(p => p.Metadata.ActionKeywords).
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<system:String x:Key="plugin">Plugin</system:String>
|
<system:String x:Key="plugin">Plugin</system:String>
|
||||||
<system:String x:Key="browserMorePlugins">Browse more plugins</system:String>
|
<system:String x:Key="browserMorePlugins">Browse more plugins</system:String>
|
||||||
<system:String x:Key="disable">Disable</system:String>
|
<system:String x:Key="disable">Disable</system:String>
|
||||||
<system:String x:Key="actionKeyword">Action keyword</system:String>
|
<system:String x:Key="actionKeywords">Action keywords</system:String>
|
||||||
<system:String x:Key="pluginDirectory">Plugin Directory</system:String>
|
<system:String x:Key="pluginDirectory">Plugin Directory</system:String>
|
||||||
<system:String x:Key="author">Author</system:String>
|
<system:String x:Key="author">Author</system:String>
|
||||||
<system:String x:Key="plugin_init_time">Init time: {0}ms</system:String>
|
<system:String x:Key="plugin_init_time">Init time: {0}ms</system:String>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<system:String x:Key="plugin">Плагины</system:String>
|
<system:String x:Key="plugin">Плагины</system:String>
|
||||||
<system:String x:Key="browserMorePlugins">Найти больше плагинов</system:String>
|
<system:String x:Key="browserMorePlugins">Найти больше плагинов</system:String>
|
||||||
<system:String x:Key="disable">Отключить</system:String>
|
<system:String x:Key="disable">Отключить</system:String>
|
||||||
<system:String x:Key="actionKeyword">Ключевое слово</system:String>
|
<system:String x:Key="actionKeywords">Ключевое слово</system:String>
|
||||||
<system:String x:Key="pluginDirectory">Папка</system:String>
|
<system:String x:Key="pluginDirectory">Папка</system:String>
|
||||||
<system:String x:Key="author">Автор</system:String>
|
<system:String x:Key="author">Автор</system:String>
|
||||||
<system:String x:Key="plugin_init_time">Инициализация: {0}ms</system:String>
|
<system:String x:Key="plugin_init_time">Инициализация: {0}ms</system:String>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<system:String x:Key="plugin">插件</system:String>
|
<system:String x:Key="plugin">插件</system:String>
|
||||||
<system:String x:Key="browserMorePlugins">浏览更多插件</system:String>
|
<system:String x:Key="browserMorePlugins">浏览更多插件</system:String>
|
||||||
<system:String x:Key="disable">禁用</system:String>
|
<system:String x:Key="disable">禁用</system:String>
|
||||||
<system:String x:Key="actionKeyword">触发关键字</system:String>
|
<system:String x:Key="actionKeywords">触发关键字</system:String>
|
||||||
<system:String x:Key="pluginDirectory">插件目录</system:String>
|
<system:String x:Key="pluginDirectory">插件目录</system:String>
|
||||||
<system:String x:Key="author">作者</system:String>
|
<system:String x:Key="author">作者</system:String>
|
||||||
<system:String x:Key="plugin_init_time">加载耗时 {0}ms</system:String>
|
<system:String x:Key="plugin_init_time">加载耗时 {0}ms</system:String>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<system:String x:Key="plugin">插件</system:String>
|
<system:String x:Key="plugin">插件</system:String>
|
||||||
<system:String x:Key="browserMorePlugins">瀏覽更多插件</system:String>
|
<system:String x:Key="browserMorePlugins">瀏覽更多插件</system:String>
|
||||||
<system:String x:Key="disable">禁用</system:String>
|
<system:String x:Key="disable">禁用</system:String>
|
||||||
<system:String x:Key="actionKeyword">觸發關鍵字</system:String>
|
<system:String x:Key="actionKeywords">觸發關鍵字</system:String>
|
||||||
<system:String x:Key="pluginDirectory">插件目錄</system:String>
|
<system:String x:Key="pluginDirectory">插件目錄</system:String>
|
||||||
<system:String x:Key="author">作者</system:String>
|
<system:String x:Key="author">作者</system:String>
|
||||||
<system:String x:Key="plugin_init_time">加載耗時:{0}ms</system:String>
|
<system:String x:Key="plugin_init_time">加載耗時:{0}ms</system:String>
|
||||||
|
|||||||
@@ -106,10 +106,10 @@
|
|||||||
<CheckBox x:Name="cbDisablePlugin" Click="CbDisablePlugin_OnClick">
|
<CheckBox x:Name="cbDisablePlugin" Click="CbDisablePlugin_OnClick">
|
||||||
<TextBlock Text="{DynamicResource disable}"></TextBlock>
|
<TextBlock Text="{DynamicResource disable}"></TextBlock>
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<TextBlock x:Name="pluginActionKeywordTitle" Margin="20 0 0 0">
|
<TextBlock x:Name="pluginActionKeywordsTitle" Margin="20 0 0 0">
|
||||||
<TextBlock Text="{DynamicResource actionKeyword}"></TextBlock>
|
<TextBlock Text="{DynamicResource actionKeywords}"></TextBlock>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock Margin="5 0 0 0" ToolTip="Change Action Keyword" Cursor="Hand" MouseUp="PluginActionKeywords_OnMouseUp" Foreground="Blue" Text="key" x:Name="pluginActionKeywords"></TextBlock>
|
<TextBlock Margin="5 0 0 0" ToolTip="Change Action Keywords" Cursor="Hand" MouseUp="PluginActionKeywords_OnMouseUp" Foreground="Blue" Text="keys" x:Name="pluginActionKeywords"></TextBlock>
|
||||||
<TextBlock Margin="10 0 0 0" Text="Init time: 0ms" x:Name="pluginInitTime"></TextBlock>
|
<TextBlock Margin="10 0 0 0" Text="Init time: 0ms" x:Name="pluginInitTime"></TextBlock>
|
||||||
<TextBlock Margin="10 0 0 0" Text="Query time: 0ms" x:Name="pluginQueryTime"></TextBlock>
|
<TextBlock Margin="10 0 0 0" Text="Query time: 0ms" x:Name="pluginQueryTime"></TextBlock>
|
||||||
<TextBlock HorizontalAlignment="Right" Cursor="Hand" MouseUp="tbOpenPluginDirecoty_MouseUp" Foreground="Blue" Text="{DynamicResource pluginDirectory}" x:Name="tbOpenPluginDirecoty"></TextBlock>
|
<TextBlock HorizontalAlignment="Right" Cursor="Hand" MouseUp="tbOpenPluginDirecoty_MouseUp" Foreground="Blue" Text="{DynamicResource pluginDirectory}" x:Name="tbOpenPluginDirecoty"></TextBlock>
|
||||||
|
|||||||
@@ -117,7 +117,8 @@ namespace Wox
|
|||||||
cbEnableProxy.Unchecked += (o, e) => DisableProxy();
|
cbEnableProxy.Unchecked += (o, e) => DisableProxy();
|
||||||
cbEnableProxy.IsChecked = UserSettingStorage.Instance.ProxyEnabled;
|
cbEnableProxy.IsChecked = UserSettingStorage.Instance.ProxyEnabled;
|
||||||
tbProxyServer.Text = UserSettingStorage.Instance.ProxyServer;
|
tbProxyServer.Text = UserSettingStorage.Instance.ProxyServer;
|
||||||
if (UserSettingStorage.Instance.ProxyPort != 0) {
|
if (UserSettingStorage.Instance.ProxyPort != 0)
|
||||||
|
{
|
||||||
tbProxyPort.Text = UserSettingStorage.Instance.ProxyPort.ToString();
|
tbProxyPort.Text = UserSettingStorage.Instance.ProxyPort.ToString();
|
||||||
}
|
}
|
||||||
tbProxyUserName.Text = UserSettingStorage.Instance.ProxyUserName;
|
tbProxyUserName.Text = UserSettingStorage.Instance.ProxyUserName;
|
||||||
@@ -187,6 +188,23 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
OnHotkeyTabSelected();
|
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
|
#region General
|
||||||
@@ -527,16 +545,24 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
provider = pair.Plugin as ISettingProvider;
|
provider = pair.Plugin as ISettingProvider;
|
||||||
pluginAuthor.Visibility = Visibility.Visible;
|
pluginAuthor.Visibility = Visibility.Visible;
|
||||||
pluginActionKeywords.Visibility = Visibility.Visible;
|
|
||||||
pluginInitTime.Text =
|
pluginInitTime.Text =
|
||||||
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
|
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
|
||||||
pluginQueryTime.Text =
|
pluginQueryTime.Text =
|
||||||
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"), pair.AvgQueryTime);
|
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;
|
tbOpenPluginDirecoty.Visibility = Visibility.Visible;
|
||||||
pluginTitle.Text = pair.Metadata.Name;
|
pluginTitle.Text = pair.Metadata.Name;
|
||||||
pluginTitle.Cursor = Cursors.Hand;
|
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;
|
pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author;
|
||||||
pluginSubTitle.Text = pair.Metadata.Description;
|
pluginSubTitle.Text = pair.Metadata.Description;
|
||||||
pluginId = pair.Metadata.ID;
|
pluginId = pair.Metadata.ID;
|
||||||
@@ -606,7 +632,7 @@ namespace Wox
|
|||||||
ActionKeywords changeKeywordsWindow = new ActionKeywords(id);
|
ActionKeywords changeKeywordsWindow = new ActionKeywords(id);
|
||||||
changeKeywordsWindow.ShowDialog();
|
changeKeywordsWindow.ShowDialog();
|
||||||
PluginPair plugin = PluginManager.GetPluginForId(id);
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user