Skip to content

Commit c227062

Browse files
authored
Merge pull request #74 from jjw24/add_browserpath_userselection
Allow user to set browser for Url, WebSearch and BrowserBookmark plugins
2 parents e9376af + 8abe313 commit c227062

File tree

13 files changed

+67
-38
lines changed

13 files changed

+67
-38
lines changed

Plugins/Wox.Plugin.BrowserBookmark/Main.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ public List<Result> Query(Query query)
5757
{
5858
if (_settings.OpenInNewBrowserWindow)
5959
{
60-
c.Url.NewBrowserWindow("");
60+
c.Url.NewBrowserWindow(_settings.BrowserPath);
6161
}
6262
else
6363
{
64-
c.Url.NewTabInBrowser("");
64+
c.Url.NewTabInBrowser(_settings.BrowserPath);
6565
}
6666

6767
return true;

Plugins/Wox.Plugin.BrowserBookmark/Models/Settings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
public class Settings : BaseModel
44
{
55
public bool OpenInNewBrowserWindow { get; set; } = true;
6+
7+
public string BrowserPath { get; set; }
68
}
79
}

Plugins/Wox.Plugin.BrowserBookmark/Views/SettingsControl.xaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@
66
mc:Ignorable="d"
77
Background="White"
88
d:DesignHeight="300" d:DesignWidth="500">
9-
<Grid Margin="10">
9+
<Grid Margin="10,10,10,0">
1010
<Grid.RowDefinitions>
1111
<RowDefinition Height="40" />
1212
<RowDefinition />
13-
<RowDefinition Height="40" />
1413
</Grid.RowDefinitions>
1514
<StackPanel Orientation="Horizontal" Grid.Row="0">
1615
<Label Content="Open bookmark in:" Margin="40 3 0 8"/>
1716
<RadioButton Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10" />
1817
<RadioButton Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10" />
19-
</StackPanel>
18+
</StackPanel>
19+
<StackPanel VerticalAlignment="Top" Grid.Row="1" Height="106" Margin="41,13,0,0">
20+
<Label Content="Set browser from path:" Height="28" Margin="0,0,155,0" HorizontalAlignment="Left" Width="290"/>
21+
<TextBox x:Name="browserPathBox" HorizontalAlignment="Left" Height="34" Margin="5,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="311" RenderTransformOrigin="0.502,-1.668"/>
22+
<Button x:Name="viewButton" HorizontalAlignment="Left" Margin="340,-33,-1,0" Width="100" Height="28" Click="OnChooseClick" FontSize="10" Content="Choose" />
23+
</StackPanel>
2024
</Grid>
2125
</UserControl>

Plugins/Wox.Plugin.BrowserBookmark/Views/SettingsControl.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.Win32;
12
using System.Windows;
23
using System.Windows.Controls;
34
using Wox.Plugin.BrowserBookmark.Models;
@@ -15,6 +16,7 @@ public SettingsControl(Settings settings)
1516
{
1617
InitializeComponent();
1718
_settings = settings;
19+
browserPathBox.Text = _settings.BrowserPath;
1820
NewWindowBrowser.IsChecked = _settings.OpenInNewBrowserWindow;
1921
NewTabInBrowser.IsChecked = !_settings.OpenInNewBrowserWindow;
2022
}
@@ -28,5 +30,18 @@ private void OnNewTabClick(object sender, RoutedEventArgs e)
2830
{
2931
_settings.OpenInNewBrowserWindow = false;
3032
}
33+
34+
private void OnChooseClick(object sender, RoutedEventArgs e)
35+
{
36+
var fileBrowserDialog = new OpenFileDialog();
37+
fileBrowserDialog.Filter = "Application(*.exe)|*.exe|All files|*.*";
38+
fileBrowserDialog.CheckFileExists = true;
39+
fileBrowserDialog.CheckPathExists = true;
40+
if (fileBrowserDialog.ShowDialog() == true)
41+
{
42+
browserPathBox.Text = fileBrowserDialog.FileName;
43+
_settings.BrowserPath = fileBrowserDialog.FileName;
44+
}
45+
}
3146
}
3247
}

Plugins/Wox.Plugin.Url/Languages/en.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010

1111
<system:String x:Key="wox_plugin_url_plugin_set_tip">Please set your browser path:</system:String>
1212
<system:String x:Key="wox_plugin_url_plugin_choose">Choose</system:String>
13-
<system:String x:Key="wox_plugin_url_plugin_apply">Apply</system:String>
1413
<system:String x:Key="wox_plugin_url_plugin_filter">Application(*.exe)|*.exe|All files|*.*</system:String>
1514
</ResourceDictionary>

Plugins/Wox.Plugin.Url/Languages/tr.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010

1111
<system:String x:Key="wox_plugin_url_plugin_set_tip">Tarayıcınızın konumunu ayarlayın:</system:String>
1212
<system:String x:Key="wox_plugin_url_plugin_choose">Seç</system:String>
13-
<system:String x:Key="wox_plugin_url_plugin_apply">Uygula</system:String>
1413
<system:String x:Key="wox_plugin_url_plugin_filter">Programlar (*.exe)|*.exe|Tüm Dosyalar|*.*</system:String>
1514
</ResourceDictionary>

Plugins/Wox.Plugin.Url/Languages/zh-cn.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010

