Add everything plugin context menu and add settings in Url plugin (#2299)

1. Add useful context menu items in everything
2. Add settings in Url plugin, can set browser path

* let url plugin support multi Languages
This commit is contained in:
magicdmer
2018-12-25 15:11:24 +08:00
committed by jhdxr
parent 0baf7744bc
commit a6e82475a3
11 changed files with 200 additions and 4 deletions

View File

@@ -2,10 +2,12 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Windows.Controls;
using Wox.Infrastructure.Storage;
namespace Wox.Plugin.Url
{
public class Main : IPlugin, IPluginI18n
public class Main : ISettingProvider,IPlugin, IPluginI18n, ISavable
{
//based on https://gist.github.com/dperini/729294
private const string urlPattern = "^" +
@@ -42,6 +44,19 @@ namespace Wox.Plugin.Url
"$";
Regex reg = new Regex(urlPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
private PluginInitContext context;
private readonly Settings _settings;
private readonly PluginJsonStorage<Settings> _storage;
public Main()
{
_storage = new PluginJsonStorage<Settings>();
_settings = _storage.Load();
}
public void Save()
{
_storage.Save();
}
public List<Result> Query(Query query)
{
@@ -64,7 +79,15 @@ namespace Wox.Plugin.Url
}
try
{
Process.Start(raw);
if (_settings.BrowserPath.Length == 0)
{
Process.Start(raw);
}
else
{
Process.Start(_settings.BrowserPath,raw);
}
return true;
}
catch(Exception ex)
@@ -79,6 +102,12 @@ namespace Wox.Plugin.Url
return new List<Result>(0);
}
public Control CreateSettingPanel()
{
return new SettingsControl(context.API,_settings);
}
public bool IsURL(string raw)
{
raw = raw.ToLower();