Merge branch 'dev' into uwpErrorFix

This commit is contained in:
theClueless 2019-11-16 11:48:09 +02:00 committed by GitHub
commit 72180d4248
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 272 additions and 49 deletions

View File

@ -1,21 +1,34 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Controls;
using Wox.Infrastructure.Storage;
using Wox.Plugin.BrowserBookmark.Commands; using Wox.Plugin.BrowserBookmark.Commands;
using Wox.Plugin.BrowserBookmark.Models;
using Wox.Plugin.BrowserBookmark.Views;
using Wox.Plugin.SharedCommands; using Wox.Plugin.SharedCommands;
namespace Wox.Plugin.BrowserBookmark namespace Wox.Plugin.BrowserBookmark
{ {
public class Main : IPlugin, IReloadable, IPluginI18n public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, ISavable
{ {
private PluginInitContext context; private PluginInitContext context;
private List<Bookmark> cachedBookmarks = new List<Bookmark>(); private List<Bookmark> cachedBookmarks = new List<Bookmark>();
private readonly Settings _settings;
private readonly PluginJsonStorage<Settings> _storage;
public Main()
{
_storage = new PluginJsonStorage<Settings>();
_settings = _storage.Load();
cachedBookmarks = Bookmarks.LoadAllBookmarks();
}
public void Init(PluginInitContext context) public void Init(PluginInitContext context)
{ {
this.context = context; this.context = context;
cachedBookmarks = Bookmarks.LoadAllBookmarks();
} }
public List<Result> Query(Query query) public List<Result> Query(Query query)
@ -42,8 +55,15 @@ namespace Wox.Plugin.BrowserBookmark
Score = 5, Score = 5,
Action = (e) => Action = (e) =>
{ {
context.API.HideApp(); if (_settings.OpenInNewBrowserWindow)
c.Url.NewBrowserWindow(""); {
c.Url.NewBrowserWindow(_settings.BrowserPath);
}
else
{
c.Url.NewTabInBrowser(_settings.BrowserPath);
}
return true; return true;
} }
}).ToList(); }).ToList();
@ -66,5 +86,14 @@ namespace Wox.Plugin.BrowserBookmark
return context.API.GetTranslation("wox_plugin_browserbookmark_plugin_description"); return context.API.GetTranslation("wox_plugin_browserbookmark_plugin_description");
} }
public Control CreateSettingPanel()
{
return new SettingsControl(_settings);
}
public void Save()
{
_storage.Save();
}
} }
} }

View File

@ -0,0 +1,9 @@
namespace Wox.Plugin.BrowserBookmark.Models
{
public class Settings : BaseModel
{
public bool OpenInNewBrowserWindow { get; set; } = true;
public string BrowserPath { get; set; }
}
}

View File

@ -0,0 +1,25 @@
<UserControl x:Class="Wox.Plugin.BrowserBookmark.Views.SettingsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
Background="White"
d:DesignHeight="300" d:DesignWidth="500">
<Grid Margin="10,10,10,0">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</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 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

