- Added functionality to launch Everything with a search query for extended results.

- Modified default sort order to match Everything defaults
This commit is contained in:
Lin Yu-Chieh (Victor) 2024-07-05 00:48:19 +08:00
parent 80d1d9d736
commit 07871a380d
7 changed files with 123 additions and 2 deletions

View File

@ -12,6 +12,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
{
internal sealed class Everything
{
private string exe = string.Empty;
internal Everything(Settings setting)
{
Everything_SetRequestFlags(Request.FILE_NAME | Request.PATH);
@ -24,6 +25,16 @@ namespace Community.PowerToys.Run.Plugin.Everything
Everything_SetMax(setting.Max);
Everything_SetMatchPath(setting.MatchPath);
Everything_SetRegex(setting.RegEx);
if (!string.IsNullOrEmpty(setting.EverythingPath))
{
if (setting.EverythingPath != exe && Path.Exists(setting.EverythingPath))
exe = setting.EverythingPath;
}
else if (string.IsNullOrEmpty(exe))
{
exe = Path.Exists("C:\\Program Files\\Everything 1.5a\\Everything64.exe") ? "C:\\Program Files\\Everything 1.5a\\Everything64.exe" :
(Path.Exists("C:\\Program Files\\Everything\\Everything64.exe") ? "C:\\Program Files\\Everything\\Everything64.exe" : string.Empty);
}
}
internal IEnumerable<Result> Query(string query, Settings setting)
@ -76,6 +87,36 @@ namespace Community.PowerToys.Run.Plugin.Everything
if (setting.Log > LogLevel.None)
Debugger.Write($"Results: {resultCount}");
bool showMore = !string.IsNullOrEmpty(exe) && resultCount == setting.Max;
if (showMore)
{
var more = new Result()
{
Title = Resources.more_results,
SubTitle = Resources.more_results_Subtitle,
IcoPath = "Images/Everything.light.png",
Action = e =>
{
using var process = new Process();
process.StartInfo.FileName = exe;
process.StartInfo.UseShellExecute = true;
process.StartInfo.Arguments = $@"-s {query}";
try
{
process.Start();
return true;
}
catch (Win32Exception)
{
return false;
}
},
Score = int.MinValue,
QueryTextDisplay = orgqry,
};
yield return more;
}
for (uint i = 0; i < resultCount; i++)
{
if (setting.Log > LogLevel.None)

View File

@ -58,6 +58,14 @@ namespace Community.PowerToys.Run.Plugin.Everything
TextValue = _setting.Prefix,
},
new()
{
Key = nameof(Settings.EverythingPath),
DisplayLabel = Resources.EverythingPath,
DisplayDescription = Resources.EverythingPath_Description,
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Textbox,
TextValue = _setting.EverythingPath,
},
new()
{
Key = nameof(Settings.Copy),
DisplayLabel = Resources.SwapCopy,
@ -144,6 +152,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
_setting.Updates = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Updates)).Value;
_setting.Log = (LogLevel)settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Log)).ComboBoxValue;
_setting.Prefix = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Prefix)).TextValue;
_setting.EverythingPath = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.EverythingPath)).TextValue;
_everything?.UpdateSettings(_setting);
_contextMenuLoader?.Update(_setting);

View File

