mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Current behavior is that GPO policies are enforced on the Light Switch settings page but not on the dashboard or quick access menu's. This allows the user to still toggle Light Switch settings in scenarios where GPO is either forcing it to be enabled or disabled. This PR addresses that issue. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] Closes: #43754 ## Additional notes This PR only addresses issues on the dashboard page and in the quick access menu as described by https://github.com/microsoft/PowerToys/issues/43754. This PR also fixed an issue where modules were not showing in the Quick access menu when GPO is set to "Enabled" until you visited the module specific page. When modules are forced enabled, they should appear in Quick Access upon launch if they have a quick access entry. This issue does not address issue https://github.com/microsoft/PowerToys/issues/42484 which was fixed with the PR https://github.com/microsoft/PowerToys/pull/44567 ## Validation Steps Performed Tested locally, photos below Not configured: <img width="1371" height="964" alt="image" src="https://github.com/user-attachments/assets/50ee579d-8ffb-44fd-92a9-e191b61c0318" /> Enabled: <img width="1183" height="988" alt="image" src="https://github.com/user-attachments/assets/789abf28-d140-4d93-8934-48b3ac92be2e" /> Disabled: <img width="1282" height="965" alt="image" src="https://github.com/user-attachments/assets/17ec915a-29d9-42fb-a58e-4b769a728e6a" /> We can observe the option being locked on the quick toggles and not present in the quick access menu when disabled.
95 lines
6.2 KiB
C#
95 lines
6.2 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 global::PowerToys.GPOWrapper;
|
|
using ManagedCommon;
|
|
using Microsoft.PowerToys.Settings.UI.Library;
|
|
using Microsoft.PowerToys.Settings.UI.Views;
|
|
using Windows.UI;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Helpers
|
|
{
|
|
internal sealed class ModuleGpoHelper
|
|
{
|
|
public static GpoRuleConfigured GetModuleGpoConfiguration(ModuleType moduleType)
|
|
{
|
|
switch (moduleType)
|
|
{
|
|
case ModuleType.AdvancedPaste: return GPOWrapper.GetConfiguredAdvancedPasteEnabledValue();
|
|
case ModuleType.AlwaysOnTop: return GPOWrapper.GetConfiguredAlwaysOnTopEnabledValue();
|
|
case ModuleType.Awake: return GPOWrapper.GetConfiguredAwakeEnabledValue();
|
|
case ModuleType.CmdPal: return GPOWrapper.GetConfiguredCmdPalEnabledValue();
|
|
case ModuleType.ColorPicker: return GPOWrapper.GetConfiguredColorPickerEnabledValue();
|
|
case ModuleType.CropAndLock: return GPOWrapper.GetConfiguredCropAndLockEnabledValue();
|
|
case ModuleType.CursorWrap: return GPOWrapper.GetConfiguredCursorWrapEnabledValue();
|
|
case ModuleType.EnvironmentVariables: return GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue();
|
|
case ModuleType.FancyZones: return GPOWrapper.GetConfiguredFancyZonesEnabledValue();
|
|
case ModuleType.FileLocksmith: return GPOWrapper.GetConfiguredFileLocksmithEnabledValue();
|
|
case ModuleType.FindMyMouse: return GPOWrapper.GetConfiguredFindMyMouseEnabledValue();
|
|
case ModuleType.Hosts: return GPOWrapper.GetConfiguredHostsFileEditorEnabledValue();
|
|
case ModuleType.ImageResizer: return GPOWrapper.GetConfiguredImageResizerEnabledValue();
|
|
case ModuleType.KeyboardManager: return GPOWrapper.GetConfiguredKeyboardManagerEnabledValue();
|
|
case ModuleType.LightSwitch: return GPOWrapper.GetConfiguredLightSwitchEnabledValue();
|
|
case ModuleType.MouseHighlighter: return GPOWrapper.GetConfiguredMouseHighlighterEnabledValue();
|
|
case ModuleType.MouseJump: return GPOWrapper.GetConfiguredMouseJumpEnabledValue();
|
|
case ModuleType.MousePointerCrosshairs: return GPOWrapper.GetConfiguredMousePointerCrosshairsEnabledValue();
|
|
case ModuleType.MouseWithoutBorders: return GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue();
|
|
case ModuleType.NewPlus: return GPOWrapper.GetConfiguredNewPlusEnabledValue();
|
|
case ModuleType.Peek: return GPOWrapper.GetConfiguredPeekEnabledValue();
|
|
case ModuleType.PowerRename: return GPOWrapper.GetConfiguredPowerRenameEnabledValue();
|
|
case ModuleType.PowerLauncher: return GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
|
|
case ModuleType.PowerAccent: return GPOWrapper.GetConfiguredQuickAccentEnabledValue();
|
|
case ModuleType.Workspaces: return GPOWrapper.GetConfiguredWorkspacesEnabledValue();
|
|
case ModuleType.RegistryPreview: return GPOWrapper.GetConfiguredRegistryPreviewEnabledValue();
|
|
case ModuleType.MeasureTool: return GPOWrapper.GetConfiguredScreenRulerEnabledValue();
|
|
case ModuleType.ShortcutGuide: return GPOWrapper.GetConfiguredShortcutGuideEnabledValue();
|
|
case ModuleType.PowerOCR: return GPOWrapper.GetConfiguredTextExtractorEnabledValue();
|
|
case ModuleType.PowerDisplay: return GPOWrapper.GetConfiguredPowerDisplayEnabledValue();
|
|
case ModuleType.ZoomIt: return GPOWrapper.GetConfiguredZoomItEnabledValue();
|
|
default: return GpoRuleConfigured.Unavailable;
|
|
}
|
|
}
|
|
|
|
public static System.Type GetModulePageType(ModuleType moduleType)
|
|
{
|
|
return moduleType switch
|
|
{
|
|
ModuleType.AdvancedPaste => typeof(AdvancedPastePage),
|
|
ModuleType.AlwaysOnTop => typeof(AlwaysOnTopPage),
|
|
ModuleType.Awake => typeof(AwakePage),
|
|
ModuleType.CmdPal => typeof(CmdPalPage),
|
|
ModuleType.ColorPicker => typeof(ColorPickerPage),
|
|
ModuleType.CropAndLock => typeof(CropAndLockPage),
|
|
ModuleType.CursorWrap => typeof(MouseUtilsPage),
|
|
ModuleType.LightSwitch => typeof(LightSwitchPage),
|
|
ModuleType.EnvironmentVariables => typeof(EnvironmentVariablesPage),
|
|
ModuleType.FancyZones => typeof(FancyZonesPage),
|
|
ModuleType.FileLocksmith => typeof(FileLocksmithPage),
|
|
ModuleType.FindMyMouse => typeof(MouseUtilsPage),
|
|
ModuleType.GeneralSettings => typeof(GeneralPage),
|
|
ModuleType.Hosts => typeof(HostsPage),
|
|
ModuleType.ImageResizer => typeof(ImageResizerPage),
|
|
ModuleType.KeyboardManager => typeof(KeyboardManagerPage),
|
|
ModuleType.MouseHighlighter => typeof(MouseUtilsPage),
|
|
ModuleType.MouseJump => typeof(MouseUtilsPage),
|
|
ModuleType.MousePointerCrosshairs => typeof(MouseUtilsPage),
|
|
ModuleType.MouseWithoutBorders => typeof(MouseWithoutBordersPage),
|
|
ModuleType.NewPlus => typeof(NewPlusPage),
|
|
ModuleType.Peek => typeof(PeekPage),
|
|
ModuleType.PowerRename => typeof(PowerRenamePage),
|
|
ModuleType.PowerLauncher => typeof(PowerLauncherPage),
|
|
ModuleType.PowerAccent => typeof(PowerAccentPage),
|
|
ModuleType.Workspaces => typeof(WorkspacesPage),
|
|
ModuleType.RegistryPreview => typeof(RegistryPreviewPage),
|
|
ModuleType.MeasureTool => typeof(MeasureToolPage),
|
|
ModuleType.ShortcutGuide => typeof(ShortcutGuidePage),
|
|
ModuleType.PowerOCR => typeof(PowerOcrPage),
|
|
ModuleType.PowerDisplay => typeof(PowerDisplayPage),
|
|
ModuleType.ZoomIt => typeof(ZoomItPage),
|
|
_ => typeof(DashboardPage), // never called, all values listed above
|
|
};
|
|
}
|
|
}
|
|
}
|