mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
Add web search feature & some UI changes.
This commit is contained in:
40
Wox.Plugin.System/WebSearchPlugin.cs
Normal file
40
Wox.Plugin.System/WebSearchPlugin.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.System
|
||||
{
|
||||
public class WebSearchPlugin : BaseSystemPlugin
|
||||
{
|
||||
protected override List<Result> QueryInternal(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
if (string.IsNullOrEmpty(query.ActionName)) return results;
|
||||
|
||||
WebSearch webSearch =
|
||||
CommonStorage.Instance.UserSetting.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName);
|
||||
|
||||
if (webSearch != null)
|
||||
{
|
||||
string keyword = query.ActionParameters.Count > 0 ? query.RawQuery.Substring(query.RawQuery.IndexOf(' ') + 1) : "";
|
||||
results.Add(new Result()
|
||||
{
|
||||
Title = string.Format("Search {0} for {1}", webSearch.Title, keyword),
|
||||
IcoPath = webSearch.IconPath,
|
||||
Action = () => Process.Start(webSearch.Url.Replace("{q}", keyword))
|
||||
});
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
protected override void InitInternal(PluginInitContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user