mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[PT Run] System plugin: Setting for separate "Empty Recycle Bin" result (#24057)
* Split results and setting * smalöl fixes * fixes
This commit is contained in:
@@ -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
|
||||
/// </summary>
|
||||
/// <param name="isUefi">Value indicating if the system is booted in uefi mode</param>
|
||||
/// <param name="splitRecycleBinResults">Value indicating if we should show two results for Recycle Bin.</param>
|
||||
/// <param name="confirmCommands">A value indicating if the user should confirm the system commands</param>
|
||||
/// <param name="emptyRBSuccessMessage">Show a success message after empty Recycle Bin.</param>
|
||||
/// <param name="iconTheme">The current theme to use for the icons</param>
|
||||
/// <param name="culture">The culture to use for the result's title and sub title</param>
|
||||
/// <param name="confirmCommands">A value indicating if the user should confirm the system commands</param>
|
||||
/// <returns>A list of all results</returns>
|
||||
internal static List<Result> GetSystemCommands(bool isUefi, string iconTheme, CultureInfo culture, bool confirmCommands)
|
||||
internal static List<Result> GetSystemCommands(bool isUefi, bool splitRecycleBinResults, bool confirmCommands, bool emptyRBSuccessMessage, string iconTheme, CultureInfo culture)
|
||||
{
|
||||
var results = new List<Result>();
|
||||
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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user