From a0b49ff6477a87354b9c7f0aa3ce92aa388582f6 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Tue, 9 Sep 2025 10:48:02 +0200 Subject: [PATCH] [Settings] Add GPO control (#40256) ## Summary of the Pull Request Quality of (dev)life improvement: a dedicated control for showing the GPO-warning InfoBar. As a result, we no longer need to copy-and-paste the same InfoBar XAML all over the place, ensuring that things are consistent and easier to maintain. ## PR Checklist - [x] **Closes:** #40252 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --------- Co-authored-by: Gordon Lam (SH) Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com> --- ...rToys.Settings.DSC.Schema.Generator.csproj | 4 +- .../Settings.UI/PowerToys.Settings.csproj | 3 + .../SettingsXAML/Controls/GPOInfoControl.xaml | 28 ++ .../Controls/GPOInfoControl.xaml.cs | 49 ++++ .../SettingsXAML/Panels/MouseJumpPanel.xaml | 27 +- .../SettingsXAML/Themes/Generic.xaml | 3 +- .../SettingsXAML/Views/AdvancedPastePage.xaml | 50 ++-- .../SettingsXAML/Views/AlwaysOnTopPage.xaml | 26 +- .../SettingsXAML/Views/AwakePage.xaml | 27 +- .../SettingsXAML/Views/CmdPalPage.xaml | 22 +- .../SettingsXAML/Views/ColorPickerPage.xaml | 22 +- .../SettingsXAML/Views/CropAndLockPage.xaml | 26 +- .../Views/EnvironmentVariablesPage.xaml | 25 +- .../SettingsXAML/Views/FancyZonesPage.xaml | 30 +- .../SettingsXAML/Views/FileLocksmithPage.xaml | 26 +- .../SettingsXAML/Views/GeneralPage.xaml | 95 +++---- .../SettingsXAML/Views/HostsPage.xaml | 25 +- .../SettingsXAML/Views/ImageResizerPage.xaml | 27 +- .../Views/KeyboardManagerPage.xaml | 35 +-- .../SettingsXAML/Views/MeasureToolPage.xaml | 32 +-- .../SettingsXAML/Views/MouseUtilsPage.xaml | 76 ++---- .../Views/MouseWithoutBordersPage.xaml | 111 +++----- .../SettingsXAML/Views/NewPlusPage.xaml | 257 ++++++++---------- .../SettingsXAML/Views/PeekPage.xaml | 26 +- .../SettingsXAML/Views/PowerAccentPage.xaml | 27 +- .../SettingsXAML/Views/PowerLauncherPage.xaml | 28 +- .../SettingsXAML/Views/PowerOcrPage.xaml | 25 +- .../SettingsXAML/Views/PowerRenamePage.xaml | 25 +- .../Views/RegistryPreviewPage.xaml | 29 +- .../SettingsXAML/Views/ShortcutGuidePage.xaml | 25 +- .../SettingsXAML/Views/WorkspacesPage.xaml | 27 +- .../SettingsXAML/Views/ZoomItPage.xaml | 26 +- 32 files changed, 499 insertions(+), 765 deletions(-) create mode 100644 src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml create mode 100644 src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml.cs diff --git a/src/dsc/PowerToys.Settings.DSC.Schema.Generator/PowerToys.Settings.DSC.Schema.Generator.csproj b/src/dsc/PowerToys.Settings.DSC.Schema.Generator/PowerToys.Settings.DSC.Schema.Generator.csproj index 83ef8f96b4..3186a01d43 100644 --- a/src/dsc/PowerToys.Settings.DSC.Schema.Generator/PowerToys.Settings.DSC.Schema.Generator.csproj +++ b/src/dsc/PowerToys.Settings.DSC.Schema.Generator/PowerToys.Settings.DSC.Schema.Generator.csproj @@ -31,11 +31,11 @@ - + - + diff --git a/src/settings-ui/Settings.UI/PowerToys.Settings.csproj b/src/settings-ui/Settings.UI/PowerToys.Settings.csproj index 18ee80a5bf..68d0348c7d 100644 --- a/src/settings-ui/Settings.UI/PowerToys.Settings.csproj +++ b/src/settings-ui/Settings.UI/PowerToys.Settings.csproj @@ -161,6 +161,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml new file mode 100644 index 0000000000..73a862f00a --- /dev/null +++ b/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml @@ -0,0 +1,28 @@ + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml.cs new file mode 100644 index 0000000000..8942d5c4db --- /dev/null +++ b/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml.cs @@ -0,0 +1,49 @@ +// 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.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices.WindowsRuntime; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Documents; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; + +namespace Microsoft.PowerToys.Settings.UI.Controls; + +public sealed partial class GPOInfoControl : ContentControl +{ + public static readonly DependencyProperty ShowWarningProperty = + DependencyProperty.Register( + nameof(ShowWarning), + typeof(bool), + typeof(GPOInfoControl), + new PropertyMetadata(false, OnShowWarningPropertyChanged)); + + public bool ShowWarning + { + get => (bool)GetValue(ShowWarningProperty); + set => SetValue(ShowWarningProperty, value); + } + + private static void OnShowWarningPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is GPOInfoControl gpoInfoControl) + { + if (gpoInfoControl.ShowWarning) + { + gpoInfoControl.IsEnabled = false; + } + } + } + + public GPOInfoControl() + { + DefaultStyleKey = typeof(GPOInfoControl); + } +} diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml index 478cd994cc..79fd53978c 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml @@ -22,25 +22,14 @@ - - - - - - - - - - + + + + + + - + \ No newline at end of file diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml index 28a28bf0b5..628df84c01 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml @@ -46,23 +46,14 @@ ChildrenTransitions="{StaticResource SettingsCardsAnimations}" Orientation="Vertical" Spacing="2"> - - - - - - - - + + + + + - - - - - - - - + + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml index a5fec151fb..d6194dc5b2 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml @@ -17,25 +17,15 @@ ModuleImageSource="ms-appx:///Assets/Settings/Modules/AlwaysOnTop.png"> - - - - - - - - + + + + + - - - - - - - - - + + + + + - - - - - - + + + + + - - - - - - - - + + + + + - - - - - - - - + + + + + - - - - - - - - - + + + + + - - - - - - - - - + + + + + - - - - - - - - - + + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml index e06d367941..fcdcc0f60d 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml @@ -48,7 +48,6 @@ FontWeight="SemiBold" Foreground="{ThemeResource TextFillColorSecondaryBrush}" /> - - - - - + + + + + + - - - + + + + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml index f988f8917d..5ad3a998ad 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml @@ -14,24 +14,14 @@ - - - - - - - - - + + + + + - - - - - - - - - - + + + + + - - - - - - - - - - + + + + + -