Files
PowerToys/src/settings-ui/Settings.UI.Library/EnabledModules.cs
Seraphima Zykova 579619952d [New Module] Workspaces (#34324)
* spell checker

* Adding OOBE Projects page

* changed the default hotkey

* module interface

* rename projects editor

* bug report tool

* installer

* gpo

* exit event constant

* extend search for projects by search over the containing apps' names

* [Projects] fix grammatical issue #43 (1 app - many apps)

* [Projects] Editor: Main page: fix layout if there are many apps, launch button not disappearing on the right side

* dsc

* github

* pipeline

* guid prefix

* [Projects] fixing general settings gpo handling in runner + minor changes

* arm build fix

* Do not allow saving project if name or applist is empty. Also minor UI changes

* version

* editor version

* spellcheck

* editor dll signing

* update projects names to filter them out

* shortcut saving fix

* [Projects] Editor: brining the highlighted app's icon into the foreground. + minor UI fixes

* spell checker

* spellcheck

* [Projects] re-implementing icon size calculation to have similar sized icons for every app.

* [projects] Adding info message for cases: there are no projects or no results for the search

* [Projects] Adding Edit button to the popup. + minor changes

* [Projects] Making popup having rounded corners

* changed "no projects" text color and position

* remove opening the first proj

* fix placing windows of the same app in the project

* [Projects] bringing back the breadcrumb on the editor page. Make it clickable.

* [Projects] optimizing click handlers

* [Projects] Removing not selected apps on save

* moved on thread executor to common

* moved display utils

* added convert rect

* unsigned monitor number

* set awareness

* app placement

* [Projects] Re-implementing preview drawing - one common image

* [Projects] fix boundary calculation, use DPI aware values

* fix launching with command line args

* Fix ARM64 CI build

* launch packaged apps using names when possible

* spell-check

* update packaged apps path

* projects editor single instance

* [Projects] Add Select all checkbox, Delete selected button

* Add Checkbox for per monitor selection

* modifying highlight in preview

* spell checker

* logs

* exclude help windows

https://github.com/JaneaSystems/PowerToys-DevProjects/issues/49

* Add intermediate step to project creation

* minor bugfix

* mutex fix

* modifying highlight for minimized apps

* Fixing bug: re-draw the preview on app deletion in the editor

* Adding helper class for getting the right bounds for screens

* spell checker

* spell checker

* Minor fixes in the capture dialog

* get dpi unaware screen bounds

* refactoring: added utils

* changed window filter

https://github.com/JaneaSystems/PowerToys-DevProjects/issues/2

* clean up

* refactoring

* projects common lib

* localizable default project prefix

* launcher resources

* clean up

* change snapshot project saving

https://github.com/JaneaSystems/PowerToys-DevProjects/issues/14

* changed project data

https://github.com/JaneaSystems/PowerToys-DevProjects/issues/14

* changed project creation save-cancel handles

https://github.com/JaneaSystems/PowerToys-DevProjects/issues/14

* spell-check

* Remove checkboxes, delete feature

* remove unused from the project

* get command line args in the snapshot

* minimized settings snap fix

* set window property after launching

* FZ: ignore projects launched windows

* Implementing major new features: remove button, position manipulation, arguments, admin, minimized, maximized

* modifying colors

* launcher project filters

* clean up

* Hide Admin checkbox

* hide WIP

* spell-check

* Revert "Hide Admin checkbox"

This reverts commit 3036df9d7f.

* get app elevated property

* Implementing Launch and Edit feature

* fixing: update of listed projects on the main page after hitting save in editor

* Fix for packaged app's icons

* fixing scroll speed issue

* change scroll speed to 15

* launch elevated apps

* minor fixes

* minor fix

* enhancing shortcut handling

* can-launch-elevated check

* projects module interface telemetry

* Implementing store of setting "order by".

* minor string correction

* moved projects data parsing

* telemetry

* add move apps checkbox

* notification about elevated apps

* restart unelevated

* move existing windows

* keep opened windows at the same positions

* handle powertoys settings

* use common theme

* fix corrupted data: project id and monitor id

* project launch on "launch and edit"

* clean up

* show screen numbers instead of monitor names

* launcher error messages

* fix default shortcut

* Adding launch button to projects settings, dashboard and flyout

* Adding new app which is launched when launching a project. It shows the status of the launch process

* spell checker

* Renaming Projects to App Layouts. Replacing only string values, not the variable names

* Re-ordering modules after Renaming Projects + spell checker

* setting window size according to the screen (making it bigger)

* commenting out feature "move apps if exist"

* spell checker

* Add ProjectsLauncherUI to signing

* opening apps in minimized state which are placed on a monitor, which is not found at the moment of launching

* consistent file name

* removed unused sln

* telemetry: create event

* WindowPosition comparison

* telemetry: edit event

* fix muted Launch as admin checkbox

* telemetry: delete event

* updated Edit telemetry event

* added invoke point to launcher args

* added utils

* parse invoke point

* replaced tuple with struct

* telemetry: launch event

* MonitorRect comparison

* resources

* rename: folders

* remove outdated

* rename: window property

* rename: files and folders

* rename: common data structures

* rename: telemetry namespace

* rename: workspaces data

* rename ProjectsLib -> WorkspacesLib

* rename: gpo

* rename: settings

* rename: launcher UI

* rename: other

* rename: pt run

* rename: fz

* rename: module interface

* rename: icon

* rename: snapshot tool

* rename: editor

* rename: common files

* rename: launcher

* rename: editor resources

* fix empty file crash

* rename: json

* rename: module interface

* fix custom actions build

* added launch editor event constant

* xaml formatting

* Add missing method defition to interop::Constants idl
Remove Any CPU config

* more .sln cleanup

* [Run][PowerToys] Fix Workspaces utility (#34336)

polished workspaces utility

* build fix - align CppWinRT version

* address PR comment: fix isdigit

* indentation

* address PR comment: rename function

* address PR comment: changed version for workspaces and revision

* added supported version definition

* addressPR comment: use BringToForeground

* address PR comments: updated projects

* address PR comment: uncomment gpo in settings

* address PR comment: rename oobe view

* update OOBE image with current module name

* moved AppUtils

* launching with AppUserModel.ID

* fixed module order in settings

* fix xaml formatting

* [Workspaces] Close launcher if there are failed launches. Plus adding new spinner gif

* fix topmost LauncherUI

* clean up

* UI closing

* BugReportTool - omit cmd arg data

* Delete icon on workspace removal

* Adding cancellation to launcher UI.

* reordered launching

* fix terminating UI

* Removing old shortcut on workspace renaming

* Sentence case labels

* get process path without waiting

* comment out unused

* remove unused argument

* logs

* New icon

* fix launch and edit for the new project

* fix launch and edit: save new project

* Update exe icons

---------

Co-authored-by: donlaci <laszlo@janeasystems.com>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it>
Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-08-23 09:28:13 +02:00

508 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;
// Default values for enabled modules should match their expected "enabled by default" values.
// Otherwise, a run of DSC on clean settings will not match the expected default result.
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 PowerPreview
{
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; // defaulting to off
[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 = true;
[JsonPropertyName("Awake")]
public bool Awake
{
get => awake;
set
{
if (awake != value)
{
LogTelemetryEvent(value);
awake = value;
}
}
}
private bool mouseWithoutBorders; // defaulting to off
[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; // defaulting to off
[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; // defaulting to off
[JsonPropertyName("MousePointerCrosshairs")]
public bool MousePointerCrosshairs
{
get => mousePointerCrosshairs;
set
{
if (mousePointerCrosshairs != value)
{
LogTelemetryEvent(value);
mousePointerCrosshairs = value;
}
}
}
private bool powerAccent; // defaulting to off
[JsonPropertyName("QuickAccent")]
public bool PowerAccent
{
get => powerAccent;
set
{
if (powerAccent != value)
{
LogTelemetryEvent(value);
powerAccent = value;
}
}
}
private bool powerOCR; // defaulting to off
[JsonPropertyName("TextExtractor")]
public bool PowerOcr
{
get => powerOCR;
set
{
if (powerOCR != value)
{
LogTelemetryEvent(value);
powerOCR = value;
NotifyChange();
}
}
}
private bool advancedPaste = true;
[JsonPropertyName("AdvancedPaste")]
public bool AdvancedPaste
{
get => advancedPaste;
set
{
if (advancedPaste != value)
{
LogTelemetryEvent(value);
advancedPaste = 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 bool workspaces = true;
[JsonPropertyName("Workspaces")]
public bool Workspaces
{
get => workspaces;
set
{
if (workspaces != value)
{
LogTelemetryEvent(value);
workspaces = value;
NotifyChange();
}
}
}
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;
}
}
}