Add browser selection to WebSearch plugin

This commit is contained in:
Jeremy Wu 2019-11-11 22:04:01 +11:00
parent d7e6f97d9c
commit 11948c1cce
4 changed files with 28 additions and 6 deletions

View File

@ -76,11 +76,11 @@ namespace Wox.Plugin.WebSearch
{
if (_settings.OpenInNewBrowser)
{
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow("");
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow(_settings.BrowserPath);
}
else
{
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewTabInBrowser("");
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewTabInBrowser(_settings.BrowserPath);
}
return true;
@ -141,11 +141,11 @@ namespace Wox.Plugin.WebSearch
{
if (_settings.OpenInNewBrowser)
{
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow("");
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow(_settings.BrowserPath);
}
else
{
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewTabInBrowser("");
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewTabInBrowser(_settings.BrowserPath);
}
return true;

View File

@ -220,6 +220,8 @@ namespace Wox.Plugin.WebSearch
}
}
public string BrowserPath { get; set; }
public bool OpenInNewBrowser { get; set; } = true;
}
}

View File

@ -11,6 +11,7 @@
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="48" />
<RowDefinition />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
@ -27,9 +28,14 @@
<RadioButton Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10" />
<RadioButton Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10" />
</StackPanel>
<StackPanel Grid.Row="1" HorizontalAlignment="Left" Margin="0,3,0,17" Width="480">
<Label Content="Set browser from path:" Height="28" Margin="0,0,350,0" HorizontalAlignment="Left" Width="130"/>
<TextBox x:Name="browserPathBox" HorizontalAlignment="Left" Height="21" Margin="138,-25,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="214" RenderTransformOrigin="0.502,-1.668"/>
<Button x:Name="viewButton" HorizontalAlignment="Left" Margin="381,-30,0,0" Width="58" Height="25" Click="OnChooseClick" FontSize="10" Content="Choose" />
</StackPanel>
<ListView ItemsSource="{Binding Settings.SearchSources}"
SelectedItem="{Binding Settings.SelectedSearchSource}"
Grid.Row="1">
Grid.Row="2">
<ListView.View>
<GridView>
<GridViewColumn Header="{DynamicResource wox_plugin_websearch_action_keyword}">
@ -49,7 +55,7 @@
</GridView>
</ListView.View>
</ListView>
<StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal">
<StackPanel Grid.Row="3" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Click="OnDeleteSearchSearchClick" Width="100" Margin="10"
Content="{DynamicResource wox_plugin_websearch_delete}" />
<Button Click="OnEditSearchSourceClick" Width="100" Margin="10"

View File

@ -1,3 +1,4 @@
using Microsoft.Win32;
using System.Windows;
using System.Windows.Controls;
using Wox.Core.Plugin;
@ -68,5 +69,18 @@ namespace Wox.Plugin.WebSearch
{
_settings.OpenInNewBrowser = false;
}
private void OnChooseClick(object sender, RoutedEventArgs e)
{
var fileBrowserDialog = new OpenFileDialog();
fileBrowserDialog.Filter = "Application(*.exe)|*.exe|All files|*.*";
fileBrowserDialog.CheckFileExists = true;
fileBrowserDialog.CheckPathExists = true;
if (fileBrowserDialog.ShowDialog() == true)
{
browserPathBox.Text = fileBrowserDialog.FileName;
_settings.BrowserPath = fileBrowserDialog.FileName;
}
}
}
}