@ -0,0 +1,47 @@
using Microsoft.Win32;
using System.Windows;
using System.Windows.Controls;
using Wox.Plugin.BrowserBookmark.Models;
namespace Wox.Plugin.BrowserBookmark.Views
{
/// <summary>
/// Interaction logic for BrowserBookmark.xaml
/// </summary>
public partial class SettingsControl : UserControl
{
private readonly Settings _settings;
public SettingsControl(Settings settings)
{
InitializeComponent();
_settings = settings;
browserPathBox.Text = _settings.BrowserPath;
NewWindowBrowser.IsChecked = _settings.OpenInNewBrowserWindow;
NewTabInBrowser.IsChecked = !_settings.OpenInNewBrowserWindow;
}
private void OnNewBrowserWindowClick(object sender, RoutedEventArgs e)
{
_settings.OpenInNewBrowserWindow = true;
}
private void OnNewTabClick(object sender, RoutedEventArgs e)
{
_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

@ -44,6 +44,7 @@
<HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -57,6 +58,7 @@
<Reference Include="System.Data.SQLite.Linq, Version=1.0.111.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> <Reference Include="System.Data.SQLite.Linq, Version=1.0.111.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Data.SQLite.Linq.1.0.111.0\lib\net451\System.Data.SQLite.Linq.dll</HintPath> <HintPath>..\..\packages\System.Data.SQLite.Linq.1.0.111.0\lib\net451\System.Data.SQLite.Linq.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Xaml" />
<Reference Include="UnidecodeSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="UnidecodeSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\UnidecodeSharp.1.0.0.0\lib\net35\UnidecodeSharp.dll</HintPath> <HintPath>..\..\packages\UnidecodeSharp.1.0.0.0\lib\net35\UnidecodeSharp.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -69,7 +71,11 @@
<Compile Include="Commands\Bookmarks.cs" /> <Compile Include="Commands\Bookmarks.cs" />
<Compile Include="FirefoxBookmarks.cs" /> <Compile Include="FirefoxBookmarks.cs" />
<Compile Include="Main.cs" /> <Compile Include="Main.cs" />
<Compile Include="Models\Settings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Views\SettingsControl.xaml.cs">
<DependentUpon>SettingsControl.xaml</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" /> <None Include="app.config" />
@ -111,6 +117,13 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Page Include="Views\SettingsControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Import Project="..\..\packages\System.Data.SQLite.Core.1.0.111.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.111.0\build\net451\System.Data.SQLite.Core.targets')" /> <Import Project="..\..\packages\System.Data.SQLite.Core.1.0.111.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.111.0\build\net451\System.Data.SQLite.Core.targets')" />

View File

@ -40,6 +40,9 @@ namespace Wox.Plugin.Program.Logger
LogManager.Configuration = configuration; LogManager.Configuration = configuration;
} }
/// <summary>
/// Logs an exception
/// </summary>
[MethodImpl(MethodImplOptions.Synchronized)] [MethodImpl(MethodImplOptions.Synchronized)]
internal static void LogException(string classname, string callingMethodName, string loadingProgramPath, internal static void LogException(string classname, string callingMethodName, string loadingProgramPath,
string interpretationMessage, Exception e) string interpretationMessage, Exception e)
@ -123,7 +126,8 @@ namespace Wox.Plugin.Program.Logger
private static bool IsKnownUWPProgramError(Exception e, string callingMethodName) private static bool IsKnownUWPProgramError(Exception e, string callingMethodName)
{ {
if (((e.HResult == -2147024774 || e.HResult == -2147009769) && callingMethodName == "ResourceFromPri") if (((e.HResult == -2147024774 || e.HResult == -2147009769) && callingMethodName == "ResourceFromPri")
|| (e.HResult == -2147024894 && callingMethodName == "LogoPathFromUri")) || (e.HResult == -2147024894 && (callingMethodName == "LogoPathFromUri" || callingMethodName == "ImageFromPath"))
|| (e.HResult == -2147024864 && callingMethodName == "InitializeAppInfo"))
return true; return true;
if (callingMethodName == "XmlNamespaces") if (callingMethodName == "XmlNamespaces")

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@ -86,6 +86,8 @@ namespace Wox.Plugin.Program.Programs
var e = Marshal.GetExceptionForHR((int)hResult); var e = Marshal.GetExceptionForHR((int)hResult);
ProgramLogger.LogException($"|UWP|InitializeAppInfo|{path}" + ProgramLogger.LogException($"|UWP|InitializeAppInfo|{path}" +
"|Error caused while trying to get the details of the UWP program", e); "|Error caused while trying to get the details of the UWP program", e);
Apps = new List<Application>().ToArray();
} }
} }
@ -157,15 +159,15 @@ namespace Wox.Plugin.Program.Programs
#if !DEBUG #if !DEBUG
catch (Exception e) catch (Exception e)
{ {
ProgramLogger.LogException("|UWP|All|An unexpected error occured and " ProgramLogger.LogException($"|UWP|All|{p.InstalledLocation}|An unexpected error occured and "
+ $"unable to convert Package to UWP for {p.Id.FullName}", e); + $"unable to convert Package to UWP for {p.Id.FullName}", e);
return new Application[] { }; return new Application[] { };
} }
#endif #endif
#if DEBUG //make developer aware and implement handling #if DEBUG //make developer aware and implement handling
catch(Exception) catch(Exception e)
{ {
throw; throw e;
} }
#endif #endif
return u.Apps; return u.Apps;

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_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_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> <system:String x:Key="wox_plugin_url_plugin_filter">Application(*.exe)|*.exe|All files|*.*</system:String>
</ResourceDictionary> </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_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_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> <system:String x:Key="wox_plugin_url_plugin_filter">Programlar (*.exe)|*.exe|Tüm Dosyalar|*.*</system:String>
</ResourceDictionary> </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_set_tip">请设置你的浏览器路径:</system:String>
<system:String x:Key="wox_plugin_url_plugin_choose">选择</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> <system:String x:Key="wox_plugin_url_plugin_filter">程序文件(*.exe)|*.exe|所有文件|*.*</system:String>
</ResourceDictionary> </ResourceDictionary>

