mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
Add right click option on query to disable program
This commit is contained in:
BIN
Plugins/Wox.Plugin.Program/Images/disable.png
Normal file
BIN
Plugins/Wox.Plugin.Program/Images/disable.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -31,10 +31,15 @@
|
|||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_run_as_administrator">Run As Administrator</system:String>
|
<system:String x:Key="wox_plugin_program_run_as_administrator">Run As Administrator</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_open_containing_folder">Open containing folder</system:String>
|
<system:String x:Key="wox_plugin_program_open_containing_folder">Open containing folder</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_program_disable_program">Disable this program from displaying</system:String>
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_plugin_name">Program</system:String>
|
<system:String x:Key="wox_plugin_program_plugin_name">Program</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_plugin_description">Search programs in Wox</system:String>
|
<system:String x:Key="wox_plugin_program_plugin_description">Search programs in Wox</system:String>
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_invalid_path">Invalid Path</system:String>
|
<system:String x:Key="wox_plugin_program_invalid_path">Invalid Path</system:String>
|
||||||
|
|
||||||
|
<!--Dialogs-->
|
||||||
|
<system:String x:Key="wox_plugin_program_disable_dlgtitle_success">Success</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_program_disable_dlgtitle_success_message">Successfully disabled this program from displaying in your query</system:String>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -102,8 +102,6 @@ namespace Wox.Plugin.Program
|
|||||||
lock (IndexLock)
|
lock (IndexLock)
|
||||||
{
|
{
|
||||||
_uwps = support ? UWP.All() : new UWP.Application[] { };
|
_uwps = support ? UWP.All() : new UWP.Application[] { };
|
||||||
|
|
||||||
//_uwps = UWP.RetainApplications(allUWPs, _settings.ProgramSources, _settings.EnableProgramSourceOnly);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,16 +131,49 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
public List<Result> LoadContextMenus(Result selectedResult)
|
public List<Result> LoadContextMenus(Result selectedResult)
|
||||||
{
|
{
|
||||||
|
var menuOptions = new List<Result>();
|
||||||
var program = selectedResult.ContextData as IProgram;
|
var program = selectedResult.ContextData as IProgram;
|
||||||
if (program != null)
|
if (program != null)
|
||||||
{
|
{
|
||||||
var menus = program.ContextMenus(_context.API);
|
menuOptions = program.ContextMenus(_context.API);
|
||||||
return menus;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new List<Result>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menuOptions.Add(
|
||||||
|
new Result
|
||||||
|
{
|
||||||
|
Title = _context.API.GetTranslation("wox_plugin_program_disable_program"),
|
||||||
|
Action = c =>
|
||||||
|
{
|
||||||
|
DisableProgram(program);
|
||||||
|
_context.API.ShowMsg(_context.API.GetTranslation("wox_plugin_program_disable_dlgtitle_success"),
|
||||||
|
_context.API.GetTranslation("wox_plugin_program_disable_dlgtitle_success_message"));
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
IcoPath = "Images/disable.png"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return menuOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisableProgram(IProgram ProgramToDelete)
|
||||||
|
{
|
||||||
|
if(_uwps.Any(x => x.UniqueIdentifier == ProgramToDelete.UniqueIdentifier))
|
||||||
|
_uwps.Where(x => x.UniqueIdentifier == ProgramToDelete.UniqueIdentifier).FirstOrDefault().Enabled = false;
|
||||||
|
|
||||||
|
if (_win32s.Any(x => x.UniqueIdentifier == ProgramToDelete.UniqueIdentifier))
|
||||||
|
_win32s.Where(x => x.UniqueIdentifier == ProgramToDelete.UniqueIdentifier).FirstOrDefault().Enabled = false;
|
||||||
|
|
||||||
|
_settings.DisabledProgramSources
|
||||||
|
.Add(
|
||||||
|
new Settings.DisabledProgramSource
|
||||||
|
{
|
||||||
|
Name = ProgramToDelete.Name,
|
||||||
|
Location = ProgramToDelete.Location,
|
||||||
|
UniqueIdentifier = ProgramToDelete.UniqueIdentifier,
|
||||||
|
Enabled = false
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool StartProcess(ProcessStartInfo info)
|
public static bool StartProcess(ProcessStartInfo info)
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Wox.Plugin.Program.Programs
|
namespace Wox.Plugin.Program.Programs
|
||||||
{
|
{
|
||||||
@@ -10,5 +6,8 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
{
|
{
|
||||||
List<Result> ContextMenus(IPublicAPI api);
|
List<Result> ContextMenus(IPublicAPI api);
|
||||||
Result Result(string query, IPublicAPI api);
|
Result Result(string query, IPublicAPI api);
|
||||||
|
string UniqueIdentifier { get; set; }
|
||||||
|
string Name { get; }
|
||||||
|
string Location { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,6 +241,9 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
public string UserModelId { get; set; }
|
public string UserModelId { get; set; }
|
||||||
public string BackgroundColor { get; set; }
|
public string BackgroundColor { get; set; }
|
||||||
|
|
||||||
|
public string Name => DisplayName;
|
||||||
|
public string Location => Package.Location;
|
||||||
|
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
public string LogoUri { get; set; }
|
public string LogoUri { get; set; }
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public bool Valid { get; set; }
|
public bool Valid { get; set; }
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
public string Location => ParentDirectory;
|
||||||
|
|
||||||
private const string ShortcutExtension = "lnk";
|
private const string ShortcutExtension = "lnk";
|
||||||
private const string ApplicationReferenceExtension = "appref-ms";
|
private const string ApplicationReferenceExtension = "appref-ms";
|
||||||
|
|||||||
@@ -105,6 +105,9 @@
|
|||||||
<None Include="Images\folder.png">
|
<None Include="Images\folder.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="Images\disable.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<Content Include="Languages\en.xaml">
|
<Content Include="Languages\en.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|||||||
Reference in New Issue
Block a user