diff --git a/Plugins/Wox.Plugin.Url/Main.cs b/Plugins/Wox.Plugin.Url/Main.cs index 6cd486919b..1c3a708c84 100644 --- a/Plugins/Wox.Plugin.Url/Main.cs +++ b/Plugins/Wox.Plugin.Url/Main.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Collections.Generic; -using System.Diagnostics; using System.Text.RegularExpressions; using System.Windows.Controls; using Wox.Infrastructure.Storage; +using Wox.Plugin.SharedCommands; namespace Wox.Plugin.Url { @@ -79,15 +79,8 @@ namespace Wox.Plugin.Url } try { - if (_settings.BrowserPath.Length == 0) - { - Process.Start(raw); - } - else - { - Process.Start(_settings.BrowserPath,raw); - } - + raw.NewBrowserWindow(_settings.BrowserPath); + return true; } catch(Exception ex) diff --git a/Plugins/Wox.Plugin.WebSearch/Main.cs b/Plugins/Wox.Plugin.WebSearch/Main.cs index 1581ddb334..ea7720329f 100644 --- a/Plugins/Wox.Plugin.WebSearch/Main.cs +++ b/Plugins/Wox.Plugin.WebSearch/Main.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Windows.Controls; using Wox.Infrastructure; using Wox.Infrastructure.Storage; +using Wox.Plugin.SharedCommands; namespace Wox.Plugin.WebSearch { @@ -23,6 +24,8 @@ namespace Wox.Plugin.WebSearch public const string Images = "Images"; public static string ImagesDirectory; + private readonly string SearchSourceGlobalPluginWildCardSign = "*"; + public void Save() { _viewModel.Save(); @@ -30,52 +33,58 @@ namespace Wox.Plugin.WebSearch public List Query(Query query) { + var searchSourceList = new List(); + var results = new List(); + _updateSource?.Cancel(); _updateSource = new CancellationTokenSource(); _updateToken = _updateSource.Token; + + _settings.SearchSources.Where(o => (o.ActionKeyword == query.ActionKeyword || o.ActionKeyword == SearchSourceGlobalPluginWildCardSign) + && o.Enabled) + .ToList() + .ForEach(x => searchSourceList.Add(x)); - SearchSource searchSource = - _settings.SearchSources.FirstOrDefault(o => o.ActionKeyword == query.ActionKeyword && o.Enabled); - - if (searchSource != null) + if (searchSourceList.Any()) { - string keyword = query.Search; - string title = keyword; - string subtitle = _context.API.GetTranslation("wox_plugin_websearch_search") + " " + searchSource.Title; - if (string.IsNullOrEmpty(keyword)) + foreach (SearchSource searchSource in searchSourceList) { - var result = new Result + string keyword = query.Search; + string title = keyword; + string subtitle = _context.API.GetTranslation("wox_plugin_websearch_search") + " " + + searchSource.Title; + if (string.IsNullOrEmpty(keyword)) { - Title = subtitle, - SubTitle = string.Empty, - IcoPath = searchSource.IconPath - }; - return new List {result}; - } - else - { - var results = new List(); - var result = new Result - { - Title = title, - SubTitle = subtitle, - Score = 6, - IcoPath = searchSource.IconPath, - Action = c => + var result = new Result { - Process.Start(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword))); - return true; - } - }; - results.Add(result); - UpdateResultsFromSuggestion(results, keyword, subtitle, searchSource, query); - return results; + Title = subtitle, + SubTitle = string.Empty, + IcoPath = searchSource.IconPath + }; + results.Add(result); + } + else + { + var result = new Result + { + Title = title, + SubTitle = subtitle, + Score = 6, + IcoPath = searchSource.IconPath, + Action = c => + { + searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow(""); + + return true; + } + }; + results.Add(result); + UpdateResultsFromSuggestion(results, keyword, subtitle, searchSource, query); + } } } - else - { - return new List(); - } + + return results; } private void UpdateResultsFromSuggestion(List results, string keyword, string subtitle, @@ -115,7 +124,7 @@ namespace Wox.Plugin.WebSearch IcoPath = searchSource.IconPath, Action = c => { - Process.Start(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o))); + searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow(""); return true; } }); @@ -160,4 +169,4 @@ namespace Wox.Plugin.WebSearch public event ResultUpdatedEventHandler ResultsUpdated; } -} \ No newline at end of file +} diff --git a/Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml.cs b/Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml.cs index d50e595a89..6e210c0d3f 100644 --- a/Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml.cs @@ -1,4 +1,4 @@ -using System.Windows; +using System.Windows; using System.Windows.Controls; using Wox.Core.Plugin; @@ -28,27 +28,33 @@ namespace Wox.Plugin.WebSearch private void OnDeleteSearchSearchClick(object sender, RoutedEventArgs e) { - var selected = _settings.SelectedSearchSource; - var warning = _context.API.GetTranslation("wox_plugin_websearch_delete_warning"); - var formated = string.Format(warning, selected.Title); - - var result = MessageBox.Show(formated, string.Empty, MessageBoxButton.YesNo); - if (result == MessageBoxResult.Yes) + if (_settings.SelectedSearchSource != null) { - var id = _context.CurrentPluginMetadata.ID; - PluginManager.RemoveActionKeyword(id, selected.ActionKeyword); - _settings.SearchSources.Remove(selected); + var selected = _settings.SelectedSearchSource; + var warning = _context.API.GetTranslation("wox_plugin_websearch_delete_warning"); + var formated = string.Format(warning, selected.Title); + + var result = MessageBox.Show(formated, string.Empty, MessageBoxButton.YesNo); + if (result == MessageBoxResult.Yes) + { + var id = _context.CurrentPluginMetadata.ID; + PluginManager.RemoveActionKeyword(id, selected.ActionKeyword); + _settings.SearchSources.Remove(selected); + } } } private void OnEditSearchSourceClick(object sender, RoutedEventArgs e) { - var selected = _settings.SelectedSearchSource; - var webSearch = new SearchSourceSettingWindow + if (_settings.SelectedSearchSource != null) + { + var webSearch = new SearchSourceSettingWindow ( - _settings.SearchSources, _context, selected + _settings.SearchSources, _context, _settings.SelectedSearchSource ); - webSearch.ShowDialog(); + + webSearch.ShowDialog(); + } } } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 3612536468..22a1a45d47 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,17 @@ Contribution Build ----- -1. Install Visual Studio 2015 and tick all Windows 10 sdk options -2. Open powershell with admin permission and `Set-ExecutionPolicy Unrestricted -Scope CurrentUser` +Install Visual Studio 2015/2017/2019 + +This project requires Windows 10 SDK: + + VS 2015: + - Tick all Windows 10 sdk options + + VS 2017/2019 and later: + - Last Windows 10 SDK which [supported](https://github.com/Wox-launcher/Wox/pull/1827#commitcomment-26475392) UwpDesktop is version 10.0.14393.795. It is needed to compile "Programs" Plugin (UWP.cs), you will see the "References" of Plugin.Programs as broken if you use a later SDK version. + - This SDK cannot be installed via VS 2019 installer. + - Download and install [Windows 10 SDK version 10.0.14393.795](https://go.microsoft.com/fwlink/p/?LinkId=838916). Documentation ------------- diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index ecbf9e3905..6ca826fd9b 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -106,16 +106,12 @@ namespace Wox.Core.Plugin foreach (var plugin in AllPlugins) { if (IsGlobalPlugin(plugin.Metadata)) - { GlobalPlugins.Add(plugin); - } - else - { - foreach (string actionKeyword in plugin.Metadata.ActionKeywords) - { - NonGlobalPlugins[actionKeyword] = plugin; - } - } + + // Plugins may have multiple ActionKeywords, eg. WebSearch + plugin.Metadata.ActionKeywords.Where(x => x != Query.GlobalPluginWildcardSign) + .ToList() + .ForEach(x => NonGlobalPlugins[x] = plugin); } } @@ -289,14 +285,20 @@ namespace Wox.Core.Plugin public static void RemoveActionKeyword(string id, string oldActionkeyword) { var plugin = GetPluginForId(id); - if (oldActionkeyword == Query.GlobalPluginWildcardSign) + if (oldActionkeyword == Query.GlobalPluginWildcardSign + && // Plugins may have multiple ActionKeywords that are global, eg. WebSearch + plugin.Metadata.ActionKeywords + .Where(x => x == Query.GlobalPluginWildcardSign) + .ToList() + .Count == 1) { GlobalPlugins.Remove(plugin); } - else - { + + if(oldActionkeyword != Query.GlobalPluginWildcardSign) NonGlobalPlugins.Remove(oldActionkeyword); - } + + plugin.Metadata.ActionKeywords.Remove(oldActionkeyword); } diff --git a/Wox/Themes/BlackAndWhite.xaml b/Wox/Themes/BlackAndWhite.xaml new file mode 100644 index 0000000000..8c3f0cbd45 --- /dev/null +++ b/Wox/Themes/BlackAndWhite.xaml @@ -0,0 +1 @@ + #4F6180 \ No newline at end of file diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 48a5c8697b..faa10af787 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -374,6 +374,11 @@ Designer PreserveNewest + + MSBuild:Compile + Designer + PreserveNewest + MSBuild:Compile Designer @@ -462,7 +467,7 @@ - powershell.exe -NoProfile -File $(SolutionDir)Scripts\post_build.ps1 $(ConfigurationName) $(SolutionDir) + powershell.exe -NoProfile -ExecutionPolicy Bypass -File $(SolutionDir)Scripts\post_build.ps1 $(ConfigurationName) $(SolutionDir) taskkill /f /fi "IMAGENAME eq Wox.exe"