mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
* Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
489 lines
12 KiB
C#
489 lines
12 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using Microsoft.PowerToys.Settings.Telemetry;
|
|
using Microsoft.PowerToys.Telemetry;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Library
|
|
{
|
|
public class EnabledModules
|
|
{
|
|
private Action notifyEnabledChangedAction;
|
|
|
|
public EnabledModules()
|
|
{
|
|
}
|
|
|
|
private bool fancyZones = true;
|
|
|
|
[JsonPropertyName("FancyZones")]
|
|
public bool FancyZones
|
|
{
|
|
get => fancyZones;
|
|
set
|
|
{
|
|
if (fancyZones != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
fancyZones = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool imageResizer = true;
|
|
|
|
[JsonPropertyName("Image Resizer")]
|
|
public bool ImageResizer
|
|
{
|
|
get => imageResizer;
|
|
set
|
|
{
|
|
if (imageResizer != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
imageResizer = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool fileExplorerPreview = true;
|
|
|
|
[JsonPropertyName("File Explorer Preview")]
|
|
public bool FileExplorerPreview
|
|
{
|
|
get => fileExplorerPreview;
|
|
set
|
|
{
|
|
if (fileExplorerPreview != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
fileExplorerPreview = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool shortcutGuide = true;
|
|
|
|
[JsonPropertyName("Shortcut Guide")]
|
|
public bool ShortcutGuide
|
|
{
|
|
get => shortcutGuide;
|
|
set
|
|
{
|
|
if (shortcutGuide != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
shortcutGuide = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool videoConference; // defaulting to off https://github.com/microsoft/PowerToys/issues/14507
|
|
|
|
[JsonPropertyName("Video Conference")]
|
|
public bool VideoConference
|
|
{
|
|
get => this.videoConference;
|
|
set
|
|
{
|
|
if (this.videoConference != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
this.videoConference = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool powerRename = true;
|
|
|
|
public bool PowerRename
|
|
{
|
|
get => powerRename;
|
|
set
|
|
{
|
|
if (powerRename != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
powerRename = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool keyboardManager = true;
|
|
|
|
[JsonPropertyName("Keyboard Manager")]
|
|
public bool KeyboardManager
|
|
{
|
|
get => keyboardManager;
|
|
set
|
|
{
|
|
if (keyboardManager != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
keyboardManager = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool powerLauncher = true;
|
|
|
|
[JsonPropertyName("PowerToys Run")]
|
|
public bool PowerLauncher
|
|
{
|
|
get => powerLauncher;
|
|
set
|
|
{
|
|
if (powerLauncher != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
powerLauncher = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool colorPicker = true;
|
|
|
|
[JsonPropertyName("ColorPicker")]
|
|
public bool ColorPicker
|
|
{
|
|
get => colorPicker;
|
|
set
|
|
{
|
|
if (colorPicker != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
colorPicker = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool cropAndLock = true;
|
|
|
|
[JsonPropertyName("CropAndLock")]
|
|
public bool CropAndLock
|
|
{
|
|
get => cropAndLock;
|
|
set
|
|
{
|
|
if (cropAndLock != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
cropAndLock = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool awake;
|
|
|
|
[JsonPropertyName("Awake")]
|
|
public bool Awake
|
|
{
|
|
get => awake;
|
|
set
|
|
{
|
|
if (awake != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
awake = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool mouseWithoutBorders = true;
|
|
|
|
[JsonPropertyName("MouseWithoutBorders")]
|
|
public bool MouseWithoutBorders
|
|
{
|
|
get => mouseWithoutBorders;
|
|
set
|
|
{
|
|
if (mouseWithoutBorders != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
mouseWithoutBorders = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool findMyMouse = true;
|
|
|
|
[JsonPropertyName("FindMyMouse")]
|
|
public bool FindMyMouse
|
|
{
|
|
get => findMyMouse;
|
|
set
|
|
{
|
|
if (findMyMouse != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
findMyMouse = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool mouseHighlighter = true;
|
|
|
|
[JsonPropertyName("MouseHighlighter")]
|
|
public bool MouseHighlighter
|
|
{
|
|
get => mouseHighlighter;
|
|
set
|
|
{
|
|
if (mouseHighlighter != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
mouseHighlighter = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool mouseJump = true;
|
|
|
|
[JsonPropertyName("MouseJump")]
|
|
public bool MouseJump
|
|
{
|
|
get => mouseJump;
|
|
set
|
|
{
|
|
if (mouseJump != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
mouseJump = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool alwaysOnTop = true;
|
|
|
|
[JsonPropertyName("AlwaysOnTop")]
|
|
public bool AlwaysOnTop
|
|
{
|
|
get => alwaysOnTop;
|
|
set
|
|
{
|
|
if (alwaysOnTop != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
alwaysOnTop = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool mousePointerCrosshairs = true;
|
|
|
|
[JsonPropertyName("MousePointerCrosshairs")]
|
|
public bool MousePointerCrosshairs
|
|
{
|
|
get => mousePointerCrosshairs;
|
|
set
|
|
{
|
|
if (mousePointerCrosshairs != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
mousePointerCrosshairs = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool powerAccent;
|
|
|
|
[JsonPropertyName("QuickAccent")]
|
|
public bool PowerAccent
|
|
{
|
|
get => powerAccent;
|
|
set
|
|
{
|
|
if (powerAccent != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
powerAccent = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool powerOCR = true;
|
|
|
|
[JsonPropertyName("TextExtractor")]
|
|
public bool PowerOCR
|
|
{
|
|
get => powerOCR;
|
|
set
|
|
{
|
|
if (powerOCR != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
powerOCR = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool pastePlain = true;
|
|
|
|
[JsonPropertyName("PastePlain")]
|
|
public bool PastePlain
|
|
{
|
|
get => pastePlain;
|
|
set
|
|
{
|
|
if (pastePlain != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
pastePlain = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool measureTool = true;
|
|
|
|
[JsonPropertyName("Measure Tool")]
|
|
public bool MeasureTool
|
|
{
|
|
get => measureTool;
|
|
set
|
|
{
|
|
if (measureTool != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
measureTool = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool hosts = true;
|
|
|
|
[JsonPropertyName("Hosts")]
|
|
public bool Hosts
|
|
{
|
|
get => hosts;
|
|
set
|
|
{
|
|
if (hosts != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
hosts = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool fileLocksmith = true;
|
|
|
|
[JsonPropertyName("File Locksmith")]
|
|
public bool FileLocksmith
|
|
{
|
|
get => fileLocksmith;
|
|
set
|
|
{
|
|
if (fileLocksmith != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
fileLocksmith = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool peek = true;
|
|
|
|
[JsonPropertyName("Peek")]
|
|
public bool Peek
|
|
{
|
|
get => peek;
|
|
set
|
|
{
|
|
if (peek != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
peek = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool registryPreview = true;
|
|
|
|
[JsonPropertyName("RegistryPreview")]
|
|
public bool RegistryPreview
|
|
{
|
|
get => registryPreview;
|
|
set
|
|
{
|
|
if (registryPreview != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
registryPreview = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool cmdNotFound = true;
|
|
|
|
[JsonPropertyName("CmdNotFound")]
|
|
public bool CmdNotFound
|
|
{
|
|
get => cmdNotFound;
|
|
set
|
|
{
|
|
if (cmdNotFound != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
cmdNotFound = value;
|
|
NotifyChange();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool environmentVariables = true;
|
|
|
|
[JsonPropertyName("EnvironmentVariables")]
|
|
public bool EnvironmentVariables
|
|
{
|
|
get => environmentVariables;
|
|
set
|
|
{
|
|
if (environmentVariables != value)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
environmentVariables = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void NotifyChange()
|
|
{
|
|
notifyEnabledChangedAction?.Invoke();
|
|
}
|
|
|
|
public string ToJsonString()
|
|
{
|
|
return JsonSerializer.Serialize(this);
|
|
}
|
|
|
|
private static void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null)
|
|
{
|
|
var dataEvent = new SettingsEnabledEvent()
|
|
{
|
|
Value = value,
|
|
Name = moduleName,
|
|
};
|
|
PowerToysTelemetry.Log.WriteEvent(dataEvent);
|
|
}
|
|
|
|
internal void AddEnabledModuleChangeNotification(Action callBack)
|
|
{
|
|
notifyEnabledChangedAction = callBack;
|
|
}
|
|
}
|
|
}
|