mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
[Run] Open in console functionality (#4739)
* Added open in console for indexer * Added open in console fpr indexer and folder plugin * Added open in console to program plugin * Added string localization for program plugin * Added test for win32 program * Added test for win32 programs * Added test for indexer plugin * Localization for context menu title * Added tests for folder plugin * Added tests for indexer plugin * Code cleanup * Improved logging and nit fixes * Updated tooltip for open in console * Updates tests * Removed subtitle property from contextmenuresult class * Improved logging for context menu loaders
This commit is contained in:
committed by
GitHub
parent
e3e6b23b7c
commit
638cd1dd48
@@ -14,6 +14,7 @@ using Wox.Plugin;
|
||||
using System.Windows.Input;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Microsoft.Plugin.Program.Programs
|
||||
{
|
||||
@@ -202,32 +203,11 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
|
||||
public List<ContextMenuResult> ContextMenus(IPublicAPI api)
|
||||
{
|
||||
// To add a context menu only to open file location as Internet shortcut applications do not have the functionality to run as admin
|
||||
if(AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
|
||||
var contextMenus = new List<ContextMenuResult>();
|
||||
|
||||
if (AppType != (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
|
||||
{
|
||||
var contextMenuItems = new List<ContextMenuResult>
|
||||
{
|
||||
new ContextMenuResult
|
||||
{
|
||||
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
|
||||
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
|
||||
Glyph = "\xE838",
|
||||
FontFamily = "Segoe MDL2 Assets",
|
||||
AcceleratorKey = Key.E,
|
||||
AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
|
||||
Action = _ =>
|
||||
{
|
||||
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", ParentDirectory));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
return contextMenuItems;
|
||||
}
|
||||
|
||||
var contextMenus = new List<ContextMenuResult>
|
||||
{
|
||||
new ContextMenuResult
|
||||
contextMenus.Add(new ContextMenuResult
|
||||
{
|
||||
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
|
||||
Title = api.GetTranslation("wox_plugin_program_run_as_administrator"),
|
||||
@@ -249,7 +229,10 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
contextMenus.Add(
|
||||
new ContextMenuResult
|
||||
{
|
||||
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
|
||||
@@ -263,8 +246,32 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", ParentDirectory));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
contextMenus.Add(
|
||||
new ContextMenuResult
|
||||
{
|
||||
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
|
||||
Title = api.GetTranslation("wox_plugin_program_open_in_console"),
|
||||
Glyph = "\xE756",
|
||||
FontFamily = "Segoe MDL2 Assets",
|
||||
AcceleratorKey = Key.C,
|
||||
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
|
||||
Action = (context) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Helper.OpenInConsole(ParentDirectory);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception($"|Microsoft.Plugin.Program.Win32.ContextMenu| Failed to open {Name} in console, {e.Message}", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return contextMenus;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user