mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
[New+, Enterprise]Policy for showing filename extension (#35000)
* add gpo: admx, gpo utils * todo note * BugReport tool * implement policy in utility * settings ui * remove todo comment * code fixes * code fixes 2 * spell fix
This commit is contained in:
@@ -51,6 +51,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
_hideStartingDigits = Settings.HideStartingDigits;
|
||||
_templateLocation = Settings.TemplateLocation;
|
||||
InitializeEnabledValue();
|
||||
InitializeGpoValues();
|
||||
|
||||
// set the callback functions value to handle outgoing IPC message.
|
||||
SendConfigMSG = ipcMSGCallBackFunc;
|
||||
@@ -71,6 +72,13 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeGpoValues()
|
||||
{
|
||||
// Policy for hide file extension setting
|
||||
_hideFileExtensionGpoRuleConfiguration = GPOWrapper.GetConfiguredNewPlusHideTemplateFilenameExtensionValue();
|
||||
_hideFileExtensionIsGPOConfigured = _hideFileExtensionGpoRuleConfiguration == GpoRuleConfigured.Disabled || _hideFileExtensionGpoRuleConfiguration == GpoRuleConfigured.Enabled;
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isNewPlusEnabled;
|
||||
@@ -82,6 +90,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
GeneralSettingsConfig.Enabled.NewPlus = value;
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
OnPropertyChanged(nameof(IsHideFileExtSettingsCardEnabled));
|
||||
OnPropertyChanged(nameof(IsHideFileExtSettingGPOConfigured));
|
||||
|
||||
OutGoingGeneralSettings outgoingMessage = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
SendConfigMSG(outgoingMessage.ToString());
|
||||
@@ -121,10 +131,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
public bool HideFileExtension
|
||||
{
|
||||
get => _hideFileExtension;
|
||||
get
|
||||
{
|
||||
if (_hideFileExtensionIsGPOConfigured)
|
||||
{
|
||||
return _hideFileExtensionGpoRuleConfiguration == GpoRuleConfigured.Enabled;
|
||||
}
|
||||
|
||||
return _hideFileExtension;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_hideFileExtension != value)
|
||||
if (_hideFileExtension != value && !_hideFileExtensionIsGPOConfigured)
|
||||
{
|
||||
_hideFileExtension = value;
|
||||
Settings.HideFileExtension = value;
|
||||
@@ -137,6 +156,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHideFileExtSettingsCardEnabled => _isNewPlusEnabled && !_hideFileExtensionIsGPOConfigured;
|
||||
|
||||
public bool IsHideFileExtSettingGPOConfigured => _isNewPlusEnabled && _hideFileExtensionIsGPOConfigured;
|
||||
|
||||
public bool HideStartingDigits
|
||||
{
|
||||
get => _hideStartingDigits;
|
||||
@@ -209,13 +232,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private GpoRuleConfigured _enabledGpoRuleConfiguration;
|
||||
private bool _enabledStateIsGPOConfigured;
|
||||
private bool _isNewPlusEnabled;
|
||||
private string _templateLocation;
|
||||
private bool _hideFileExtension;
|
||||
private bool _hideStartingDigits;
|
||||
|
||||
private GpoRuleConfigured _enabledGpoRuleConfiguration;
|
||||
private bool _enabledStateIsGPOConfigured;
|
||||
private GpoRuleConfigured _hideFileExtensionGpoRuleConfiguration;
|
||||
private bool _hideFileExtensionIsGPOConfigured;
|
||||
|
||||
public void RefreshEnabledState()
|
||||
{
|
||||
InitializeEnabledValue();
|
||||
|
||||
Reference in New Issue
Block a user