From 93c952b344f336b3c2405e02f21f3ec9239c72e9 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Fri, 8 Nov 2019 05:47:54 +1100 Subject: [PATCH 01/11] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 36628d4c0..d7ccabd40 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ Features Installation ------------ +View new features released from this fork since Wox v1.3.524: [new releases](https://github.com/jjw24/Wox/releases) + To install this fork's version of Wox, you can **download** it [here](https://github.com/jjw24/Wox/releases/latest). To install the upstream version: From 2debabe66426417494ba1a364082326fea8dc5bd Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 10 Nov 2019 19:12:43 +1100 Subject: [PATCH 02/11] Add option to open in tab for WebSearch plugin --- Plugins/Wox.Plugin.WebSearch/Main.cs | 19 +++++++++++++++-- Plugins/Wox.Plugin.WebSearch/Settings.cs | 2 ++ Wox.Plugin/SharedCommands/SearchWeb.cs | 26 +++++++++++++++++++++--- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Plugins/Wox.Plugin.WebSearch/Main.cs b/Plugins/Wox.Plugin.WebSearch/Main.cs index ec4033ac3..095ce20e1 100644 --- a/Plugins/Wox.Plugin.WebSearch/Main.cs +++ b/Plugins/Wox.Plugin.WebSearch/Main.cs @@ -74,7 +74,14 @@ namespace Wox.Plugin.WebSearch IcoPath = searchSource.IconPath, Action = c => { - searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow(""); + if (_settings.OpenInNewBrowser) + { + searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow(""); + } + else + { + searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewTabInBrowser(""); + } return true; } @@ -132,7 +139,15 @@ namespace Wox.Plugin.WebSearch IcoPath = searchSource.IconPath, Action = c => { - searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow(""); + if (_settings.OpenInNewBrowser) + { + searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow(""); + } + else + { + searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewTabInBrowser(""); + } + return true; } }); diff --git a/Plugins/Wox.Plugin.WebSearch/Settings.cs b/Plugins/Wox.Plugin.WebSearch/Settings.cs index 6277ab753..5f7a3913e 100644 --- a/Plugins/Wox.Plugin.WebSearch/Settings.cs +++ b/Plugins/Wox.Plugin.WebSearch/Settings.cs @@ -219,5 +219,7 @@ namespace Wox.Plugin.WebSearch } } } + + public bool OpenInNewBrowser { get; set; } = true; } } \ No newline at end of file diff --git a/Wox.Plugin/SharedCommands/SearchWeb.cs b/Wox.Plugin/SharedCommands/SearchWeb.cs index 853fca43d..0d94bfd6d 100644 --- a/Wox.Plugin/SharedCommands/SearchWeb.cs +++ b/Wox.Plugin/SharedCommands/SearchWeb.cs @@ -7,7 +7,8 @@ namespace Wox.Plugin.SharedCommands { public static class SearchWeb { - /// Opens search in a new browser. If no browser path is passed in then Chrome is used. + /// + /// Opens search in a new browser. If no browser path is passed in then Chrome is used. /// Leave browser path blank to use Chrome. /// public static void NewBrowserWindow(this string url, string browserPath) @@ -19,11 +20,30 @@ namespace Wox.Plugin.SharedCommands var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath; // Internet Explorer will open url in new browser window, and does not take the --new-window parameter - var browserArguements = browserExecutableName == "iexplore.exe" ? url : "--new-window " + url; + var browserArguements = browserExecutableName == "iexplore.exe" ? "" : "--new-window "; + OpenWebSearch(browser, browserArguements, url); + } + + /// + /// Opens search as a tab in the default browser chosen in Windows settings. + /// + public static void NewTabInBrowser(this string url, string browserPath) + { + var browserExecutableName = browserPath? + .Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None) + .Last(); + + var browser = string.IsNullOrEmpty(browserExecutableName) ? "" : browserPath; + + OpenWebSearch(browser, "", url); + } + + private static void OpenWebSearch(string chosenBrowser, string browserArguements, string url) + { try { - Process.Start(browser, browserArguements); + Process.Start(chosenBrowser, browserArguements + url); } catch (System.ComponentModel.Win32Exception) { From b565d1ab762b92683d72d210f3927804a7f61439 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 10 Nov 2019 19:51:50 +1100 Subject: [PATCH 03/11] Update naming --- Wox.Plugin/SharedCommands/SearchWeb.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Wox.Plugin/SharedCommands/SearchWeb.cs b/Wox.Plugin/SharedCommands/SearchWeb.cs index 0d94bfd6d..e40c40542 100644 --- a/Wox.Plugin/SharedCommands/SearchWeb.cs +++ b/Wox.Plugin/SharedCommands/SearchWeb.cs @@ -17,12 +17,12 @@ namespace Wox.Plugin.SharedCommands .Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None) .Last(); - var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath; + var selectedBrowserPath = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath; // Internet Explorer will open url in new browser window, and does not take the --new-window parameter var browserArguements = browserExecutableName == "iexplore.exe" ? "" : "--new-window "; - OpenWebSearch(browser, browserArguements, url); + OpenWebSearch(selectedBrowserPath, browserArguements, url); } /// @@ -34,9 +34,9 @@ namespace Wox.Plugin.SharedCommands .Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None) .Last(); - var browser = string.IsNullOrEmpty(browserExecutableName) ? "" : browserPath; + var selectedBrowserPath = string.IsNullOrEmpty(browserExecutableName) ? "" : browserPath; - OpenWebSearch(browser, "", url); + OpenWebSearch(selectedBrowserPath, "", url); } private static void OpenWebSearch(string chosenBrowser, string browserArguements, string url) From 3e292d7604690ff8fbbf492feb2f2786516d60f8 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 10 Nov 2019 20:12:45 +1100 Subject: [PATCH 04/11] Reverse changes made to new browser window call --- Wox.Plugin/SharedCommands/SearchWeb.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Wox.Plugin/SharedCommands/SearchWeb.cs b/Wox.Plugin/SharedCommands/SearchWeb.cs index e40c40542..52a79a51b 100644 --- a/Wox.Plugin/SharedCommands/SearchWeb.cs +++ b/Wox.Plugin/SharedCommands/SearchWeb.cs @@ -11,18 +11,25 @@ namespace Wox.Plugin.SharedCommands /// Opens search in a new browser. If no browser path is passed in then Chrome is used. /// Leave browser path blank to use Chrome. /// - public static void NewBrowserWindow(this string url, string browserPath) + public static void NewBrowserWindow(this string url, string browserPath) { var browserExecutableName = browserPath? .Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None) .Last(); - var selectedBrowserPath = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath; + var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath; // Internet Explorer will open url in new browser window, and does not take the --new-window parameter - var browserArguements = browserExecutableName == "iexplore.exe" ? "" : "--new-window "; + var browserArguements = browserExecutableName == "iexplore.exe" ? url : "--new-window " + url; - OpenWebSearch(selectedBrowserPath, browserArguements, url); + try + { + Process.Start(browser, browserArguements); + } + catch (System.ComponentModel.Win32Exception) + { + Process.Start(url); + } } /// From adb2582856748153ee155d31025e298941eb2608 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 10 Nov 2019 20:15:14 +1100 Subject: [PATCH 05/11] Reverse out common open browser call and update open browser in tab --- Wox.Plugin/SharedCommands/SearchWeb.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Wox.Plugin/SharedCommands/SearchWeb.cs b/Wox.Plugin/SharedCommands/SearchWeb.cs index 52a79a51b..f91025bff 100644 --- a/Wox.Plugin/SharedCommands/SearchWeb.cs +++ b/Wox.Plugin/SharedCommands/SearchWeb.cs @@ -36,22 +36,19 @@ namespace Wox.Plugin.SharedCommands /// Opens search as a tab in the default browser chosen in Windows settings. /// public static void NewTabInBrowser(this string url, string browserPath) - { - var browserExecutableName = browserPath? - .Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None) - .Last(); - - var selectedBrowserPath = string.IsNullOrEmpty(browserExecutableName) ? "" : browserPath; - - OpenWebSearch(selectedBrowserPath, "", url); - } - - private static void OpenWebSearch(string chosenBrowser, string browserArguements, string url) { try { - Process.Start(chosenBrowser, browserArguements + url); + if (!string.IsNullOrEmpty(browserPath)) + { + Process.Start(browserPath, url); + } + else + { + Process.Start(url); + } } + // This error may be thrown for Process.Start(browserPath, url) catch (System.ComponentModel.Win32Exception) { Process.Start(url); From 23712ce59067193272bcac6beaabb7be731e1d4c Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 10 Nov 2019 20:43:40 +1100 Subject: [PATCH 06/11] Add option in WebSearches plugin settings panel for user selection --- Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml | 3 +++ Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml.cs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml b/Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml index 01b2d25c6..fd4320e4f 100644 --- a/Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml +++ b/Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml @@ -23,6 +23,9 @@ SelectedItem="{Binding Settings.SelectedSuggestion}" IsEnabled="{Binding ElementName=EnableSuggestion, Path=IsChecked}" Margin="10" /> +