Merge pull request #74 from jjw24/add_browserpath_userselection

Allow user to set browser for Url, WebSearch and BrowserBookmark plugins
This commit is contained in:
Jeremy Wu 2019-11-12 07:40:18 +11:00 committed by GitHub
commit c227062a37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 67 additions and 38 deletions

View file

@ -57,11 +57,11 @@ namespace Wox.Plugin.BrowserBookmark
{
if (_settings.OpenInNewBrowserWindow)
{
c.Url.NewBrowserWindow("");
c.Url.NewBrowserWindow(_settings.BrowserPath);
}
else
{
c.Url.NewTabInBrowser("");
c.Url.NewTabInBrowser(_settings.BrowserPath);
}
return true;

View file

@ -3,5 +3,7 @@
public class Settings : BaseModel
{
public bool OpenInNewBrowserWindow { get; set; } = true;
public string BrowserPath { get; set; }
}
}

View file

@ -6,16 +6,20 @@
mc:Ignorable="d"
Background="White"
d:DesignHeight="300" d:DesignWidth="500">
<Grid Margin="10">
<Grid Margin="10,10,10,0">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<Label Content="Open bookmark in:" Margin="40 3 0 8"/>
<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>
<StackPanel VerticalAlignment="Top" Grid.Row="1" Height="106" Margin="41,13,0,0">
<Label Content="Set browser from path:" Height="28" Margin="0,0,155,0" HorizontalAlignment="Left" Width="290"/>
<TextBox x:Name="browserPathBox" HorizontalAlignment="Left" Height="34" Margin="5,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="311" RenderTransformOrigin="0.502,-1.668"/>
<Button x:Name="viewButton" HorizontalAlignment="Left" Margin="340,-33,-1,0" Width="100" Height="28" Click="OnChooseClick" FontSize="10" Content="Choose" />
</StackPanel>
</Grid>
</UserControl>

View file

@ -1,3 +1,4 @@
using Microsoft.Win32;
using System.Windows;
using System.Windows.Controls;
using Wox.Plugin.BrowserBookmark.Models;
@ -15,6 +16,7 @@ namespace Wox.Plugin.BrowserBookmark.Views
{
InitializeComponent();
_settings = settings;
browserPathBox.Text = _settings.BrowserPath;
NewWindowBrowser.IsChecked = _settings.OpenInNewBrowserWindow;
NewTabInBrowser.IsChecked = !_settings.OpenInNewBrowserWindow;
}
@ -28,5 +30,18 @@ namespace Wox.Plugin.BrowserBookmark.Views
{
_settings.OpenInNewBrowserWindow = 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;
}
}
}
}

View file

@ -10,6 +10,5 @@
<system:String x:Key="wox_plugin_url_plugin_set_tip">Please set your browser path:</system:String>
<system:String x:Key="wox_plugin_url_plugin_choose">Choose</system:String>
<system:String x:Key="wox_plugin_url_plugin_apply">Apply</system:String>
<system:String x:Key="wox_plugin_url_plugin_filter">Application(*.exe)|*.exe|All files|*.*</system:String>
</ResourceDictionary>

View file

@ -10,6 +10,5 @@
<system:String x:Key="wox_plugin_url_plugin_set_tip">Tarayıcınızın konumunu ayarlayın:</system:String>
<system:String x:Key="wox_plugin_url_plugin_choose">Seç</system:String>
<system:String x:Key="wox_plugin_url_plugin_apply">Uygula</system:String>
<system:String x:Key="wox_plugin_url_plugin_filter">Programlar (*.exe)|*.exe|Tüm Dosyalar|*.*</system:String>
</ResourceDictionary>

View file

@ -10,6 +10,5 @@
<system:String x:Key="wox_plugin_url_plugin_set_tip">请设置你的浏览器路径:</system:String>
<system:String x:Key="wox_plugin_url_plugin_choose">选择</system:String>
<system:String x:Key="wox_plugin_url_plugin_apply">应用</system:String>
<system:String x:Key="wox_plugin_url_plugin_filter">程序文件(*.exe)|*.exe|所有文件|*.*</system:String>
</ResourceDictionary>

View file

@ -3,29 +3,21 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wox.Plugin.Url"
mc:Ignorable="d" Height="300" Width="500">
<Grid>
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="500">
<Grid Margin="10,10,10,0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="0*"/>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0*"/>
<ColumnDefinition Width="0*"/>
<ColumnDefinition Width="0*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<Label Content="Open search in:" Margin="40,3,0,272"/>
<RadioButton Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10,10,10,272" />
<RadioButton Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10,10,10,272" />
<Label Content="Open search in:" Margin="40 3 0 8" />
<RadioButton x:Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10" />
<RadioButton x:Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10" />
</StackPanel>
<StackPanel VerticalAlignment="Center">
<Label Content="{DynamicResource wox_plugin_url_plugin_set_tip}" Height="42" Margin="0,0,155,0" HorizontalAlignment="Right" Width="310"/>
<TextBox x:Name="browserPathBox" HorizontalAlignment="Left" Height="34" Margin="35,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="311" RenderTransformOrigin="0.502,-1.668"/>
<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}" />
<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}" />
<StackPanel VerticalAlignment="Top" Grid.Row="1" Height="106" Margin="41,13,0,0">
<Label Content="{DynamicResource wox_plugin_url_plugin_set_tip}" Height="28" Margin="0,0,155,0" HorizontalAlignment="Left" Width="290" />
<TextBox x:Name="browserPathBox" HorizontalAlignment="Left" Height="34" Margin="5,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="311" RenderTransformOrigin="0.502,-1.668" />
<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}" />
</StackPanel>
</Grid>
</UserControl>

View file

@ -35,11 +35,6 @@ namespace Wox.Plugin.Url
NewTabInBrowser.IsChecked = !_settings.OpenInNewBrowserWindow;
}
private void OnApplyBTClick(object sender, RoutedEventArgs e)
{
_settings.BrowserPath = browserPathBox.Text;
}
private void OnChooseClick(object sender, RoutedEventArgs e)
{
var fileBrowserDialog = new OpenFileDialog();
@ -49,6 +44,7 @@ namespace Wox.Plugin.Url
if (fileBrowserDialog.ShowDialog() == true)
{
browserPathBox.Text = fileBrowserDialog.FileName;
_settings.BrowserPath = fileBrowserDialog.FileName;
}
}

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;
@ -18,6 +19,7 @@ namespace Wox.Plugin.WebSearch
_context = context;
_settings = viewModel.Settings;
DataContext = viewModel;
browserPathBox.Text = _settings.BrowserPath;
NewWindowBrowser.IsChecked = _settings.OpenInNewBrowser;
NewTabInBrowser.IsChecked = !_settings.OpenInNewBrowser;
}
@ -68,5 +70,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;
}
}
}
}