@ -160,6 +160,24 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Everything64.exe.
/// </summary>
public static string EverythingPath {
get {
return ResourceManager.GetString("EverythingPath", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Location of Everything64.exe if it&apos;s not installed in &quot;Program Files&quot;.
/// </summary>
public static string EverythingPath_Description {
get {
return ResourceManager.GetString("EverythingPath_Description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Fail to open folder at.
/// </summary>
@ -205,6 +223,24 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to See more....
/// </summary>
public static string more_results {
get {
return ResourceManager.GetString("more_results", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open Everything and see the remaining results.
/// </summary>
public static string more_results_Subtitle {
get {
return ResourceManager.GetString("more_results_Subtitle", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open containing folder (Ctrl+Shift+E).
/// </summary>

View File

@ -145,6 +145,12 @@
<data name="EnvVar_Description" xml:space="preserve">
<value>Expand enviroment variables, such as %appdata%, so that they work properly at the cost of query time.</value>
</data>
<data name="EverythingPath" xml:space="preserve">
<value>Everything64.exe</value>
</data>
<data name="EverythingPath_Description" xml:space="preserve">
<value>Location of Everything64.exe if it's not installed in "Program Files"</value>
</data>
<data name="Everything_ini" xml:space="preserve">
<value>Install Everything if not installed</value>
</data>
@ -166,6 +172,12 @@
<data name="Max_Description" xml:space="preserve">
<value>The maximum amount of results to display in the results.</value>
</data>
<data name="more_results" xml:space="preserve">
<value>See more...</value>
</data>
<data name="more_results_Subtitle" xml:space="preserve">
<value>Open Everything and see the remaining results</value>
</data>
<data name="open_containing_folder" xml:space="preserve">
<value>Open containing folder (Ctrl+Shift+E)</value>
</data>

View File

@ -133,6 +133,9 @@
<data name="EnvVar_Description" xml:space="preserve">
<value>搜索时可以使用环境变量,但会增加搜索时间</value>
</data>
<data name="EverythingPath_Description" xml:space="preserve">
<value>若Everything安装位置非预设的Program Files请提供Everything64exe的位置</value>
</data>
<data name="Everything_ini" xml:space="preserve">
<value>是否安装了 Everything?</value>
</data>
@ -148,6 +151,12 @@
<data name="Max_Description" xml:space="preserve">
<value>结果中显示的最大结果数</value>
</data>
<data name="more_results" xml:space="preserve">
<value>显示更多结果...</value>
</data>
<data name="more_results_Subtitle" xml:space="preserve">
<value>在Everything主视窗里查看更多结果</value>
</data>
<data name="open_containing_folder" xml:space="preserve">
<value>打开所在文件夹 (Ctrl+Shift+E)</value>
</data>
@ -160,6 +169,10 @@
<data name="plugin_name" xml:space="preserve">
<value>Everything</value>
</data>
<data name="Prefix_Description" xml:space="preserve">
<value>为搜索词添加固定的前缀,搜索时无需再手动输入修饰词/筛选词
前缀与搜索词之间不会自动加入空格</value>
</data>
<data name="Preview_Description" xml:space="preserve">
<value>以图标形式预览文件内容,如果文件不是本地文件,可能会导致冻结</value>
</data>

View File

@ -133,6 +133,9 @@
<data name="EnvVar_Description" xml:space="preserve">
<value>搜尋時可用環境變數,但會增加搜尋時間</value>
</data>
<data name="EverythingPath_Description" xml:space="preserve">
<value>若Everything安裝位置非預設的Program Files請提供Everything64.exe的位置</value>
</data>
<data name="Everything_ini" xml:space="preserve">
<value>是否有安裝 Everything?</value>
</data>
@ -148,6 +151,12 @@
<data name="Max_Description" xml:space="preserve">
<value>結果中顯示的結果數上限</value>
</data>
<data name="more_results" xml:space="preserve">
<value>顯示更多結果...</value>
</data>
<data name="more_results_Subtitle" xml:space="preserve">
<value>在Everything主視窗裡查看更多結果</value>
</data>
<data name="open_containing_folder" xml:space="preserve">
<value>開啟檔案位置 (Ctrl+Shift+E)</value>
</data>

View File

@ -9,8 +9,8 @@ namespace Community.PowerToys.Run.Plugin.Everything
public class Settings
{
// Settings from PTR settings
public Sort Sort { get; set; } = Sort.DATE_MODIFIED_DESCENDING;
public uint Max { get; set; } = 20;
public Sort Sort { get; set; } = Sort.NAME_ASCENDING;
public uint Max { get; set; } = 10;
public string Context { get; set; } = "012345";
public bool Copy { get; set; }
public bool MatchPath { get; set; }
@ -22,6 +22,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
public string Skip { get; set; }
public LogLevel Log { get; set; } = LogLevel.None;
public string Prefix { get; set; }
public string EverythingPath { get; set; }
// Get Filters from settings.toml
public Dictionary<string, string> Filters { get; } = [];