View File

@ -79,7 +79,14 @@ namespace Wox.Plugin.Url
} }
try try
{ {
raw.NewBrowserWindow(_settings.BrowserPath); if (_settings.OpenInNewBrowserWindow)
{
raw.NewBrowserWindow(_settings.BrowserPath);
}
else
{
raw.NewTabInBrowser(_settings.BrowserPath);
}
return true; return true;
} }

View File

@ -9,5 +9,7 @@ namespace Wox.Plugin.Url
public class Settings public class Settings
{ {
public string BrowserPath { get; set; } public string BrowserPath { get; set; }
public bool OpenInNewBrowserWindow { get; set; } = true;
} }
} }

View File

@ -3,23 +3,21 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wox.Plugin.Url" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="500">
mc:Ignorable="d" Height="300" Width="500"> <Grid Margin="10,10,10,0">
<Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition Height="40" />
<RowDefinition Height="0*"/> <RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <StackPanel Orientation="Horizontal" Grid.Row="0">
<ColumnDefinition/> <Label Content="Open search in:" Margin="40 3 0 8" />
<ColumnDefinition Width="0*"/> <RadioButton x:Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10" />
<ColumnDefinition Width="0*"/> <RadioButton x:Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10" />
<ColumnDefinition Width="0*"/> </StackPanel>
</Grid.ColumnDefinitions> <StackPanel VerticalAlignment="Top" Grid.Row="1" Height="106" Margin="41,13,0,0">
<Label HorizontalAlignment="Left" Margin="99,22,0,0" VerticalAlignment="Top" Height="43" Width="318" FontSize="20" Content="{DynamicResource wox_plugin_url_plugin_set_tip}"/> <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="35,90,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="311"/> <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="setButton" HorizontalAlignment="Left" Margin="356,247,0,0" VerticalAlignment="Top" Width="110" Height="33" FontSize="20" Click="OnApplyBTClick" Content="{DynamicResource wox_plugin_url_plugin_apply}"/> <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}" />
<Button x:Name="viewButton" HorizontalAlignment="Left" Margin="369,90,0,0" VerticalAlignment="Top" Width="86" Height="34" Click="OnChooseClick" FontSize="20" Content="{DynamicResource wox_plugin_url_plugin_choose}"/> </StackPanel>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -31,11 +31,8 @@ namespace Wox.Plugin.Url
_settings = settings; _settings = settings;
_woxAPI = woxAPI; _woxAPI = woxAPI;
browserPathBox.Text = _settings.BrowserPath; browserPathBox.Text = _settings.BrowserPath;
} NewWindowBrowser.IsChecked = _settings.OpenInNewBrowserWindow;
NewTabInBrowser.IsChecked = !_settings.OpenInNewBrowserWindow;
private void OnApplyBTClick(object sender, RoutedEventArgs e)
{
_settings.BrowserPath = browserPathBox.Text;
} }
private void OnChooseClick(object sender, RoutedEventArgs e) private void OnChooseClick(object sender, RoutedEventArgs e)
@ -47,7 +44,18 @@ namespace Wox.Plugin.Url
if (fileBrowserDialog.ShowDialog() == true) if (fileBrowserDialog.ShowDialog() == true)
{ {
browserPathBox.Text = fileBrowserDialog.FileName; browserPathBox.Text = fileBrowserDialog.FileName;
_settings.BrowserPath = fileBrowserDialog.FileName;
} }
} }
private void OnNewBrowserWindowClick(object sender, RoutedEventArgs e)
{
_settings.OpenInNewBrowserWindow = true;
}
private void OnNewTabClick(object sender, RoutedEventArgs e)
{
_settings.OpenInNewBrowserWindow = false;
}
} }
} }

View File

@ -74,7 +74,14 @@ namespace Wox.Plugin.WebSearch
IcoPath = searchSource.IconPath, IcoPath = searchSource.IconPath,
Action = c => Action = c =>
{ {
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow(""); if (_settings.OpenInNewBrowser)
{
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow(_settings.BrowserPath);
}
else
{
searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewTabInBrowser(_settings.BrowserPath);
}
return true; return true;
} }
@ -132,7 +139,15 @@ namespace Wox.Plugin.WebSearch
IcoPath = searchSource.IconPath, IcoPath = searchSource.IconPath,
Action = c => Action = c =>
{ {
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow(""); if (_settings.OpenInNewBrowser)
{
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow(_settings.BrowserPath);
}
else
{
searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewTabInBrowser(_settings.BrowserPath);
}
return true; return true;
} }
}); });

