[Settings][AdvPaste]Check clibboard history gpo (#32977)

* [Settings][AdvPaste]Check clibboard history gpo

* Fix XAML style

* GPO Infobar below
This commit is contained in:
Jaime Bernardo 2024-05-24 00:19:01 +01:00 committed by GitHub
parent 8fce41da06
commit 59f9785296
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 1 deletions

View File

@ -76,9 +76,18 @@
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="AdvancedPaste_ClipboardHistorySettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsCard x:Uid="AdvancedPaste_Clipboard_History_Enabled_SettingsCard" HeaderIcon="{ui:FontIcon Glyph=&#xF0E3;}">
<tkcontrols:SettingsCard
x:Uid="AdvancedPaste_Clipboard_History_Enabled_SettingsCard"
HeaderIcon="{ui:FontIcon Glyph=&#xF0E3;}"
IsEnabled="{x:Bind ViewModel.ClipboardHistoryDisabledByGPO, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
<ToggleSwitch IsOn="{x:Bind ViewModel.ClipboardHistoryEnabled, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<InfoBar
x:Uid="GPO_SettingIsManaged"
IsClosable="False"
IsOpen="{x:Bind ViewModel.ClipboardHistoryDisabledByGPO, Mode=OneWay}"
IsTabStop="{x:Bind ViewModel.ClipboardHistoryDisabledByGPO, Mode=OneWay}"
Severity="Informational" />
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="AdvancedPaste_Direct_Access_Hotkeys_GroupSettings" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">

View File

@ -145,6 +145,27 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
private bool IsClipboardHistoryDisabledByGPO()
{
string registryKey = @"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System\";
try
{
object allowClipboardHistory = Registry.GetValue(registryKey, "AllowClipboardHistory", null);
if (allowClipboardHistory != null)
{
return (int)allowClipboardHistory == 0;
}
else
{
return false;
}
}
catch (Exception)
{
return false;
}
}
private void SetClipboardHistoryEnabled(bool value)
{
string registryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Clipboard\";
@ -169,6 +190,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public bool ClipboardHistoryDisabledByGPO
{
get => IsClipboardHistoryDisabledByGPO();
}
public HotkeySettings AdvancedPasteUIShortcut
{
get => _advancedPasteSettings.Properties.AdvancedPasteUIShortcut;