diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/Commands.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/Commands.cs index 7e337c2bf5..9278e4941a 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/Commands.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/Commands.cs @@ -5,14 +5,10 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Runtime; -using System.Windows; -using System.Windows.Interop; using Microsoft.PowerToys.Run.Plugin.System.Properties; using Wox.Infrastructure; using Wox.Plugin; using Wox.Plugin.Common.Win32; -using Wox.Plugin.Logger; namespace Microsoft.PowerToys.Run.Plugin.System.Components { @@ -37,11 +33,13 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Components /// Returns a list with all system command results /// /// Value indicating if the system is booted in uefi mode + /// Value indicating if we should show two results for Recycle Bin. + /// A value indicating if the user should confirm the system commands + /// Show a success message after empty Recycle Bin. /// The current theme to use for the icons /// The culture to use for the result's title and sub title - /// A value indicating if the user should confirm the system commands /// A list of all results - internal static List GetSystemCommands(bool isUefi, string iconTheme, CultureInfo culture, bool confirmCommands) + internal static List GetSystemCommands(bool isUefi, bool splitRecycleBinResults, bool confirmCommands, bool emptyRBSuccessMessage, string iconTheme, CultureInfo culture) { var results = new List(); results.AddRange(new[] @@ -106,7 +104,39 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Components return ResultHelper.ExecuteCommand(confirmCommands, Resources.Microsoft_plugin_sys_hibernate_confirmation, () => NativeMethods.SetSuspendState(true, true, true)); }, }, - new Result + }); + + // Show Recycle Bin results based on setting. + if (splitRecycleBinResults) + { + results.AddRange(new[] + { + new Result + { + Title = Resources.ResourceManager.GetString("Microsoft_plugin_sys_RecycleBinOpen", culture), + SubTitle = Resources.ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_description", culture), + IcoPath = $"Images\\recyclebin.{iconTheme}.png", + Action = c => + { + return Helper.OpenInShell("explorer.exe", "shell:RecycleBinFolder"); + }, + }, + new Result + { + Title = Resources.ResourceManager.GetString("Microsoft_plugin_sys_RecycleBinEmptyResult", culture), + SubTitle = Resources.ResourceManager.GetString("Microsoft_plugin_sys_RecycleBinEmpty_description", culture), + IcoPath = $"Images\\recyclebin.{iconTheme}.png", + Action = c => + { + ResultHelper.EmptyRecycleBinAsync(emptyRBSuccessMessage); + return true; + }, + }, + }); + } + else + { + results.Add(new Result { Title = Resources.ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin", culture), SubTitle = Resources.ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_description", culture), @@ -116,8 +146,8 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Components { return Helper.OpenInShell("explorer.exe", "shell:RecycleBinFolder"); }, - }, - }); + }); + } // UEFI command/result. It is only available on systems booted in UEFI mode. if (isUefi) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/ResultHelper.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/ResultHelper.cs index b769e61796..047cc94c3c 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/ResultHelper.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/ResultHelper.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; -using System.Windows.Navigation; using Microsoft.PowerToys.Run.Plugin.System.Properties; using Wox.Plugin; using Wox.Plugin.Common.Win32; diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Main.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Main.cs index e6efc47c0a..0fdfe8e0d0 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Main.cs @@ -26,6 +26,7 @@ namespace Microsoft.PowerToys.Run.Plugin.System private bool _showSuccessOnEmptyRB; private bool _localizeSystemCommands; private bool _reduceNetworkResultScore; + private bool _separateEmptyRB; public string Name => Resources.Microsoft_plugin_sys_plugin_name; @@ -56,6 +57,12 @@ namespace Microsoft.PowerToys.Run.Plugin.System Value = true, }, new PluginAdditionalOption() + { + Key = "SeparateResultEmptyRB", + DisplayLabel = Resources.Microsoft_plugin_sys_RecycleBin_ShowEmptySeparate, + Value = false, + }, + new PluginAdditionalOption() { Key = "ReduceNetworkResultScore", DisplayLabel = Resources.Reduce_Network_Result_Score, @@ -90,7 +97,7 @@ namespace Microsoft.PowerToys.Run.Plugin.System } // normal system commands are fast and can be returned immediately - var systemCommands = Commands.GetSystemCommands(IsBootedInUefiMode, IconTheme, culture, _confirmSystemCommands); + var systemCommands = Commands.GetSystemCommands(IsBootedInUefiMode, _separateEmptyRB, _confirmSystemCommands, _showSuccessOnEmptyRB, IconTheme, culture); foreach (var c in systemCommands) { var resultMatch = StringMatcher.FuzzySearch(query.Search, c.Title); @@ -209,6 +216,7 @@ namespace Microsoft.PowerToys.Run.Plugin.System var showSuccessOnEmptyRB = false; var localizeSystemCommands = true; var reduceNetworkResultScore = true; + var separateEmptyRB = false; if (settings != null && settings.AdditionalOptions != null) { @@ -223,12 +231,16 @@ namespace Microsoft.PowerToys.Run.Plugin.System var optionNetworkScore = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "ReduceNetworkResultScore"); reduceNetworkResultScore = optionNetworkScore?.Value ?? reduceNetworkResultScore; + + var optionSeparateEmptyRB = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "SeparateResultEmptyRB"); + separateEmptyRB = optionSeparateEmptyRB?.Value ?? separateEmptyRB; } _confirmSystemCommands = confirmSystemCommands; _showSuccessOnEmptyRB = showSuccessOnEmptyRB; _localizeSystemCommands = localizeSystemCommands; _reduceNetworkResultScore = reduceNetworkResultScore; + _separateEmptyRB = separateEmptyRB; } } } diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Properties/Resources.Designer.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Properties/Resources.Designer.cs index fe14b50773..21edf832d4 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Properties/Resources.Designer.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Properties/Resources.Designer.cs @@ -457,7 +457,16 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Properties { } /// - /// Looks up a localized string similar to Show a success message after empty the Recycle Bin. + /// Looks up a localized string similar to Show separate result for Empty Recycle Bin command. + /// + internal static string Microsoft_plugin_sys_RecycleBin_ShowEmptySeparate { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_ShowEmptySeparate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show a success message after emptying the Recycle Bin. /// internal static string Microsoft_plugin_sys_RecycleBin_ShowEmptySuccessMessage { get { @@ -465,6 +474,33 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Properties { } } + /// + /// Looks up a localized string similar to Empty Recycle Bin. + /// + internal static string Microsoft_plugin_sys_RecycleBinEmpty_description { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBinEmpty_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Empty Recycle Bin. + /// + internal static string Microsoft_plugin_sys_RecycleBinEmptyResult { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBinEmptyResult", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open Recycle Bin. + /// + internal static string Microsoft_plugin_sys_RecycleBinOpen { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBinOpen", resourceCulture); + } + } + /// /// Looks up a localized string similar to Restart. /// diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Properties/Resources.resx b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Properties/Resources.resx index 5d6c53aae8..c762257889 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Properties/Resources.resx +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Properties/Resources.resx @@ -244,6 +244,18 @@ Recycle Bin Means the recycle bin folder in Explorer. + + Empty Recycle Bin + This should align to the action in Windows of emptying the recycle bin on your computer. + + + Empty Recycle Bin + This should align to the action in Windows of emptying the recycle bin on your computer. + + + Open Recycle Bin + Means the recycle bin folder in Explorer. + Empty Recycle Bin (Shift+Delete) This should align to the action in Windows of emptying the recycle bin on your computer. @@ -271,6 +283,9 @@ Empty Recycle Bin This should align to the action in Windows of emptying the recycle bin on your computer. + + Show separate result for Empty Recycle Bin command + Show a success message after emptying the Recycle Bin Means the recycle bin folder in Explorer and "emptying" refers to "Empty Recycle Bin" command.