View File

@ -219,5 +219,9 @@ 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 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>
@ -21,12 +22,20 @@
Content="{DynamicResource wox_plugin_websearch_enable_suggestion}" /> Content="{DynamicResource wox_plugin_websearch_enable_suggestion}" />
<ComboBox ItemsSource="{Binding Settings.Suggestions}" <ComboBox ItemsSource="{Binding Settings.Suggestions}"
SelectedItem="{Binding Settings.SelectedSuggestion}" SelectedItem="{Binding Settings.SelectedSuggestion}"
IsEnabled="{Binding ElementName=EnableSuggestion, Path=IsChecked}" Margin="10" /> IsEnabled="{Binding ElementName=EnableSuggestion, Path=IsChecked}" Margin="10,3,10,10" />
<!-- Not sure why binding IsEnabled directly to Settings.EnableWebSaerchSuggestion is not working --> <!-- Not sure why binding IsEnabled directly to Settings.EnableWebSaerchSuggestion is not working -->
<Label Content="Open search 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 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> </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}">
@ -46,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"

View File

@ -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;
@ -18,6 +19,9 @@ namespace Wox.Plugin.WebSearch
_context = context; _context = context;
_settings = viewModel.Settings; _settings = viewModel.Settings;
DataContext = viewModel; DataContext = viewModel;
browserPathBox.Text = _settings.BrowserPath;
NewWindowBrowser.IsChecked = _settings.OpenInNewBrowser;
NewTabInBrowser.IsChecked = !_settings.OpenInNewBrowser;
} }
private void OnAddSearchSearchClick(object sender, RoutedEventArgs e) private void OnAddSearchSearchClick(object sender, RoutedEventArgs e)
@ -56,5 +60,28 @@ namespace Wox.Plugin.WebSearch
webSearch.ShowDialog(); webSearch.ShowDialog();
} }
} }
private void OnNewBrowserWindowClick(object sender, RoutedEventArgs e)
{
_settings.OpenInNewBrowser = true;
}
private void OnNewTabClick(object sender, RoutedEventArgs e)
{
_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;
}
}
} }
} }

View File

@ -28,6 +28,8 @@ Features
Installation 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 this fork's version of Wox, you can **download** it [here](https://github.com/jjw24/Wox/releases/latest).
To install the upstream version: To install the upstream version:

View File

@ -7,10 +7,11 @@ namespace Wox.Plugin.SharedCommands
{ {
public static class SearchWeb public static class SearchWeb
{ {
/// <summary> Opens search in a new browser. If no browser path is passed in then Chrome is used. /// <summary>
/// Opens search in a new browser. If no browser path is passed in then Chrome is used.
/// Leave browser path blank to use Chrome. /// Leave browser path blank to use Chrome.
/// </summary> /// </summary>
public static void NewBrowserWindow(this string url, string browserPath) public static void NewBrowserWindow(this string url, string browserPath)
{ {
var browserExecutableName = browserPath? var browserExecutableName = browserPath?
.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None) .Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
@ -30,5 +31,28 @@ namespace Wox.Plugin.SharedCommands
Process.Start(url); Process.Start(url);
} }
} }
/// <summary>
/// Opens search as a tab in the default browser chosen in Windows settings.
/// </summary>
public static void NewTabInBrowser(this string url, string browserPath)
{
try
{
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);
}
}
} }
} }

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Threading; using System.Windows.Threading;
using Wox.Infrastructure;
using Wox.Infrastructure.Image; using Wox.Infrastructure.Image;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Plugin; using Wox.Plugin;
@ -22,7 +23,8 @@ namespace Wox.ViewModel
{ {
get get
{ {
if (string.IsNullOrEmpty(Result.IcoPath)) var imagePath = Result.IcoPath;
if (string.IsNullOrEmpty(imagePath) && Result.Icon != null)
{ {
try try
{ {
@ -31,13 +33,12 @@ namespace Wox.ViewModel
catch (Exception e) catch (Exception e)
{ {
Log.Exception($"|ResultViewModel.Image|IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", e); Log.Exception($"|ResultViewModel.Image|IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", e);
return ImageLoader.Load(Result.IcoPath); imagePath = Constant.ErrorIcon;
} }
} }
else
{ // will get here either when icoPath has value\icon delegate is null\when had exception in delegate
return ImageLoader.Load(Result.IcoPath); return ImageLoader.Load(imagePath);
}
} }
} }