[PowerToys Run] Plugin manager (#9872)

This commit is contained in:
Mykhailo Pylyp
2021-02-26 13:21:58 +02:00
committed by GitHub
parent f839a408de
commit 4a9e920a1c
66 changed files with 749 additions and 276 deletions

View File

@@ -11,5 +11,11 @@ namespace Wox.Plugin
List<Result> Query(Query query);
void Init(PluginInitContext context);
// Localized name
string Name { get; }
// Localized description
string Description { get; }
}
}

View File

@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Windows.Controls;
using Microsoft.PowerToys.Settings.UI.Library;
@@ -11,6 +12,8 @@ namespace Wox.Plugin
{
Control CreateSettingPanel();
void UpdateSettings(PowerLauncherSettings settings);
void UpdateSettings(PowerLauncherPluginSettings settings);
IEnumerable<PluginAdditionalOption> AdditionalOptions { get; }
}
}

View File

@@ -32,8 +32,6 @@ namespace Wox.Plugin
public string Language { get; set; }
public string Description { get; set; }
public string Website { get; set; }
public bool Disabled { get; set; }

View File

@@ -19,19 +19,32 @@ namespace Wox.Plugin
/// Initializes a new instance of the <see cref="Query"/> class.
/// to allow unit tests for plug ins
/// </summary>
public Query(string rawQuery, string search, ReadOnlyCollection<string> terms, string actionKeyword = "")
public Query(string query, string actionKeyword = "")
{
Search = search;
RawQuery = rawQuery;
Terms = terms;
_query = query;
ActionKeyword = actionKeyword;
}
private string _rawQuery;
/// <summary>
/// Gets raw query, this includes action keyword if it has
/// We didn't recommend use this property directly. You should always use Search property.
/// </summary>
public string RawQuery { get; internal set; }
public string RawQuery
{
get
{
if (_rawQuery == null)
{
_rawQuery = string.Join(Query.TermSeparator, _query.Split(new[] { TermSeparator }, StringSplitOptions.RemoveEmptyEntries));
}
return _rawQuery;
}
}
private string _search;
/// <summary>
/// Gets search part of a query.
@@ -39,12 +52,41 @@ namespace Wox.Plugin
/// Since we allow user to switch a exclusive plugin to generic plugin,
/// so this property will always give you the "real" query part of the query
/// </summary>
public string Search { get; internal set; }
public string Search
{
get
{
if (_search == null)
{
_search = RawQuery.Substring(ActionKeyword.Length).Trim();
}
return _search;
}
}
private ReadOnlyCollection<string> _terms;
/// <summary>
/// Gets the raw query splited into a string array.
/// </summary>
public ReadOnlyCollection<string> Terms { get; private set; }
public ReadOnlyCollection<string> Terms
{
get
{
if (_terms == null)
{
var terms = _query
.Trim()
.Substring(ActionKeyword.Length)
.Split(new[] { TermSeparator }, StringSplitOptions.RemoveEmptyEntries);
_terms = new ReadOnlyCollection<string>(terms);
}
return _terms;
}
}
/// <summary>
/// Query can be splited into multiple terms by whitespace
@@ -102,6 +144,8 @@ namespace Wox.Plugin
}
}
private string _query;
public override string ToString() => RawQuery;
[Obsolete("Use Search instead, this method will be removed in v1.3.0")]