mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
Add browser selection to WebSearch plugin
This commit is contained in:
@@ -76,11 +76,11 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
if (_settings.OpenInNewBrowser)
|
if (_settings.OpenInNewBrowser)
|
||||||
{
|
{
|
||||||
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow("");
|
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow(_settings.BrowserPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewTabInBrowser("");
|
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewTabInBrowser(_settings.BrowserPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -141,11 +141,11 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
if (_settings.OpenInNewBrowser)
|
if (_settings.OpenInNewBrowser)
|
||||||
{
|
{
|
||||||
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow("");
|
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow(_settings.BrowserPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewTabInBrowser("");
|
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewTabInBrowser(_settings.BrowserPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -220,6 +220,8 @@ namespace Wox.Plugin.WebSearch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string BrowserPath { get; set; }
|
||||||
|
|
||||||
public bool OpenInNewBrowser { get; set; } = true;
|
public bool OpenInNewBrowser { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
<Grid Margin="10">
|
<Grid Margin="10">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="40" />
|
<RowDefinition Height="40" />
|
||||||
|
<RowDefinition Height="48" />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition Height="40" />
|
<RowDefinition Height="40" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
@@ -27,9 +28,14 @@
|
|||||||
<RadioButton Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10" />
|
<RadioButton Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10" />
|
||||||
<RadioButton Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10" />
|
<RadioButton Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10" />
|
||||||
</StackPanel>
|
</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}"
|
<ListView ItemsSource="{Binding Settings.SearchSources}"
|
||||||
SelectedItem="{Binding Settings.SelectedSearchSource}"
|
SelectedItem="{Binding Settings.SelectedSearchSource}"
|
||||||
Grid.Row="1">
|
Grid.Row="2">
|
||||||
<ListView.View>
|
<ListView.View>
|
||||||
<GridView>
|
<GridView>
|
||||||
<GridViewColumn Header="{DynamicResource wox_plugin_websearch_action_keyword}">
|
<GridViewColumn Header="{DynamicResource wox_plugin_websearch_action_keyword}">
|
||||||
@@ -49,7 +55,7 @@
|
|||||||
</GridView>
|
</GridView>
|
||||||
</ListView.View>
|
</ListView.View>
|
||||||
</ListView>
|
</ListView>
|
||||||
<StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal">
|
<StackPanel Grid.Row="3" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||||
<Button Click="OnDeleteSearchSearchClick" Width="100" Margin="10"
|
<Button Click="OnDeleteSearchSearchClick" Width="100" Margin="10"
|
||||||
Content="{DynamicResource wox_plugin_websearch_delete}" />
|
Content="{DynamicResource wox_plugin_websearch_delete}" />
|
||||||
<Button Click="OnEditSearchSourceClick" Width="100" Margin="10"
|
<Button Click="OnEditSearchSourceClick" Width="100" Margin="10"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Microsoft.Win32;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
@@ -68,5 +69,18 @@ namespace Wox.Plugin.WebSearch
|
|||||||
{
|
{
|
||||||
_settings.OpenInNewBrowser = false;
|
_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user