Files
PowerToys/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerAccentPage.xaml
Niels Laute a0b49ff647 [Settings] Add GPO control (#40256)
<!-- 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
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.

<!-- Please review the items on the PR checklist before submitting-->
## 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

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

---------

Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com>
Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com>
2025-09-09 16:48:02 +08:00

234 lines
17 KiB
XML

<local:NavigablePage
x:Class="Microsoft.PowerToys.Settings.UI.Views.PowerAccentPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Lib="using:Microsoft.PowerToys.Settings.UI.Library"
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
xmlns:ui="using:CommunityToolkit.WinUI"
AutomationProperties.LandmarkType="Main"
mc:Ignorable="d">
<local:NavigablePage.Resources>
<CollectionViewSource
x:Name="LanguagesCustomViewSource"
IsSourceGrouped="True"
Source="{x:Bind ViewModel.LanguageGroups, Mode=OneWay}" />
<DataTemplate x:Key="LanguageViewTemplate" x:DataType="Lib:PowerAccentLanguageModel">
<TextBlock Text="{x:Bind Language}" />
</DataTemplate>
</local:NavigablePage.Resources>
<controls:SettingsPageControl
x:Uid="QuickAccent"
IsTabStop="False"
ModuleImageSource="ms-appx:///Assets/Settings/Modules/QuickAccent.png">
<controls:SettingsPageControl.ModuleContent>
<StackPanel ChildrenTransitions="{StaticResource SettingsCardsAnimations}" Orientation="Vertical">
<controls:GPOInfoControl ShowWarning="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay}">
<tkcontrols:SettingsCard
Name="QuickAccentEnableQuickAccent"
x:Uid="QuickAccent_EnableQuickAccent"
HeaderIcon="{ui:BitmapIcon Source=/Assets/Settings/Icons/QuickAccent.png}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.IsEnabled, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
</controls:GPOInfoControl>
<controls:SettingsGroup x:Uid="QuickAccent_Activation_GroupSettings" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsExpander
Name="QuickAccentActivationShortcut"
x:Uid="QuickAccent_Activation_Shortcut"
HeaderIcon="{ui:FontIcon Glyph=&#xEDA7;}"
IsExpanded="True">
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind Path=ViewModel.ActivationKey, Mode=TwoWay}">
<ComboBoxItem x:Uid="QuickAccent_Activation_Key_Arrows" />
<ComboBoxItem x:Uid="QuickAccent_Activation_Key_Space" />
<ComboBoxItem x:Uid="QuickAccent_Activation_Key_Either" />
</ComboBox>
<tkcontrols:SettingsExpander.Items>
<tkcontrols:SettingsCard ContentAlignment="Left">
<CheckBox x:Uid="QuickAccent_Prevent_Activation_On_Game_Mode" IsChecked="{x:Bind ViewModel.DoNotActivateOnGameMode, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
</tkcontrols:SettingsExpander.Items>
</tkcontrols:SettingsExpander>
</controls:SettingsGroup>
<controls:SettingsGroup
x:Name="QuickAccent_Language"
x:Uid="QuickAccent_Language"
IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsExpander
Name="QuickAccentSelectedLanguage"
x:Uid="QuickAccent_SelectedLanguage"
HeaderIcon="{ui:FontIcon Glyph=&#xF2B7;}"
IsExpanded="False">
<CheckBox
x:Name="QuickAccent_SelectedLanguage_All"
x:Uid="QuickAccent_SelectedLanguage_All"
Checked="QuickAccent_SelectedLanguage_SelectAll"
IsThreeState="True"
Unchecked="QuickAccent_SelectedLanguage_UnselectAll" />
<tkcontrols:SettingsExpander.Items>
<tkcontrols:SettingsCard>
<ListView
x:Name="QuickAccent_Language_Select"
MinWidth="{StaticResource SettingActionControlMinWidth}"
MinHeight="{StaticResource SettingActionControlMinWidth}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
ItemTemplate="{StaticResource LanguageViewTemplate}"
ItemsSource="{x:Bind LanguagesCustomViewSource.View, Mode=OneWay}"
Loaded="QuickAccent_Language_Select_Loaded"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollMode="Enabled"
SelectionChanged="QuickAccent_SelectedLanguage_SelectionChanged"
SelectionMode="Multiple">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid
MaxWidth="{Binding ElementName=QuickAccent_Language, Path=ActualWidth}"
ItemWidth="280"
Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<ListViewItemPresenter
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
CheckBoxBorderBrush="{ThemeResource CheckBoxBorderThemeBrush}"
CheckBoxBrush="{ThemeResource CheckBoxCheckBackgroundFillUnchecked}"
CheckBoxCornerRadius="{ThemeResource ControlCornerRadius}"
CheckBoxDisabledBorderBrush="{ThemeResource CheckBoxDisabledBorderThemeBrush}"
CheckBoxDisabledBrush="{ThemeResource CheckBoxCheckBackgroundFillUncheckedDisabled}"
CheckBoxPointerOverBorderBrush="{ThemeResource CheckBoxPointerOverBorderThemeBrush}"
CheckBoxPointerOverBrush="{ThemeResource CheckBoxCheckBackgroundFillUncheckedPointerOver}"
CheckBoxPressedBorderBrush="{ThemeResource CheckBoxPressedBorderThemeBrush}"
CheckBoxPressedBrush="{ThemeResource CheckBoxCheckBackgroundFillUncheckedPressed}"
CheckBoxSelectedBrush="{ThemeResource CheckBoxCheckBackgroundFillChecked}"
CheckBoxSelectedDisabledBrush="{ThemeResource CheckBoxCheckBackgroundFillCheckedDisabled}"
CheckBoxSelectedPointerOverBrush="{ThemeResource CheckBoxCheckBackgroundFillCheckedPointerOver}"
CheckBoxSelectedPressedBrush="{ThemeResource CheckBoxCheckBackgroundFillCheckedPressed}"
CheckBrush="{ThemeResource CheckBoxCheckGlyphForegroundChecked}"
CheckDisabledBrush="{ThemeResource CheckBoxCheckGlyphForegroundCheckedDisabled}"
CheckMode="Inline"
CheckPressedBrush="{ThemeResource CheckBoxCheckGlyphForegroundUncheckedPressed}"
ContentMargin="{TemplateBinding Padding}"
ContentTransitions="{TemplateBinding ContentTransitions}"
DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
SelectionCheckMarkVisualEnabled="True" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate x:DataType="Lib:PowerAccentLanguageGroupModel">
<Border AutomationProperties.AccessibilityView="Raw">
<TextBlock
AutomationProperties.AccessibilityView="Raw"
Style="{ThemeResource SubtitleTextBlockStyle}"
Text="{x:Bind Group}" />
</Border>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
</tkcontrols:SettingsCard>
</tkcontrols:SettingsExpander.Items>
</tkcontrols:SettingsExpander>
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="QuickAccent_Toolbar" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsCard
Name="QuickAccentToolbarPosition"
x:Uid="QuickAccent_ToolbarPosition"
HeaderIcon="{ui:FontIcon Glyph=&#xEC12;}">
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind Path=ViewModel.ToolbarPositionIndex, Mode=TwoWay}">
<ComboBoxItem x:Uid="QuickAccent_ToolbarPosition_TopCenter" />
<ComboBoxItem x:Uid="QuickAccent_ToolbarPosition_BottomCenter" />
<ComboBoxItem x:Uid="QuickAccent_ToolbarPosition_Left" />
<ComboBoxItem x:Uid="QuickAccent_ToolbarPosition_Right" />
<ComboBoxItem x:Uid="QuickAccent_ToolbarPosition_TopRightCorner" />
<ComboBoxItem x:Uid="QuickAccent_ToolbarPosition_TopLeftCorner" />
<ComboBoxItem x:Uid="QuickAccent_ToolbarPosition_BottomRightCorner" />
<ComboBoxItem x:Uid="QuickAccent_ToolbarPosition_BottomLeftCorner" />
<ComboBoxItem x:Uid="QuickAccent_ToolbarPosition_Center" />
</ComboBox>
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
Name="QuickAccentDescriptionIndicator"
x:Uid="QuickAccent_Description_Indicator"
HeaderIcon="{ui:FontIcon Glyph=&#xE946;}">
<ToggleSwitch x:Uid="QuickAccent_UnicodeDescription_ToggleSwitch" IsOn="{x:Bind ViewModel.ShowUnicodeDescription, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
Name="QuickAccentSortByUsageFrequencyIndicator"
x:Uid="QuickAccent_SortByUsageFrequency_Indicator"
HeaderIcon="{ui:FontIcon Glyph=&#xE8CB;}">
<ToggleSwitch x:Uid="QuickAccent_SortByUsageFrequency_ToggleSwitch" IsOn="{x:Bind ViewModel.SortByUsageFrequency, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
Name="QuickAccentStartSelectionFromTheLeftIndicator"
x:Uid="QuickAccent_StartSelectionFromTheLeft_Indicator"
HeaderIcon="{ui:FontIcon Glyph=&#xE974;}">
<ToggleSwitch x:Uid="QuickAccent_StartSelectionFromTheLeft_ToggleSwitch" IsOn="{x:Bind ViewModel.StartSelectionFromTheLeft, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="QuickAccent_Behavior" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsCard
Name="QuickAccentInputTimeMs"
x:Uid="QuickAccent_InputTimeMs"
HeaderIcon="{ui:FontIcon Glyph=&#xE916;}">
<NumberBox
MinWidth="{StaticResource SettingActionControlMinWidth}"
LargeChange="100"
Minimum="100"
SmallChange="10"
SpinButtonPlacementMode="Compact"
Value="{x:Bind ViewModel.InputTimeMs, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsExpander
Name="QuickAccentExcludedApps"
x:Uid="QuickAccent_ExcludedApps"
HeaderIcon="{ui:FontIcon Glyph=&#xECE4;}">
<tkcontrols:SettingsExpander.Items>
<tkcontrols:SettingsCard HorizontalContentAlignment="Stretch" ContentAlignment="Vertical">
<TextBox
x:Uid="QuickAccent_ExcludedApps_TextBoxControl"
MinWidth="240"
MinHeight="160"
AcceptsReturn="True"
ScrollViewer.IsVerticalRailEnabled="True"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollMode="Enabled"
Text="{x:Bind ViewModel.ExcludedApps, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap" />
</tkcontrols:SettingsCard>
</tkcontrols:SettingsExpander.Items>
</tkcontrols:SettingsExpander>
</controls:SettingsGroup>
</StackPanel>
</controls:SettingsPageControl.ModuleContent>
<controls:SettingsPageControl.PrimaryLinks>
<controls:PageLink x:Uid="LearnMore_QuickAccent" Link="https://aka.ms/PowerToysOverview_QuickAccent" />
</controls:SettingsPageControl.PrimaryLinks>
<controls:SettingsPageControl.SecondaryLinks>
<controls:PageLink Link="https://github.com/damienleroy/PowerAccent" Text="Damien Leroy's PowerAccent" />
</controls:SettingsPageControl.SecondaryLinks>
</controls:SettingsPageControl>
</local:NavigablePage>