1111
<system:String x:Key="wox_plugin_url_plugin_set_tip">请设置你的浏览器路径:</system:String>
1212
<system:String x:Key="wox_plugin_url_plugin_choose">选择</system:String>
13-
<system:String x:Key="wox_plugin_url_plugin_apply">应用</system:String>
1413
<system:String x:Key="wox_plugin_url_plugin_filter">程序文件(*.exe)|*.exe|所有文件|*.*</system:String>
1514
</ResourceDictionary>

Plugins/Wox.Plugin.Url/SettingsControl.xaml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,21 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:local="clr-namespace:Wox.Plugin.Url"
7-
mc:Ignorable="d" Height="300" Width="500">
8-
<Grid>
6+
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="500">
7+
<Grid Margin="10,10,10,0">
98
<Grid.RowDefinitions>
10-
<RowDefinition/>
11-
<RowDefinition Height="0*"/>
9+
<RowDefinition Height="40" />
10+
<RowDefinition />
1211
</Grid.RowDefinitions>
13-
<Grid.ColumnDefinitions>
14-
<ColumnDefinition/>
15-
<ColumnDefinition Width="0*"/>
16-
<ColumnDefinition Width="0*"/>
17-
<ColumnDefinition Width="0*"/>
18-
</Grid.ColumnDefinitions>
1912
<StackPanel Orientation="Horizontal" Grid.Row="0">
20-
<Label Content="Open search in:" Margin="40,3,0,272"/>
21-
<RadioButton Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10,10,10,272" />
22-
<RadioButton Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10,10,10,272" />
13+
<Label Content="Open search in:" Margin="40 3 0 8" />
14+
<RadioButton x:Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10" />
15+
<RadioButton x:Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10" />
2316
</StackPanel>
24-
<StackPanel VerticalAlignment="Center">
25-
<Label Content="{DynamicResource wox_plugin_url_plugin_set_tip}" Height="42" Margin="0,0,155,0" HorizontalAlignment="Right" Width="310"/>
26-
<TextBox x:Name="browserPathBox" HorizontalAlignment="Left" Height="34" Margin="35,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="311" RenderTransformOrigin="0.502,-1.668"/>
27-
<Button x:Name="setButton" HorizontalAlignment="Left" Margin="272,5,0,0" Width="73" Height="25" FontSize="10" Click="OnApplyBTClick" Content="{DynamicResource wox_plugin_url_plugin_apply}" />
28-
<Button x:Name="viewButton" HorizontalAlignment="Left" Margin="180,-25,0,0" Width="73" Height="25" Click="OnChooseClick" FontSize="10" Content="{DynamicResource wox_plugin_url_plugin_choose}" />
17+
<StackPanel VerticalAlignment="Top" Grid.Row="1" Height="106" Margin="41,13,0,0">
18+
<Label Content="{DynamicResource wox_plugin_url_plugin_set_tip}" Height="28" Margin="0,0,155,0" HorizontalAlignment="Left" Width="290" />
19+
<TextBox x:Name="browserPathBox" HorizontalAlignment="Left" Height="34" Margin="5,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="311" RenderTransformOrigin="0.502,-1.668" />
20+
<Button x:Name="viewButton" HorizontalAlignment="Left" Margin="340,-33,-1,0" Width="100" Height="28" Click="OnChooseClick" FontSize="10" Content="{DynamicResource wox_plugin_url_plugin_choose}" />
2921
</StackPanel>
3022
</Grid>
3123
</UserControl>

Plugins/Wox.Plugin.Url/SettingsControl.xaml.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ public SettingsControl(IPublicAPI woxAPI,Settings settings)
3535
NewTabInBrowser.IsChecked = !_settings.OpenInNewBrowserWindow;
3636
}
3737

38-
private void OnApplyBTClick(object sender, RoutedEventArgs e)
39-
{
40-
_settings.BrowserPath = browserPathBox.Text;
41-
}
42-
4338
private void OnChooseClick(object sender, RoutedEventArgs e)
4439
{
4540
var fileBrowserDialog = new OpenFileDialog();
@@ -49,6 +44,7 @@ private void OnChooseClick(object sender, RoutedEventArgs e)
4944
if (fileBrowserDialog.ShowDialog() == true)
5045
{
5146
browserPathBox.Text = fileBrowserDialog.FileName;
47+
_settings.BrowserPath = fileBrowserDialog.FileName;
5248
}
5349
}
5450

Plugins/Wox.Plugin.WebSearch/Main.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ public List<Result> Query(Query query)
7676
{
7777
if (_settings.OpenInNewBrowser)
7878
{
79-
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow("");
79+
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow(_settings.BrowserPath);
8080
}
8181
else
8282
{
83-
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewTabInBrowser("");
83+
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewTabInBrowser(_settings.BrowserPath);
8484
}
8585

8686
return true;
@@ -141,11 +141,11 @@ private async Task<IEnumerable<Result>> Suggestions(string keyword, string subti
141141
{
142142
if (_settings.OpenInNewBrowser)
143143
{
144-
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow("");
144+
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow(_settings.BrowserPath);
145145
}
146146
else
147147
{
148-
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewTabInBrowser("");
148+
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewTabInBrowser(_settings.BrowserPath);
149149
}
150150

151151
return true;

0 commit comments

Comments
 (0)