mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #372 from Wox-launcher/dev
Multiple action keywords implemented
This commit is contained in:
commit
ddc28c43c8
36 changed files with 373 additions and 386 deletions
|
|
@ -12,7 +12,7 @@ using Control = System.Windows.Controls.Control;
|
|||
|
||||
namespace Wox.Plugin.CMD
|
||||
{
|
||||
public class CMD : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery, IContextMenu
|
||||
public class CMD : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IContextMenu
|
||||
{
|
||||
private PluginInitContext context;
|
||||
private bool WinRStroked;
|
||||
|
|
@ -202,11 +202,6 @@ namespace Wox.Plugin.CMD
|
|||
|
||||
public bool IsInstantQuery(string query) => false;
|
||||
|
||||
public bool IsExclusiveQuery(Query query)
|
||||
{
|
||||
return query.Search.StartsWith(">");
|
||||
}
|
||||
|
||||
public List<Result> LoadContextMenus(Result selectedResult)
|
||||
{
|
||||
return new List<Result>()
|
||||
|
|
|
|||
|
|
@ -7,47 +7,32 @@ using Wox.Core.UserSettings;
|
|||
|
||||
namespace Wox.Plugin.PluginIndicator
|
||||
{
|
||||
public class PluginIndicator : IPlugin,IPluginI18n
|
||||
public class PluginIndicator : IPlugin, IPluginI18n
|
||||
{
|
||||
private List<PluginPair> allPlugins = new List<PluginPair>();
|
||||
private PluginInitContext context;
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
if (allPlugins.Count == 0)
|
||||
{
|
||||
allPlugins = context.API.GetAllPlugins().Where(o => !PluginManager.IsSystemPlugin(o.Metadata)).ToList();
|
||||
}
|
||||
|
||||
foreach (PluginMetadata metadata in allPlugins.Select(o => o.Metadata))
|
||||
{
|
||||
if (metadata.ActionKeyword.StartsWith(query.Search))
|
||||
{
|
||||
PluginMetadata metadataCopy = metadata;
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadataCopy.ID);
|
||||
if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Result result = new Result
|
||||
{
|
||||
Title = metadata.ActionKeyword,
|
||||
SubTitle = string.Format("Activate {0} plugin", metadata.Name),
|
||||
Score = 100,
|
||||
IcoPath = metadata.FullIcoPath,
|
||||
Action = (c) =>
|
||||
{
|
||||
context.API.ChangeQuery(metadataCopy.ActionKeyword + " ");
|
||||
return false;
|
||||
},
|
||||
};
|
||||
results.Add(result);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
var results = from plugin in PluginManager.NonGlobalPlugins
|
||||
select plugin.Metadata into metadata
|
||||
from keyword in metadata.ActionKeywords
|
||||
where keyword.StartsWith(query.Terms[0])
|
||||
let customizedPluginConfig =
|
||||
UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID)
|
||||
where customizedPluginConfig == null || !customizedPluginConfig.Disabled
|
||||
select new Result
|
||||
{
|
||||
Title = keyword,
|
||||
SubTitle = $"Activate {metadata.Name} plugin",
|
||||
Score = 100,
|
||||
IcoPath = metadata.FullIcoPath,
|
||||
Action = (c) =>
|
||||
{
|
||||
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeperater}");
|
||||
return false;
|
||||
},
|
||||
};
|
||||
return results.ToList();
|
||||
}
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
|
|
|
|||
|
|
@ -7,134 +7,109 @@ using System.Net;
|
|||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Wox.Plugin.PluginManagement
|
||||
{
|
||||
public class Main : IPlugin,IPluginI18n
|
||||
public class Main : IPlugin, IPluginI18n
|
||||
{
|
||||
private static string APIBASE = "https://api.getwox.com";
|
||||
private static string PluginConfigName = "plugin.json";
|
||||
private static string pluginSearchUrl = APIBASE + "/plugin/search/";
|
||||
private const string ListCommand = "list";
|
||||
private const string InstallCommand = "install";
|
||||
private const string UninstallCommand = "uninstall";
|
||||
private PluginInitContext context;
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
|
||||
if (string.IsNullOrEmpty(query.Search))
|
||||
{
|
||||
results.Add(new Result("install <pluginName>", "Images\\plugin.png", "search and install wox plugins")
|
||||
{
|
||||
Action = e => ChangeToInstallCommand()
|
||||
});
|
||||
results.Add(new Result("uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin")
|
||||
{
|
||||
Action = e => ChangeToUninstallCommand()
|
||||
});
|
||||
results.Add(new Result("list", "Images\\plugin.png", "list plugins installed")
|
||||
{
|
||||
Action = e => ChangeToListCommand()
|
||||
});
|
||||
results.Add(ResultForListCommandAutoComplete(query));
|
||||
results.Add(ResultForInstallCommandAutoComplete(query));
|
||||
results.Add(ResultForUninstallCommandAutoComplete(query));
|
||||
return results;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.FirstSearch))
|
||||
string command = query.FirstSearch.ToLower();
|
||||
if (string.IsNullOrEmpty(command)) return results;
|
||||
|
||||
if (command == ListCommand)
|
||||
{
|
||||
bool hit = false;
|
||||
switch (query.FirstSearch.ToLower())
|
||||
{
|
||||
case "list":
|
||||
hit = true;
|
||||
results = ListInstalledPlugins();
|
||||
break;
|
||||
return ResultForListInstalledPlugins();
|
||||
}
|
||||
if (command == UninstallCommand)
|
||||
{
|
||||
return ResultForUnInstallPlugin(query);
|
||||
}
|
||||
if (command == InstallCommand)
|
||||
{
|
||||
return ResultForInstallPlugin(query);
|
||||
}
|
||||
|
||||
case "uninstall":
|
||||
hit = true;
|
||||
results = UnInstallPlugins(query);
|
||||
break;
|
||||
|
||||
case "install":
|
||||
hit = true;
|
||||
if (!string.IsNullOrEmpty(query.SecondSearch))
|
||||
{
|
||||
results = InstallPlugin(query.SecondSearch);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hit)
|
||||
{
|
||||
if ("install".Contains(query.FirstSearch.ToLower()))
|
||||
{
|
||||
results.Add(new Result("install <pluginName>", "Images\\plugin.png", "search and install wox plugins")
|
||||
{
|
||||
Action = e => ChangeToInstallCommand()
|
||||
});
|
||||
}
|
||||
if ("uninstall".Contains(query.FirstSearch.ToLower()))
|
||||
{
|
||||
results.Add(new Result("uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin")
|
||||
{
|
||||
Action = e => ChangeToUninstallCommand()
|
||||
});
|
||||
}
|
||||
if ("list".Contains(query.FirstSearch.ToLower()))
|
||||
{
|
||||
results.Add(new Result("list", "Images\\plugin.png", "list plugins installed")
|
||||
{
|
||||
Action = e => ChangeToListCommand()
|
||||
});
|
||||
}
|
||||
}
|
||||
if (InstallCommand.Contains(command))
|
||||
{
|
||||
results.Add(ResultForInstallCommandAutoComplete(query));
|
||||
}
|
||||
if (UninstallCommand.Contains(command))
|
||||
{
|
||||
results.Add(ResultForUninstallCommandAutoComplete(query));
|
||||
}
|
||||
if (ListCommand.Contains(command))
|
||||
{
|
||||
results.Add(ResultForListCommandAutoComplete(query));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private bool ChangeToListCommand()
|
||||
private Result ResultForListCommandAutoComplete(Query query)
|
||||
{
|
||||
if (context.CurrentPluginMetadata.ActionKeyword == "*")
|
||||
{
|
||||
context.API.ChangeQuery("list ");
|
||||
}
|
||||
else
|
||||
{
|
||||
context.API.ChangeQuery(string.Format("{0} list ", context.CurrentPluginMetadata.ActionKeyword));
|
||||
}
|
||||
return false;
|
||||
string title = ListCommand;
|
||||
string subtitle = "list installed plugins";
|
||||
return ResultForCommand(query, ListCommand, title, subtitle);
|
||||
}
|
||||
|
||||
private bool ChangeToUninstallCommand()
|
||||
private Result ResultForInstallCommandAutoComplete(Query query)
|
||||
{
|
||||
if (context.CurrentPluginMetadata.ActionKeyword == "*")
|
||||
{
|
||||
context.API.ChangeQuery("uninstall ");
|
||||
}
|
||||
else
|
||||
{
|
||||
context.API.ChangeQuery(string.Format("{0} uninstall ", context.CurrentPluginMetadata.ActionKeyword));
|
||||
}
|
||||
return false;
|
||||
string title = $"{InstallCommand} <Package Name>";
|
||||
string subtitle = "list installed plugins";
|
||||
return ResultForCommand(query, InstallCommand, title, subtitle);
|
||||
}
|
||||
|
||||
private bool ChangeToInstallCommand()
|
||||
private Result ResultForUninstallCommandAutoComplete(Query query)
|
||||
{
|
||||
if (context.CurrentPluginMetadata.ActionKeyword == "*")
|
||||
{
|
||||
context.API.ChangeQuery("install ");
|
||||
}
|
||||
else
|
||||
{
|
||||
context.API.ChangeQuery(string.Format("{0} install ", context.CurrentPluginMetadata.ActionKeyword));
|
||||
}
|
||||
return false;
|
||||
string title = $"{UninstallCommand} <Package Name>";
|
||||
string subtitle = "list installed plugins";
|
||||
return ResultForCommand(query, UninstallCommand, title, subtitle);
|
||||
}
|
||||
|
||||
private List<Result> InstallPlugin(string queryPluginName)
|
||||
private Result ResultForCommand(Query query, string command, string title, string subtitle)
|
||||
{
|
||||
const string seperater = Plugin.Query.TermSeperater;
|
||||
var result = new Result
|
||||
{
|
||||
Title = title,
|
||||
IcoPath = "Images\\plugin.png",
|
||||
SubTitle = subtitle,
|
||||
Action = e =>
|
||||
{
|
||||
context.API.ChangeQuery($"{query.ActionKeyword}{seperater}{command}{seperater}");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Result> ResultForInstallPlugin(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(pluginSearchUrl + queryPluginName, context.Proxy);
|
||||
string pluginName = query.SecondSearch;
|
||||
if (string.IsNullOrEmpty(pluginName)) return results;
|
||||
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(pluginSearchUrl + pluginName, context.Proxy);
|
||||
Stream s = response.GetResponseStream();
|
||||
if (s != null)
|
||||
{
|
||||
|
|
@ -154,17 +129,17 @@ namespace Wox.Plugin.PluginManagement
|
|||
foreach (WoxPluginResult r in searchedPlugins)
|
||||
{
|
||||
WoxPluginResult r1 = r;
|
||||
results.Add(new Result()
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = r.name,
|
||||
SubTitle = r.description,
|
||||
IcoPath = "Images\\plugin.png",
|
||||
Action = e =>
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Are your sure to install " + r.name + " plugin",
|
||||
"Install plugin", MessageBoxButtons.YesNo);
|
||||
MessageBoxResult result = MessageBox.Show("Are your sure to install " + r.name + " plugin",
|
||||
"Install plugin", MessageBoxButton.YesNo);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
string folder = Path.Combine(Path.GetTempPath(), "WoxPluginDownload");
|
||||
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
|
||||
|
|
@ -201,7 +176,7 @@ namespace Wox.Plugin.PluginManagement
|
|||
return results;
|
||||
}
|
||||
|
||||
private List<Result> UnInstallPlugins(Query query)
|
||||
private List<Result> ResultForUnInstallPlugin(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
List<PluginMetadata> allInstalledPlugins = context.API.GetAllPlugins().Select(o => o.Metadata).ToList();
|
||||
|
|
@ -213,15 +188,14 @@ namespace Wox.Plugin.PluginManagement
|
|||
|
||||
foreach (PluginMetadata plugin in allInstalledPlugins)
|
||||
{
|
||||
var plugin1 = plugin;
|
||||
results.Add(new Result()
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = plugin.Name,
|
||||
SubTitle = plugin.Description,
|
||||
IcoPath = plugin.FullIcoPath,
|
||||
Action = e =>
|
||||
{
|
||||
UnInstallPlugin(plugin1);
|
||||
UnInstallPlugin(plugin);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
@ -232,16 +206,16 @@ namespace Wox.Plugin.PluginManagement
|
|||
private void UnInstallPlugin(PluginMetadata plugin)
|
||||
{
|
||||
string content = string.Format("Do you want to uninstall following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}", plugin.Name, plugin.Version, plugin.Author);
|
||||
if (MessageBox.Show(content, "Wox", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
if (MessageBox.Show(content, "Wox", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
File.Create(Path.Combine(plugin.PluginDirectory, "NeedDelete.txt")).Close();
|
||||
if (MessageBox.Show(
|
||||
"You have uninstalled plugin " + plugin.Name + " successfully.\r\n Restart Wox to take effect?",
|
||||
"Install plugin",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
|
||||
{
|
||||
ProcessStartInfo Info = new ProcessStartInfo();
|
||||
Info.Arguments = "/C ping 127.0.0.1 -n 1 && \"" + Application.ExecutablePath + "\"";
|
||||
Info.Arguments = "/C ping 127.0.0.1 -n 1 && \"" + Assembly.GetExecutingAssembly().Location + "\"";
|
||||
Info.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
Info.CreateNoWindow = true;
|
||||
Info.FileName = "cmd.exe";
|
||||
|
|
@ -251,14 +225,15 @@ namespace Wox.Plugin.PluginManagement
|
|||
}
|
||||
}
|
||||
|
||||
private List<Result> ListInstalledPlugins()
|
||||
private List<Result> ResultForListInstalledPlugins()
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
foreach (PluginMetadata plugin in context.API.GetAllPlugins().Select(o => o.Metadata))
|
||||
{
|
||||
results.Add(new Result()
|
||||
string actionKeywordString = string.Join(" or ", plugin.ActionKeywords.ToArray());
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = plugin.Name + " - " + plugin.ActionKeyword,
|
||||
Title = $"{plugin.Name} - Action Keywords: {actionKeywordString}",
|
||||
SubTitle = plugin.Description,
|
||||
IcoPath = plugin.FullIcoPath
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,9 +38,10 @@
|
|||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Windows.Presentation" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="HttpRequest.cs" />
|
||||
|
|
@ -98,5 +99,4 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
|
||||
</Project>
|
||||
|
|
@ -8,6 +8,7 @@ using System.Windows;
|
|||
using IWshRuntimeLibrary;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin.Program.ProgramSources;
|
||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||
|
||||
namespace Wox.Plugin.Program
|
||||
{
|
||||
|
|
@ -70,15 +71,12 @@ namespace Wox.Plugin.Program
|
|||
{
|
||||
this.context = context;
|
||||
this.context.API.ResultItemDropEvent += API_ResultItemDropEvent;
|
||||
using (new Timeit("Preload programs"))
|
||||
Stopwatch.Debug("Preload programs", () =>
|
||||
{
|
||||
programs = ProgramCacheStorage.Instance.Programs;
|
||||
}
|
||||
Debug.WriteLine(string.Format("Preload {0} programs from cache", programs.Count));
|
||||
using (new Timeit("Program Index"))
|
||||
{
|
||||
IndexPrograms();
|
||||
}
|
||||
});
|
||||
Debug.WriteLine($"Preload {programs.Count} programs from cache");
|
||||
Stopwatch.Debug("Program Index", IndexPrograms);
|
||||
}
|
||||
|
||||
void API_ResultItemDropEvent(Result result, IDataObject dropObject, DragEventArgs e)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<system:String x:Key="wox_plugin_websearch_input_title">Please input title</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_input_action_keyword">Please input action keyword</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_input_url">Please input URL</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">ActionWord has existed, please input a new one</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">ActionKeyword has existed, please input a new one</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_succeed">Succeed</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_websearch_plugin_name">Web Searches</system:String>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Wox.Plugin.WebSearch
|
|||
public class WebSearch
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string ActionWord { get; set; }
|
||||
public string ActionKeyword { get; set; }
|
||||
public string IconPath { get; set; }
|
||||
public string Url { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Wox.Plugin.WebSearch.SuggestionSources;
|
|||
|
||||
namespace Wox.Plugin.WebSearch
|
||||
{
|
||||
public class WebSearchPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery
|
||||
public class WebSearchPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery
|
||||
{
|
||||
private PluginInitContext context;
|
||||
private IDisposable suggestionTimer;
|
||||
|
|
@ -16,17 +16,12 @@ namespace Wox.Plugin.WebSearch
|
|||
public List<Result> Query(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
if (!query.Search.Contains(' '))
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
WebSearch webSearch =
|
||||
WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled);
|
||||
WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionKeyword == query.ActionKeyword && o.Enabled);
|
||||
|
||||
if (webSearch != null)
|
||||
{
|
||||
string keyword = query.SecondToEndSearch;
|
||||
string keyword = query.ActionKeyword;
|
||||
string title = keyword;
|
||||
string subtitle = context.API.GetTranslation("wox_plugin_websearch_search") + " " + webSearch.Title;
|
||||
if (string.IsNullOrEmpty(keyword))
|
||||
|
|
@ -122,14 +117,5 @@ namespace Wox.Plugin.WebSearch
|
|||
|
||||
public bool IsInstantQuery(string query) => false;
|
||||
|
||||
public bool IsExclusiveQuery(Query query)
|
||||
{
|
||||
var strings = query.RawQuery.Split(' ');
|
||||
if (strings.Length > 1)
|
||||
{
|
||||
return WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == strings[0] && o.Enabled);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ namespace Wox.Plugin.WebSearch
|
|||
cbEnable.IsChecked = webSearch.Enabled;
|
||||
tbTitle.Text = webSearch.Title;
|
||||
tbUrl.Text = webSearch.Url;
|
||||
tbActionword.Text = webSearch.ActionWord;
|
||||
tbActionword.Text = webSearch.ActionKeyword;
|
||||
}
|
||||
|
||||
private void ShowIcon(string path)
|
||||
|
|
@ -90,7 +90,7 @@ namespace Wox.Plugin.WebSearch
|
|||
|
||||
if (!update)
|
||||
{
|
||||
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action))
|
||||
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionKeyword == action))
|
||||
{
|
||||
string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist");
|
||||
MessageBox.Show(warning);
|
||||
|
|
@ -98,32 +98,41 @@ namespace Wox.Plugin.WebSearch
|
|||
}
|
||||
WebSearchStorage.Instance.WebSearches.Add(new WebSearch()
|
||||
{
|
||||
ActionWord = action,
|
||||
ActionKeyword = action,
|
||||
Enabled = cbEnable.IsChecked ?? false,
|
||||
IconPath = tbIconPath.Text,
|
||||
Url = url,
|
||||
Title = title
|
||||
});
|
||||
|
||||
//save the action keywords, the order is not metters. Wox will read this metadata when save settings.
|
||||
context.CurrentPluginMetadata.ActionKeywords.Add(action);
|
||||
|
||||
string msg = context.API.GetTranslation("wox_plugin_websearch_succeed");
|
||||
MessageBox.Show(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action && o != updateWebSearch))
|
||||
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionKeyword == action && o != updateWebSearch))
|
||||
{
|
||||
string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist");
|
||||
MessageBox.Show(warning);
|
||||
return;
|
||||
}
|
||||
updateWebSearch.ActionWord = action;
|
||||
updateWebSearch.ActionKeyword = action;
|
||||
updateWebSearch.IconPath = tbIconPath.Text;
|
||||
updateWebSearch.Enabled = cbEnable.IsChecked ?? false;
|
||||
updateWebSearch.Url = url;
|
||||
updateWebSearch.Title= title;
|
||||
|
||||
//save the action keywords, the order is not metters. Wox will read this metadata when save settings.
|
||||
context.CurrentPluginMetadata.ActionKeywords.Add(action);
|
||||
|
||||
string msg = context.API.GetTranslation("wox_plugin_websearch_succeed");
|
||||
MessageBox.Show(msg);
|
||||
}
|
||||
WebSearchStorage.Instance.Save();
|
||||
|
||||
settingWindow.ReloadWebSearchView();
|
||||
Close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace Wox.Plugin.WebSearch
|
|||
WebSearch googleWebSearch = new WebSearch()
|
||||
{
|
||||
Title = "Google",
|
||||
ActionWord = "g",
|
||||
ActionKeyword = "g",
|
||||
IconPath = @"Images\websearch\google.png",
|
||||
Url = "https://www.google.com/search?q={q}",
|
||||
Enabled = true
|
||||
|
|
@ -51,7 +51,7 @@ namespace Wox.Plugin.WebSearch
|
|||
WebSearch wikiWebSearch = new WebSearch()
|
||||
{
|
||||
Title = "Wikipedia",
|
||||
ActionWord = "wiki",
|
||||
ActionKeyword = "wiki",
|
||||
IconPath = @"Images\websearch\wiki.png",
|
||||
Url = "http://en.wikipedia.org/wiki/{q}",
|
||||
Enabled = true
|
||||
|
|
@ -61,7 +61,7 @@ namespace Wox.Plugin.WebSearch
|
|||
WebSearch findIcon = new WebSearch()
|
||||
{
|
||||
Title = "FindIcon",
|
||||
ActionWord = "findicon",
|
||||
ActionKeyword = "findicon",
|
||||
IconPath = @"Images\websearch\pictures.png",
|
||||
Url = "http://findicons.com/search/{q}",
|
||||
Enabled = true
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<GridViewColumn Header="{DynamicResource wox_plugin_websearch_action_keyword}" Width="180">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding ActionWord}"/>
|
||||
<TextBlock Text="{Binding ActionKeyword}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
<Compile Include="WebSearchesSetting.xaml.cs">
|
||||
<DependentUpon>WebSearchesSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WebQueryPlugin.cs" />
|
||||
<Compile Include="WebSearchPlugin.cs" />
|
||||
<Compile Include="WebSearchSetting.xaml.cs">
|
||||
<DependentUpon>WebSearchSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
@ -135,5 +135,4 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"ID":"565B73353DBF4806919830B9202EE3BF",
|
||||
"ActionKeyword":"*",
|
||||
"ActionKeywords": ["g", "wiki", "findicon"],
|
||||
"Name":"Web Searches",
|
||||
"Description":"Provide the web search ability",
|
||||
"Author":"qianlifeng",
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ namespace Wox.Core.Plugin
|
|||
{
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
// for plugins which doesn't has ActionKeywords key
|
||||
metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> {metadata.ActionKeyword};
|
||||
// for plugin still use old ActionKeyword
|
||||
metadata.ActionKeyword = metadata.ActionKeywords?[0];
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
|
|
@ -112,9 +116,10 @@ namespace Wox.Core.Plugin
|
|||
|
||||
//replace action keyword if user customized it.
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID);
|
||||
if (customizedPluginConfig != null && !string.IsNullOrEmpty(customizedPluginConfig.Actionword))
|
||||
if (customizedPluginConfig?.ActionKeywords?.Count > 0)
|
||||
{
|
||||
metadata.ActionKeyword = customizedPluginConfig.Actionword;
|
||||
metadata.ActionKeywords = customizedPluginConfig.ActionKeywords;
|
||||
metadata.ActionKeyword = customizedPluginConfig.ActionKeywords[0];
|
||||
}
|
||||
|
||||
return metadata;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace Wox.Core.Plugin
|
|||
string content = string.Format(
|
||||
"Do you want to install following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}",
|
||||
plugin.Name, plugin.Version, plugin.Author);
|
||||
PluginPair existingPlugin = PluginManager.GetPlugin(plugin.ID);
|
||||
PluginPair existingPlugin = PluginManager.GetPluginForId(plugin.ID);
|
||||
|
||||
if (existingPlugin != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows.Documents;
|
||||
using Wox.Core.Exception;
|
||||
using Wox.Core.i18n;
|
||||
using Wox.Core.UI;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Plugin;
|
||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||
|
||||
namespace Wox.Core.Plugin
|
||||
{
|
||||
|
|
@ -21,23 +20,19 @@ namespace Wox.Core.Plugin
|
|||
public static class PluginManager
|
||||
{
|
||||
public const string DirectoryName = "Plugins";
|
||||
private static List<PluginMetadata> pluginMetadatas;
|
||||
private static IEnumerable<PluginPair> instantQueryPlugins;
|
||||
private static IEnumerable<PluginPair> exclusiveSearchPlugins;
|
||||
private static IEnumerable<PluginPair> contextMenuPlugins;
|
||||
private static List<PluginPair> plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Directories that will hold Wox plugin directory
|
||||
/// </summary>
|
||||
private static List<string> pluginDirectories = new List<string>();
|
||||
|
||||
public static IEnumerable<PluginPair> AllPlugins
|
||||
{
|
||||
get { return plugins; }
|
||||
private set { plugins = value.OrderBy(o => o.Metadata.Name).ToList(); }
|
||||
}
|
||||
public static IEnumerable<PluginPair> AllPlugins { get; private set; }
|
||||
|
||||
public static IEnumerable<PluginPair> GlobalPlugins { get; private set; }
|
||||
public static IEnumerable<PluginPair> NonGlobalPlugins { get; private set; }
|
||||
|
||||
private static IEnumerable<PluginPair> InstantQueryPlugins { get; set; }
|
||||
public static IPublicAPI API { private set; get; }
|
||||
|
||||
public static string PluginDirectory
|
||||
|
|
@ -79,9 +74,9 @@ namespace Wox.Core.Plugin
|
|||
SetupPluginDirectories();
|
||||
API = api;
|
||||
|
||||
pluginMetadatas = PluginConfig.Parse(pluginDirectories);
|
||||
AllPlugins = (new CSharpPluginLoader().LoadPlugin(pluginMetadatas)).
|
||||
Concat(new JsonRPCPluginLoader<PythonPlugin>().LoadPlugin(pluginMetadatas));
|
||||
var metadatas = PluginConfig.Parse(pluginDirectories);
|
||||
AllPlugins = (new CSharpPluginLoader().LoadPlugin(metadatas)).
|
||||
Concat(new JsonRPCPluginLoader<PythonPlugin>().LoadPlugin(metadatas));
|
||||
|
||||
//load plugin i18n languages
|
||||
ResourceMerger.ApplyPluginLanguages();
|
||||
|
|
@ -91,7 +86,7 @@ namespace Wox.Core.Plugin
|
|||
PluginPair pair = pluginPair;
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
{
|
||||
using (var time = new Timeit($"Plugin init: {pair.Metadata.Name}"))
|
||||
var milliseconds = Stopwatch.Normal($"Plugin init: {pair.Metadata.Name}", () =>
|
||||
{
|
||||
pair.Plugin.Init(new PluginInitContext
|
||||
{
|
||||
|
|
@ -99,17 +94,18 @@ namespace Wox.Core.Plugin
|
|||
Proxy = HttpProxy.Instance,
|
||||
API = API
|
||||
});
|
||||
pair.InitTime = time.Current;
|
||||
}
|
||||
});
|
||||
pair.InitTime = milliseconds;
|
||||
InternationalizationManager.Instance.UpdatePluginMetadataTranslations(pair);
|
||||
});
|
||||
}
|
||||
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
{
|
||||
instantQueryPlugins = GetPlugins<IInstantQuery>();
|
||||
exclusiveSearchPlugins = GetPlugins<IExclusiveQuery>();
|
||||
contextMenuPlugins = GetPlugins<IContextMenu>();
|
||||
InstantQueryPlugins = GetPluginsForInterface<IInstantQuery>();
|
||||
contextMenuPlugins = GetPluginsForInterface<IContextMenu>();
|
||||
GlobalPlugins = AllPlugins.Where(p => IsGlobalPlugin(p.Metadata));
|
||||
NonGlobalPlugins = AllPlugins.Where(p => !IsGlobalPlugin(p.Metadata));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -121,33 +117,34 @@ namespace Wox.Core.Plugin
|
|||
public static Query QueryInit(string text) //todo is that possible to move it into type Query?
|
||||
{
|
||||
// replace multiple white spaces with one white space
|
||||
var terms = text.Split(new[] { Query.Seperater }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var rawQuery = string.Join(Query.Seperater, terms.ToArray());
|
||||
var terms = text.Split(new[] { Query.TermSeperater }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var rawQuery = string.Join(Query.TermSeperater, terms);
|
||||
var actionKeyword = string.Empty;
|
||||
var search = rawQuery;
|
||||
IEnumerable<string> actionParameters = terms;
|
||||
List<string> actionParameters = terms.ToList();
|
||||
if (terms.Length == 0) return null;
|
||||
if (IsVailldActionKeyword(terms[0]))
|
||||
{
|
||||
actionKeyword = terms[0];
|
||||
}
|
||||
if (!string.IsNullOrEmpty(actionKeyword))
|
||||
{
|
||||
actionParameters = terms.Skip(1);
|
||||
search = string.Join(Query.Seperater, actionParameters.ToArray());
|
||||
actionParameters = terms.Skip(1).ToList();
|
||||
search = string.Join(Query.TermSeperater, actionParameters.ToArray());
|
||||
}
|
||||
return new Query
|
||||
{
|
||||
Terms = terms, RawQuery = rawQuery, ActionKeyword = actionKeyword, Search = search,
|
||||
Terms = terms,
|
||||
RawQuery = rawQuery,
|
||||
ActionKeyword = actionKeyword,
|
||||
Search = search,
|
||||
// Obsolete value initialisation
|
||||
ActionName = actionKeyword, ActionParameters = actionParameters.ToList()
|
||||
ActionName = actionKeyword,
|
||||
ActionParameters = actionParameters
|
||||
};
|
||||
}
|
||||
|
||||
public static void QueryForAllPlugins(Query query)
|
||||
{
|
||||
var pluginPairs = GetNonSystemPlugin(query) != null ?
|
||||
new List<PluginPair> { GetNonSystemPlugin(query) } : GetSystemPlugins();
|
||||
var pluginPairs = GetPluginForActionKeyword(query.ActionKeyword) != null ?
|
||||
new List<PluginPair> { GetPluginForActionKeyword(query.ActionKeyword) } : GlobalPlugins;
|
||||
foreach (var plugin in pluginPairs)
|
||||
{
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.
|
||||
|
|
@ -155,10 +152,10 @@ namespace Wox.Core.Plugin
|
|||
if (customizedPluginConfig != null && customizedPluginConfig.Disabled) continue;
|
||||
if (IsInstantQueryPlugin(plugin))
|
||||
{
|
||||
using (new Timeit($"Plugin {plugin.Metadata.Name} is executing instant search"))
|
||||
Stopwatch.Debug($"Instant Query for {plugin.Metadata.Name}", () =>
|
||||
{
|
||||
QueryForPlugin(plugin, query);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -174,15 +171,15 @@ namespace Wox.Core.Plugin
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var time = new Timeit($"Query For {pair.Metadata.Name}"))
|
||||
{
|
||||
var results = pair.Plugin.Query(query) ?? new List<Result>();
|
||||
results.ForEach(o => { o.PluginID = pair.Metadata.ID; });
|
||||
var seconds = time.Current;
|
||||
pair.QueryCount += 1;
|
||||
pair.AvgQueryTime = pair.QueryCount == 1 ? seconds : (pair.AvgQueryTime + seconds) / 2;
|
||||
API.PushResults(query, pair.Metadata, results);
|
||||
}
|
||||
List<Result> results = new List<Result>();
|
||||
var milliseconds = Stopwatch.Normal($"Query for {pair.Metadata.Name}", () =>
|
||||
{
|
||||
results = pair.Plugin.Query(query) ?? results;
|
||||
results.ForEach(o => { o.PluginID = pair.Metadata.ID; });
|
||||
});
|
||||
pair.QueryCount += 1;
|
||||
pair.AvgQueryTime = pair.QueryCount == 1 ? milliseconds : (pair.AvgQueryTime + milliseconds) / 2;
|
||||
API.PushResults(query, pair.Metadata, results);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
|
|
@ -197,17 +194,17 @@ namespace Wox.Core.Plugin
|
|||
/// <returns></returns>
|
||||
private static bool IsVailldActionKeyword(string actionKeyword)
|
||||
{
|
||||
if (string.IsNullOrEmpty(actionKeyword) || actionKeyword == Query.WildcardSign) return false;
|
||||
PluginPair pair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == actionKeyword);
|
||||
if (string.IsNullOrEmpty(actionKeyword) || actionKeyword == Query.GlobalPluginWildcardSign) return false;
|
||||
PluginPair pair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeywords.Contains(actionKeyword));
|
||||
if (pair == null) return false;
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.
|
||||
CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pair.Metadata.ID);
|
||||
return customizedPluginConfig == null || !customizedPluginConfig.Disabled;
|
||||
}
|
||||
|
||||
public static bool IsSystemPlugin(PluginMetadata metadata)
|
||||
private static bool IsGlobalPlugin(PluginMetadata metadata)
|
||||
{
|
||||
return metadata.ActionKeyword == Query.WildcardSign;
|
||||
return metadata.ActionKeywords.Contains(Query.GlobalPluginWildcardSign);
|
||||
}
|
||||
|
||||
private static bool IsInstantQueryPlugin(PluginPair plugin)
|
||||
|
|
@ -215,7 +212,7 @@ namespace Wox.Core.Plugin
|
|||
//any plugin that takes more than 200ms for AvgQueryTime won't be treated as IInstantQuery plugin anymore.
|
||||
return plugin.AvgQueryTime < 200 &&
|
||||
plugin.Plugin is IInstantQuery &&
|
||||
instantQueryPlugins.Any(p => p.Metadata.ID == plugin.Metadata.ID);
|
||||
InstantQueryPlugins.Any(p => p.Metadata.ID == plugin.Metadata.ID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -223,39 +220,24 @@ namespace Wox.Core.Plugin
|
|||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static PluginPair GetPlugin(string id)
|
||||
public static PluginPair GetPluginForId(string id)
|
||||
{
|
||||
return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id);
|
||||
}
|
||||
|
||||
public static IEnumerable<PluginPair> GetPlugins<T>() where T : IFeatures
|
||||
private static PluginPair GetPluginForActionKeyword(string actionKeyword)
|
||||
{
|
||||
//if a query doesn't contain a vaild action keyword, it should be a query for system plugin
|
||||
if (string.IsNullOrEmpty(actionKeyword) || actionKeyword == Query.GlobalPluginWildcardSign) return null;
|
||||
return NonGlobalPlugins.FirstOrDefault(o => o.Metadata.ActionKeywords.Contains(actionKeyword));
|
||||
}
|
||||
|
||||
public static IEnumerable<PluginPair> GetPluginsForInterface<T>() where T : IFeatures
|
||||
{
|
||||
return AllPlugins.Where(p => p.Plugin is T);
|
||||
}
|
||||
|
||||
private static PluginPair GetExclusivePlugin(Query query)
|
||||
{
|
||||
return exclusiveSearchPlugins.FirstOrDefault(p => ((IExclusiveQuery)p.Plugin).IsExclusiveQuery(query));
|
||||
}
|
||||
|
||||
private static PluginPair GetActionKeywordPlugin(Query query)
|
||||
{
|
||||
//if a query doesn't contain a vaild action keyword, it should not be a action keword plugin query
|
||||
if (string.IsNullOrEmpty(query.ActionKeyword)) return null;
|
||||
return AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionKeyword);
|
||||
}
|
||||
|
||||
private static PluginPair GetNonSystemPlugin(Query query)
|
||||
{
|
||||
return GetExclusivePlugin(query) ?? GetActionKeywordPlugin(query);
|
||||
}
|
||||
|
||||
private static List<PluginPair> GetSystemPlugins()
|
||||
{
|
||||
return AllPlugins.Where(o => IsSystemPlugin(o.Metadata)).ToList();
|
||||
}
|
||||
|
||||
public static List<Result> GetPluginContextMenus(Result result)
|
||||
public static List<Result> GetContextMenusForPlugin(Result result)
|
||||
{
|
||||
var pluginPair = contextMenuPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID);
|
||||
var plugin = (IContextMenu)pluginPair?.Plugin;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Wox.Core.UI
|
|||
internal static void ApplyPluginLanguages()
|
||||
{
|
||||
RemoveResource(PluginManager.DirectoryName);
|
||||
foreach (var languageFile in PluginManager.GetPlugins<IPluginI18n>().
|
||||
foreach (var languageFile in PluginManager.GetPluginsForInterface<IPluginI18n>().
|
||||
Select(plugin => InternationalizationManager.Instance.GetLanguageFile(((IPluginI18n)plugin.Plugin).GetLanguagesFolder())).
|
||||
Where(file => !string.IsNullOrEmpty(file)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Wox.Core.UserSettings
|
||||
{
|
||||
|
|
@ -9,7 +10,7 @@ namespace Wox.Core.UserSettings
|
|||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Actionword { get; set; }
|
||||
public List<string> ActionKeywords { get; set; }
|
||||
|
||||
public bool Disabled { get; set; }
|
||||
}
|
||||
|
|
|
|||
44
Wox.Infrastructure/Stopwatch.cs
Normal file
44
Wox.Infrastructure/Stopwatch.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
public static class Stopwatch
|
||||
{
|
||||
/// <summary>
|
||||
/// This stopwatch will appear only in Debug mode
|
||||
/// </summary>
|
||||
public static void Debug(string name, Action action)
|
||||
{
|
||||
#if DEBUG
|
||||
Normal(name, action);
|
||||
#else
|
||||
action();
|
||||
#endif
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private static void WriteTimeInfo(string name, long milliseconds)
|
||||
{
|
||||
string info = $"{name} : {milliseconds}ms";
|
||||
System.Diagnostics.Debug.WriteLine(info);
|
||||
Log.Info(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This stopwatch will also appear only in Debug mode
|
||||
/// </summary>
|
||||
public static long Normal(string name, Action action)
|
||||
{
|
||||
var stopWatch = new System.Diagnostics.Stopwatch();
|
||||
stopWatch.Start();
|
||||
action();
|
||||
stopWatch.Stop();
|
||||
var milliseconds = stopWatch.ElapsedMilliseconds;
|
||||
WriteTimeInfo(name, milliseconds);
|
||||
return milliseconds;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
public class Timeit : IDisposable
|
||||
{
|
||||
private readonly Stopwatch _stopwatch = new Stopwatch();
|
||||
private readonly string _name;
|
||||
|
||||
public Timeit(string name)
|
||||
{
|
||||
_name = name;
|
||||
_stopwatch.Start();
|
||||
}
|
||||
|
||||
public long Current
|
||||
{
|
||||
get
|
||||
{
|
||||
_stopwatch.Stop();
|
||||
long seconds = _stopwatch.ElapsedMilliseconds;
|
||||
_stopwatch.Start();
|
||||
return seconds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_stopwatch.Stop();
|
||||
string info = _name + " : " + _stopwatch.ElapsedMilliseconds + "ms";
|
||||
Debug.WriteLine(info);
|
||||
Log.Info(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -53,11 +53,11 @@
|
|||
<Compile Include="Hotkey\KeyEvent.cs" />
|
||||
<Compile Include="Logger\Log.cs" />
|
||||
<Compile Include="PeHeaderReader.cs" />
|
||||
<Compile Include="Stopwatch.cs" />
|
||||
<Compile Include="Storage\BinaryStorage.cs" />
|
||||
<Compile Include="Storage\IStorage.cs" />
|
||||
<Compile Include="Storage\JsonStorage.cs" />
|
||||
<Compile Include="StringMatcher.cs" />
|
||||
<Compile Include="Timeit.cs" />
|
||||
<Compile Include="Unidecoder.Characters.cs" />
|
||||
<Compile Include="Http\HttpRequest.cs" />
|
||||
<Compile Include="Storage\BaseStorage.cs" />
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ namespace Wox.Plugin
|
|||
List<Result> LoadContextMenus(Result selectedResult);
|
||||
}
|
||||
|
||||
[Obsolete("If a plugin has a action keyword, then it is exclusive. This interface will be remove in v1.3.0")]
|
||||
public interface IExclusiveQuery : IFeatures
|
||||
{
|
||||
[Obsolete("If a plugin has a action keyword, then it is exclusive. This method will be remove in v1.3.0")]
|
||||
bool IsExclusiveQuery(Query query);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Wox.Plugin
|
||||
{
|
||||
|
|
@ -23,8 +24,11 @@ namespace Wox.Plugin
|
|||
|
||||
public string PluginDirectory { get; set; }
|
||||
|
||||
[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 List<string> ActionKeywords { get; set; }
|
||||
|
||||
public string IcoPath { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
|||
|
|
@ -23,16 +23,23 @@ namespace Wox.Plugin
|
|||
/// <summary>
|
||||
/// The raw query splited into a string array.
|
||||
/// </summary>
|
||||
internal string[] Terms { private get; set; }
|
||||
|
||||
public const string Seperater = " ";
|
||||
public string[] Terms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// * is used for System Plugin
|
||||
/// Query can be splited into multiple terms by whitespace
|
||||
/// </summary>
|
||||
public const string WildcardSign = "*";
|
||||
public const string TermSeperater = " ";
|
||||
/// <summary>
|
||||
/// User can set multiple action keywords seperated by ';'
|
||||
/// </summary>
|
||||
public const string ActionKeywordSeperater = ";";
|
||||
|
||||
internal string ActionKeyword { get; set; }
|
||||
/// <summary>
|
||||
/// '*' is used for System Plugin
|
||||
/// </summary>
|
||||
public const string GlobalPluginWildcardSign = "*";
|
||||
|
||||
public string ActionKeyword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Return first search split by space if it has
|
||||
|
|
@ -46,8 +53,8 @@ namespace Wox.Plugin
|
|||
{
|
||||
get
|
||||
{
|
||||
var index = String.IsNullOrEmpty(ActionKeyword) ? 1 : 2;
|
||||
return String.Join(Seperater, Terms.Skip(index).ToArray());
|
||||
var index = string.IsNullOrEmpty(ActionKeyword) ? 1 : 2;
|
||||
return string.Join(TermSeperater, Terms.Skip(index).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,18 +72,17 @@ namespace Wox.Plugin
|
|||
{
|
||||
try
|
||||
{
|
||||
return String.IsNullOrEmpty(ActionKeyword) ? Terms[index] : Terms[index + 1];
|
||||
return string.IsNullOrEmpty(ActionKeyword) ? Terms[index] : Terms[index + 1];
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
return String.Empty;
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() => RawQuery;
|
||||
|
||||
[Obsolete("Use Search instead, A plugin developer shouldn't care about action name, as it may changed by users. " +
|
||||
"this property will be removed in v1.3.0")]
|
||||
[Obsolete("Use ActionKeyword, this property will be removed in v1.3.0")]
|
||||
public string ActionName { get; internal set; }
|
||||
|
||||
[Obsolete("Use Search instead, this property will be removed in v1.3.0")]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Window x:Class="Wox.ActionKeyword"
|
||||
<Window x:Class="Wox.ActionKeywords"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="ActionKeyword"
|
||||
Title="ActionKeywords"
|
||||
Icon="Images\app.png"
|
||||
ResizeMode="NoResize"
|
||||
Loaded="ActionKeyword_OnLoaded"
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
<ColumnDefinition></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource oldActionKeyword}"></TextBlock>
|
||||
<TextBlock x:Name="tbOldActionKeyword" Margin="10" FontSize="14" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left">Old ActionKeyword:</TextBlock>
|
||||
<TextBlock x:Name="tbOldActionKeyword" Margin="10" FontSize="14" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left">Old ActionKeywords:</TextBlock>
|
||||
|
||||
<TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource newActionKeyword}"></TextBlock>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1" >
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Wox.Core.i18n;
|
||||
using Wox.Core.Plugin;
|
||||
|
|
@ -7,14 +8,14 @@ using Wox.Plugin;
|
|||
|
||||
namespace Wox
|
||||
{
|
||||
public partial class ActionKeyword : Window
|
||||
public partial class ActionKeywords : Window
|
||||
{
|
||||
private PluginMetadata pluginMetadata;
|
||||
|
||||
public ActionKeyword(string pluginId)
|
||||
public ActionKeywords(string pluginId)
|
||||
{
|
||||
InitializeComponent();
|
||||
PluginPair plugin = PluginManager.GetPlugin(pluginId);
|
||||
PluginPair plugin = PluginManager.GetPluginForId(pluginId);
|
||||
if (plugin == null)
|
||||
{
|
||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("cannotFindSpecifiedPlugin"));
|
||||
|
|
@ -27,7 +28,7 @@ namespace Wox
|
|||
|
||||
private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tbOldActionKeyword.Text = pluginMetadata.ActionKeyword;
|
||||
tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeperater, pluginMetadata.ActionKeywords.ToArray());
|
||||
tbAction.Focus();
|
||||
}
|
||||
|
||||
|
|
@ -44,15 +45,18 @@ namespace Wox
|
|||
return;
|
||||
}
|
||||
|
||||
var actionKeywords = tbAction.Text.Trim().Split(new[] { Query.ActionKeywordSeperater }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
//check new action keyword didn't used by other plugin
|
||||
if (tbAction.Text.Trim() != Query.WildcardSign && PluginManager.AllPlugins.Any(o => o.Metadata.ActionKeyword == tbAction.Text.Trim()))
|
||||
if (actionKeywords[0] != Query.GlobalPluginWildcardSign && PluginManager.AllPlugins.
|
||||
SelectMany(p => p.Metadata.ActionKeywords).
|
||||
Any(k => actionKeywords.Contains(k)))
|
||||
{
|
||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordHasBeenAssigned"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pluginMetadata.ActionKeyword = tbAction.Text.Trim();
|
||||
pluginMetadata.ActionKeywords = actionKeywords;
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pluginMetadata.ID);
|
||||
if (customizedPluginConfig == null)
|
||||
{
|
||||
|
|
@ -61,12 +65,12 @@ namespace Wox
|
|||
Disabled = false,
|
||||
ID = pluginMetadata.ID,
|
||||
Name = pluginMetadata.Name,
|
||||
Actionword = tbAction.Text.Trim()
|
||||
ActionKeywords = actionKeywords
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
customizedPluginConfig.Actionword = tbAction.Text.Trim();
|
||||
customizedPluginConfig.ActionKeywords = actionKeywords;
|
||||
}
|
||||
UserSettingStorage.Instance.Save();
|
||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
|
||||
|
|
@ -6,7 +6,7 @@ using System.Windows;
|
|||
using Wox.CommandArgs;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ namespace Wox
|
|||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
using (new Timeit("Startup Time"))
|
||||
Stopwatch.Debug("Startup Time", () =>
|
||||
{
|
||||
base.OnStartup(e);
|
||||
DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException;
|
||||
|
|
@ -39,7 +39,7 @@ namespace Wox
|
|||
Window = new MainWindow();
|
||||
PluginManager.Init(Window);
|
||||
CommandArgsFactory.Execute(e.Args.ToList());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Windows;
|
|||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Wox.Infrastructure;
|
||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||
|
||||
namespace Wox.ImageLoader
|
||||
{
|
||||
|
|
@ -48,7 +49,7 @@ namespace Wox.ImageLoader
|
|||
new Int32Rect(0, 0, icon.Width, icon.Height), BitmapSizeOptions.FromEmptyOptions());
|
||||
}
|
||||
}
|
||||
catch{}
|
||||
catch { }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
@ -57,7 +58,7 @@ namespace Wox.ImageLoader
|
|||
{
|
||||
//ImageCacheStroage.Instance.TopUsedImages can be changed during foreach, so we need to make a copy
|
||||
var imageList = new Dictionary<string, int>(ImageCacheStroage.Instance.TopUsedImages);
|
||||
using (new Timeit(string.Format("Preload {0} images", imageList.Count)))
|
||||
Stopwatch.Debug($"Preload {imageList.Count} images", () =>
|
||||
{
|
||||
foreach (var image in imageList)
|
||||
{
|
||||
|
|
@ -75,20 +76,22 @@ namespace Wox.ImageLoader
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static ImageSource Load(string path, bool addToCache = true)
|
||||
{
|
||||
using (new Timeit($"Loading image path: {path}"))
|
||||
if (string.IsNullOrEmpty(path)) return null;
|
||||
ImageSource img = null;
|
||||
Stopwatch.Debug($"Loading image path: {path}", () =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return null;
|
||||
|
||||
if (addToCache)
|
||||
{
|
||||
ImageCacheStroage.Instance.Add(path);
|
||||
}
|
||||
|
||||
ImageSource img = null;
|
||||
|
||||
if (imageCache.ContainsKey(path))
|
||||
{
|
||||
img = imageCache[path];
|
||||
|
|
@ -119,8 +122,8 @@ namespace Wox.ImageLoader
|
|||
}
|
||||
}
|
||||
}
|
||||
return img;
|
||||
}
|
||||
});
|
||||
return img;
|
||||
}
|
||||
|
||||
// http://blogs.msdn.com/b/oldnewthing/archive/2011/01/27/10120844.aspx
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<system:String x:Key="plugin">Plugin</system:String>
|
||||
<system:String x:Key="browserMorePlugins">Browse more plugins</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="author">Author</system:String>
|
||||
<system:String x:Key="plugin_init_time">Init time: {0}ms</system:String>
|
||||
|
|
@ -77,13 +77,13 @@
|
|||
<system:String x:Key="about_activate_times">You have activated Wox {0} times</system:String>
|
||||
|
||||
<!--Action Keyword Setting Dialog-->
|
||||
<system:String x:Key="oldActionKeyword">Old Action Keyword</system:String>
|
||||
<system:String x:Key="newActionKeyword">New Action Keyword</system:String>
|
||||
<system:String x:Key="oldActionKeywords">Old Action Keyword</system:String>
|
||||
<system:String x:Key="newActionKeywords">New Action Keyword</system:String>
|
||||
<system:String x:Key="cancel">Cancel</system:String>
|
||||
<system:String x:Key="done">Done</system:String>
|
||||
<system:String x:Key="cannotFindSpecifiedPlugin">Can't find specified plugin</system:String>
|
||||
<system:String x:Key="newActionKeywordCannotBeEmpty">New Action Keyword can't be empty</system:String>
|
||||
<system:String x:Key="newActionKeywordHasBeenAssigned">New ActionKeyword has been assigned to other plugin, please assign another new action keyword</system:String>
|
||||
<system:String x:Key="newActionKeywordsCannotBeEmpty">New Action Keyword can't be empty</system:String>
|
||||
<system:String x:Key="newActionKeywordsHasBeenAssigned">New ActionKeywords has been assigned to other plugin, please assign another new action keyword</system:String>
|
||||
<system:String x:Key="succeed">Succeed</system:String>
|
||||
<system:String x:Key="actionkeyword_tips">Use * if you don't want to specify a action keyword</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<system:String x:Key="plugin">Плагины</system:String>
|
||||
<system:String x:Key="browserMorePlugins">Найти больше плагинов</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="author">Автор</system:String>
|
||||
<system:String x:Key="plugin_init_time">Инициализация: {0}ms</system:String>
|
||||
|
|
@ -77,13 +77,13 @@
|
|||
<system:String x:Key="about_activate_times">Вы воспользовались Wox уже {0} раз</system:String>
|
||||
|
||||
<!--Action Keyword Setting Dialog-->
|
||||
<system:String x:Key="oldActionKeyword">Текущая горячая клавиша</system:String>
|
||||
<system:String x:Key="newActionKeyword">Новая горячая клавиша</system:String>
|
||||
<system:String x:Key="oldActionKeywords">Текущая горячая клавиша</system:String>
|
||||
<system:String x:Key="newActionKeywords">Новая горячая клавиша</system:String>
|
||||
<system:String x:Key="cancel">Отменить</system:String>
|
||||
<system:String x:Key="done">Подтвердить</system:String>
|
||||
<system:String x:Key="cannotFindSpecifiedPlugin">Не удалось найти заданный плагин</system:String>
|
||||
<system:String x:Key="newActionKeywordCannotBeEmpty">Новая горячая клавиша не может быть пустой</system:String>
|
||||
<system:String x:Key="newActionKeywordHasBeenAssigned">Новая горячая клавиша уже используется другим плагином. Пожалуйста, зайдайте новую</system:String>
|
||||
<system:String x:Key="newActionKeywordsCannotBeEmpty">Новая горячая клавиша не может быть пустой</system:String>
|
||||
<system:String x:Key="newActionKeywordsHasBeenAssigned">Новая горячая клавиша уже используется другим плагином. Пожалуйста, зайдайте новую</system:String>
|
||||
<system:String x:Key="succeed">Сохранено</system:String>
|
||||
<system:String x:Key="actionkeyword_tips">Используйте * в случае, если вы не хотите задавать конкретную горячую клавишу</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<system:String x:Key="plugin">插件</system:String>
|
||||
<system:String x:Key="browserMorePlugins">浏览更多插件</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="author">作者</system:String>
|
||||
<system:String x:Key="plugin_init_time">加载耗时 {0}ms</system:String>
|
||||
|
|
@ -77,13 +77,13 @@
|
|||
<system:String x:Key="about_activate_times">你已经激活了Wox {0} 次</system:String>
|
||||
|
||||
<!--Action Keyword 设置对话框-->
|
||||
<system:String x:Key="oldActionKeyword">旧触发关键字</system:String>
|
||||
<system:String x:Key="newActionKeyword">新触发关键字</system:String>
|
||||
<system:String x:Key="oldActionKeywords">旧触发关键字</system:String>
|
||||
<system:String x:Key="newActionKeywords">新触发关键字</system:String>
|
||||
<system:String x:Key="cancel">取消</system:String>
|
||||
<system:String x:Key="done">确定</system:String>
|
||||
<system:String x:Key="cannotFindSpecifiedPlugin">找不到指定的插件</system:String>
|
||||
<system:String x:Key="newActionKeywordCannotBeEmpty">新触发关键字不能为空</system:String>
|
||||
<system:String x:Key="newActionKeywordHasBeenAssigned">新触发关键字已经被指派给其他插件了,请重新选择一个关键字</system:String>
|
||||
<system:String x:Key="newActionKeywordsCannotBeEmpty">新触发关键字不能为空</system:String>
|
||||
<system:String x:Key="newActionKeywordsHasBeenAssigned">新触发关键字已经被指派给其他插件了,请重新选择一个关键字</system:String>
|
||||
<system:String x:Key="succeed">成功</system:String>
|
||||
<system:String x:Key="actionkeyword_tips">如果你不想设置触发关键字,可以使用*代替</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<system:String x:Key="plugin">插件</system:String>
|
||||
<system:String x:Key="browserMorePlugins">瀏覽更多插件</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="author">作者</system:String>
|
||||
<system:String x:Key="plugin_init_time">加載耗時:{0}ms</system:String>
|
||||
|
|
@ -77,13 +77,13 @@
|
|||
<system:String x:Key="about_activate_times">你已經激活了Wox {0} 次</system:String>
|
||||
|
||||
<!--Action Keyword 設置對話框-->
|
||||
<system:String x:Key="oldActionKeyword">舊觸發關鍵字</system:String>
|
||||
<system:String x:Key="newActionKeyword">新觸發關鍵字</system:String>
|
||||
<system:String x:Key="oldActionKeywords">舊觸發關鍵字</system:String>
|
||||
<system:String x:Key="newActionKeywords">新觸發關鍵字</system:String>
|
||||
<system:String x:Key="cancel">取消</system:String>
|
||||
<system:String x:Key="done">確定</system:String>
|
||||
<system:String x:Key="cannotFindSpecifiedPlugin">找不到指定的插件</system:String>
|
||||
<system:String x:Key="newActionKeywordCannotBeEmpty">新觸發關鍵字不能為空</system:String>
|
||||
<system:String x:Key="newActionKeywordHasBeenAssigned">新觸發關鍵字已經被指派給其他插件了,請重新選擇一個關鍵字</system:String>
|
||||
<system:String x:Key="newActionKeywordsCannotBeEmpty">新觸發關鍵字不能為空</system:String>
|
||||
<system:String x:Key="newActionKeywordsHasBeenAssigned">新觸發關鍵字已經被指派給其他插件了,請重新選擇一個關鍵字</system:String>
|
||||
<system:String x:Key="succeed">成功</system:String>
|
||||
<system:String x:Key="actionkeyword_tips">如果你不想設置觸發關鍵字,可以使用*代替</system:String>
|
||||
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ namespace Wox
|
|||
Query(tbQuery.Text);
|
||||
Dispatcher.DelayInvoke("ShowProgressbar", () =>
|
||||
{
|
||||
if (!queryHasReturn && !string.IsNullOrEmpty(tbQuery.Text) && tbQuery.Text != lastQuery)
|
||||
if (!string.IsNullOrEmpty(tbQuery.Text.Trim()) && tbQuery.Text != lastQuery && !queryHasReturn)
|
||||
{
|
||||
StartProgress();
|
||||
}
|
||||
|
|
@ -873,10 +873,10 @@ namespace Wox
|
|||
|
||||
private void ShowContextMenu(Result result)
|
||||
{
|
||||
List<Result> results = PluginManager.GetPluginContextMenus(result);
|
||||
List<Result> results = PluginManager.GetContextMenusForPlugin(result);
|
||||
results.ForEach(o =>
|
||||
{
|
||||
o.PluginDirectory = PluginManager.GetPlugin(result.PluginID).Metadata.PluginDirectory;
|
||||
o.PluginDirectory = PluginManager.GetPluginForId(result.PluginID).Metadata.PluginDirectory;
|
||||
o.PluginID = result.PluginID;
|
||||
o.OriginQuery = result.OriginQuery;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -106,10 +106,10 @@
|
|||
<CheckBox x:Name="cbDisablePlugin" Click="CbDisablePlugin_OnClick">
|
||||
<TextBlock Text="{DynamicResource disable}"></TextBlock>
|
||||
</CheckBox>
|
||||
<TextBlock x:Name="pluginActionKeywordTitle" Margin="20 0 0 0">
|
||||
<TextBlock Text="{DynamicResource actionKeyword}"></TextBlock>
|
||||
<TextBlock x:Name="pluginActionKeywordsTitle" Margin="20 0 0 0">
|
||||
<TextBlock Text="{DynamicResource actionKeywords}"></TextBlock>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="5 0 0 0" ToolTip="Change Action Keyword" Cursor="Hand" MouseUp="PluginActionKeyword_OnMouseUp" Foreground="Blue" Text="key" x:Name="pluginActionKeyword"></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="Query time: 0ms" x:Name="pluginQueryTime"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Right" Cursor="Hand" MouseUp="tbOpenPluginDirecoty_MouseUp" Foreground="Blue" Text="{DynamicResource pluginDirectory}" x:Name="tbOpenPluginDirecoty"></TextBlock>
|
||||
|
|
@ -234,7 +234,7 @@
|
|||
<GridViewColumn Header="{DynamicResource actionKeyword}" Width="500">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding ActionKeyword}"/>
|
||||
<TextBlock Text="{Binding ActionKeywords}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ using Wox.Helper;
|
|||
using Wox.Infrastructure;
|
||||
using Wox.Plugin;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
|
|
@ -116,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;
|
||||
|
|
@ -186,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
|
||||
|
|
@ -329,10 +348,10 @@ namespace Wox
|
|||
|
||||
private void OnThemeTabSelected()
|
||||
{
|
||||
using (new Timeit("theme load"))
|
||||
Stopwatch.Debug("theme load", () =>
|
||||
{
|
||||
var s = Fonts.SystemFontFamilies;
|
||||
}
|
||||
});
|
||||
|
||||
if (themeTabLoaded) return;
|
||||
|
||||
|
|
@ -526,16 +545,24 @@ namespace Wox
|
|||
{
|
||||
provider = pair.Plugin as ISettingProvider;
|
||||
pluginAuthor.Visibility = Visibility.Visible;
|
||||
pluginActionKeyword.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;
|
||||
pluginActionKeyword.Text = pair.Metadata.ActionKeyword;
|
||||
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;
|
||||
|
|
@ -577,12 +604,13 @@ namespace Wox
|
|||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == id);
|
||||
if (customizedPluginConfig == null)
|
||||
{
|
||||
// todo when this part will be invoked
|
||||
UserSettingStorage.Instance.CustomizedPluginConfigs.Add(new CustomizedPluginConfig()
|
||||
{
|
||||
Disabled = cbDisabled.IsChecked ?? true,
|
||||
ID = id,
|
||||
Name = name,
|
||||
Actionword = string.Empty
|
||||
ActionKeywords = null
|
||||
});
|
||||
}
|
||||
else
|
||||
|
|
@ -592,7 +620,7 @@ namespace Wox
|
|||
UserSettingStorage.Instance.Save();
|
||||
}
|
||||
|
||||
private void PluginActionKeyword_OnMouseUp(object sender, MouseButtonEventArgs e)
|
||||
private void PluginActionKeywords_OnMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left)
|
||||
{
|
||||
|
|
@ -601,10 +629,10 @@ namespace Wox
|
|||
{
|
||||
//third-party plugin
|
||||
string id = pair.Metadata.ID;
|
||||
ActionKeyword changeKeywordWindow = new ActionKeyword(id);
|
||||
changeKeywordWindow.ShowDialog();
|
||||
PluginPair plugin = PluginManager.GetPlugin(id);
|
||||
if (plugin != null) pluginActionKeyword.Text = plugin.Metadata.ActionKeyword;
|
||||
ActionKeywords changeKeywordsWindow = new ActionKeywords(id);
|
||||
changeKeywordsWindow.ShowDialog();
|
||||
PluginPair plugin = PluginManager.GetPluginForId(id);
|
||||
if (plugin != null) pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, pair.Metadata.ActionKeywords.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="ActionKeyword.xaml.cs">
|
||||
<DependentUpon>ActionKeyword.xaml</DependentUpon>
|
||||
<Compile Include="ActionKeywords.xaml.cs">
|
||||
<DependentUpon>ActionKeywords.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CommandArgs\CommandArgsFactory.cs" />
|
||||
<Compile Include="CommandArgs\HideStartCommandArg.cs" />
|
||||
|
|
@ -160,7 +160,7 @@
|
|||
<Compile Include="SettingWindow.xaml.cs">
|
||||
<DependentUpon>SettingWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="ActionKeyword.xaml">
|
||||
<Page Include="ActionKeywords.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
|
@ -374,5 +374,4 @@ cd "$(TargetDir)Plugins" & del /s /q WindowsInput.dll
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in a new issue