mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02: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:
@@ -76,9 +76,18 @@
|
|||||||
</controls:SettingsGroup>
|
</controls:SettingsGroup>
|
||||||
|
|
||||||
<controls:SettingsGroup x:Uid="AdvancedPaste_ClipboardHistorySettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
|
<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}" />
|
<ToggleSwitch IsOn="{x:Bind ViewModel.ClipboardHistoryEnabled, Mode=TwoWay}" />
|
||||||
</tkcontrols:SettingsCard>
|
</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>
|
||||||
|
|
||||||
<controls:SettingsGroup x:Uid="AdvancedPaste_Direct_Access_Hotkeys_GroupSettings" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
|
<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)
|
private void SetClipboardHistoryEnabled(bool value)
|
||||||
{
|
{
|
||||||
string registryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Clipboard\";
|
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
|
public HotkeySettings AdvancedPasteUIShortcut
|
||||||
{
|
{
|
||||||
get => _advancedPasteSettings.Properties.AdvancedPasteUIShortcut;
|
get => _advancedPasteSettings.Properties.AdvancedPasteUIShortcut;
|
||||||
|
|||||||
Reference in New Issue
Block a user