[PTRun][System] Recycle Bin command: Allow opening RB + Improvements (#23045)

This commit is contained in:
Heiko
2023-01-10 15:09:23 +01:00
committed by GitHub
parent 25e9241d42
commit 196db19be8
12 changed files with 253 additions and 51 deletions

View File

@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows.Controls;
using ControlzEx.Standard;
using ManagedCommon;
using Microsoft.PowerToys.Run.Plugin.System.Components;
using Microsoft.PowerToys.Run.Plugin.System.Properties;
@@ -22,6 +23,7 @@ namespace Microsoft.PowerToys.Run.Plugin.System
private PluginInitContext _context;
private bool _confirmSystemCommands;
private bool _showSuccessOnEmptyRB;
private bool _localizeSystemCommands;
private bool _reduceNetworkResultScore;
@@ -42,6 +44,12 @@ namespace Microsoft.PowerToys.Run.Plugin.System
Value = false,
},
new PluginAdditionalOption()
{
Key = "ShowSuccessOnEmptyRB",
DisplayLabel = Resources.Microsoft_plugin_sys_RecycleBin_ShowEmptySuccessMessage,
Value = false,
},
new PluginAdditionalOption()
{
Key = "LocalizeSystemCommands",
DisplayLabel = Resources.Use_localized_system_commands,
@@ -92,6 +100,15 @@ namespace Microsoft.PowerToys.Run.Plugin.System
c.TitleHighlightData = resultMatch.MatchData;
results.Add(c);
}
else if (c?.ContextData is SystemPluginContext contextData)
{
var searchTagMatch = StringMatcher.FuzzySearch(query.Search, contextData.SearchTag);
if (searchTagMatch.Score > 0)
{
c.Score = resultMatch.Score;
results.Add(c);
}
}
}
// The following information result is not returned because delayed queries doesn't clear output if no results are available.
@@ -134,6 +151,15 @@ namespace Microsoft.PowerToys.Run.Plugin.System
r.SubTitleHighlightData = resultMatch.MatchData;
results.Add(r);
}
else if (r?.ContextData is SystemPluginContext contextData)
{
var searchTagMatch = StringMatcher.FuzzySearch(query.Search, contextData.SearchTag);
if (searchTagMatch.Score > 0)
{
r.Score = resultMatch.Score;
results.Add(r);
}
}
}
}
@@ -142,7 +168,7 @@ namespace Microsoft.PowerToys.Run.Plugin.System
public List<ContextMenuResult> LoadContextMenus(Result selectedResult)
{
return ResultHelper.GetContextMenuForResult(selectedResult);
return ResultHelper.GetContextMenuForResult(selectedResult, _showSuccessOnEmptyRB);
}
private void UpdateIconTheme(Theme theme)
@@ -180,6 +206,7 @@ namespace Microsoft.PowerToys.Run.Plugin.System
public void UpdateSettings(PowerLauncherPluginSettings settings)
{
var confirmSystemCommands = false;
var showSuccessOnEmptyRB = false;
var localizeSystemCommands = true;
var reduceNetworkResultScore = true;
@@ -188,6 +215,9 @@ namespace Microsoft.PowerToys.Run.Plugin.System
var optionConfirm = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "ConfirmSystemCommands");
confirmSystemCommands = optionConfirm?.Value ?? confirmSystemCommands;
var optionEmptyRBSuccessMsg = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "ShowSuccessOnEmptyRB");
showSuccessOnEmptyRB = optionEmptyRBSuccessMsg?.Value ?? showSuccessOnEmptyRB;
var optionLocalize = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "LocalizeSystemCommands");
localizeSystemCommands = optionLocalize?.Value ?? localizeSystemCommands;
@@ -196,6 +226,7 @@ namespace Microsoft.PowerToys.Run.Plugin.System
}
_confirmSystemCommands = confirmSystemCommands;
_showSuccessOnEmptyRB = showSuccessOnEmptyRB;
_localizeSystemCommands = localizeSystemCommands;
_reduceNetworkResultScore = reduceNetworkResultScore;
}