mirror of
https://github.com/microsoft/PowerToys
synced 2024-11-22 00:03:48 +00:00
[Settings][AdvPaste]Check clibboard history gpo (#32977)
* [Settings][AdvPaste]Check clibboard history gpo * Fix XAML style * GPO Infobar below
This commit is contained in:
parent
8fce41da06
commit
59f9785296
@ -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=}">
|
||||
<tkcontrols:SettingsCard
|
||||
x:Uid="AdvancedPaste_Clipboard_History_Enabled_SettingsCard"
|
||||
HeaderIcon="{ui:FontIcon Glyph=}"
|
||||
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}">
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user