mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 13:35:31 +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:
@@ -220,4 +220,8 @@ namespace winrt::PowerToys::GPOWrapper::implementation
|
|||||||
// Convert std::wstring to winrt::hstring
|
// Convert std::wstring to winrt::hstring
|
||||||
return to_hstring(rules.c_str());
|
return to_hstring(rules.c_str());
|
||||||
}
|
}
|
||||||
|
GpoRuleConfigured GPOWrapper::GetConfiguredNewPlusHideTemplateFilenameExtensionValue()
|
||||||
|
{
|
||||||
|
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredNewPlusHideTemplateFilenameExtensionValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ namespace winrt::PowerToys::GPOWrapper::implementation
|
|||||||
static GpoRuleConfigured GetConfiguredMwbValidateRemoteIpValue();
|
static GpoRuleConfigured GetConfiguredMwbValidateRemoteIpValue();
|
||||||
static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
|
static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
|
||||||
static winrt::hstring GPOWrapper::GetConfiguredMwbPolicyDefinedIpMappingRules();
|
static winrt::hstring GPOWrapper::GetConfiguredMwbPolicyDefinedIpMappingRules();
|
||||||
|
static GpoRuleConfigured GetConfiguredNewPlusHideTemplateFilenameExtensionValue();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ namespace PowerToys
|
|||||||
static GpoRuleConfigured GetConfiguredMwbValidateRemoteIpValue();
|
static GpoRuleConfigured GetConfiguredMwbValidateRemoteIpValue();
|
||||||
static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
|
static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
|
||||||
static String GetConfiguredMwbPolicyDefinedIpMappingRules();
|
static String GetConfiguredMwbPolicyDefinedIpMappingRules();
|
||||||
|
static GpoRuleConfigured GetConfiguredNewPlusHideTemplateFilenameExtensionValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ namespace powertoys_gpo {
|
|||||||
const std::wstring POLICY_MWB_VALIDATE_REMOTE_IP = L"MwbValidateRemoteIp";
|
const std::wstring POLICY_MWB_VALIDATE_REMOTE_IP = L"MwbValidateRemoteIp";
|
||||||
const std::wstring POLICY_MWB_DISABLE_USER_DEFINED_IP_MAPPING_RULES = L"MwbDisableUserDefinedIpMappingRules";
|
const std::wstring POLICY_MWB_DISABLE_USER_DEFINED_IP_MAPPING_RULES = L"MwbDisableUserDefinedIpMappingRules";
|
||||||
const std::wstring POLICY_MWB_POLICY_DEFINED_IP_MAPPING_RULES = L"MwbPolicyDefinedIpMappingRules";
|
const std::wstring POLICY_MWB_POLICY_DEFINED_IP_MAPPING_RULES = L"MwbPolicyDefinedIpMappingRules";
|
||||||
|
const std::wstring POLICY_NEW_PLUS_HIDE_TEMPLATE_FILENAME_EXTENSION = L"NewPlusHideTemplateFilenameExtension";
|
||||||
|
|
||||||
// Methods used for reading the registry
|
// Methods used for reading the registry
|
||||||
#pragma region ReadRegistryMethods
|
#pragma region ReadRegistryMethods
|
||||||
@@ -585,5 +586,10 @@ namespace powertoys_gpo {
|
|||||||
return std::wstring ();
|
return std::wstring ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline gpo_rule_configured_t getConfiguredNewPlusHideTemplateFilenameExtensionValue()
|
||||||
|
{
|
||||||
|
return getConfiguredValue(POLICY_NEW_PLUS_HIDE_TEMPLATE_FILENAME_EXTENSION);
|
||||||
|
}
|
||||||
#pragma endregion IndividualModuleSettingPolicies
|
#pragma endregion IndividualModuleSettingPolicies
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@
|
|||||||
<category name="GeneralSettings" displayName="$(string.GeneralSettings)">
|
<category name="GeneralSettings" displayName="$(string.GeneralSettings)">
|
||||||
<parentCategory ref="PowerToys" />
|
<parentCategory ref="PowerToys" />
|
||||||
</category>
|
</category>
|
||||||
|
<category name="NewPlus" displayName="$(string.NewPlus)">
|
||||||
|
<parentCategory ref="PowerToys" />
|
||||||
|
</category>
|
||||||
</categories>
|
</categories>
|
||||||
<policies>
|
<policies>
|
||||||
|
|
||||||
@@ -611,5 +614,15 @@
|
|||||||
<multiText id="MwbPolicyDefinedIpMappingsList" valueName="MwbPolicyDefinedIpMappingRules" maxLength="65" required="true"/>
|
<multiText id="MwbPolicyDefinedIpMappingsList" valueName="MwbPolicyDefinedIpMappingRules" maxLength="65" required="true"/>
|
||||||
</elements>
|
</elements>
|
||||||
</policy>
|
</policy>
|
||||||
|
<policy name="NewPlusHideTemplateFilenameExtension" class="Both" displayName="$(string.NewPlusHideTemplateFilenameExtension)" explainText="$(string.NewPlusHideTemplateFilenameExtensionDescription)" key="Software\Policies\PowerToys" valueName="NewPlusHideTemplateFilenameExtension">
|
||||||
|
<parentCategory ref="NewPlus" />
|
||||||
|
<supportedOn ref="SUPPORTED_POWERTOYS_0_85_0" />
|
||||||
|
<enabledValue>
|
||||||
|
<decimal value="1" />
|
||||||
|
</enabledValue>
|
||||||
|
<disabledValue>
|
||||||
|
<decimal value="0" />
|
||||||
|
</disabledValue>
|
||||||
|
</policy>
|
||||||
</policies>
|
</policies>
|
||||||
</policyDefinitions>
|
</policyDefinitions>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<string id="AdvancedPaste">Advanced Paste</string>
|
<string id="AdvancedPaste">Advanced Paste</string>
|
||||||
<string id="MouseWithoutBorders">Mouse Without Borders</string>
|
<string id="MouseWithoutBorders">Mouse Without Borders</string>
|
||||||
<string id="GeneralSettings">General settings</string>
|
<string id="GeneralSettings">General settings</string>
|
||||||
|
<string id="NewPlus">New+</string>
|
||||||
|
|
||||||
<string id="SUPPORTED_POWERTOYS_0_64_0">PowerToys version 0.64.0 or later</string>
|
<string id="SUPPORTED_POWERTOYS_0_64_0">PowerToys version 0.64.0 or later</string>
|
||||||
<string id="SUPPORTED_POWERTOYS_0_68_0">PowerToys version 0.68.0 or later</string>
|
<string id="SUPPORTED_POWERTOYS_0_68_0">PowerToys version 0.68.0 or later</string>
|
||||||
@@ -189,6 +190,14 @@ If you enable this policy, you can define IP Address mapping rules that the user
|
|||||||
Please enter one mapping per line in the format: "hostname IP"
|
Please enter one mapping per line in the format: "hostname IP"
|
||||||
|
|
||||||
If you disable or don't configure this policy, no predefined rules are applied.
|
If you disable or don't configure this policy, no predefined rules are applied.
|
||||||
|
</string>
|
||||||
|
<string id="NewPlusHideTemplateFilenameExtensionDescription">This policy configures if the template filenames are shown with extension or not.
|
||||||
|
|
||||||
|
If you enable this policy, the setting is enabled and the extension is hidden.
|
||||||
|
|
||||||
|
If you disable this policy, the setting is disabled and the extension is shown.
|
||||||
|
|
||||||
|
If you don't configure this policy, the user takes control over the setting and can enable or disable it.
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
<string id="ConfigureAllUtilityGlobalEnabledState">Configure global utility enabled state</string>
|
<string id="ConfigureAllUtilityGlobalEnabledState">Configure global utility enabled state</string>
|
||||||
@@ -248,6 +257,7 @@ If you disable or don't configure this policy, no predefined rules are applied.
|
|||||||
<string id="MwbValidateRemoteIp">Validate remote machine IP Address</string>
|
<string id="MwbValidateRemoteIp">Validate remote machine IP Address</string>
|
||||||
<string id="MwbDisableUserDefinedIpMappingRules">Disable user defined IP Address mapping rules</string>
|
<string id="MwbDisableUserDefinedIpMappingRules">Disable user defined IP Address mapping rules</string>
|
||||||
<string id="MwbPolicyDefinedIpMappingRules">Predefined IP Address mapping rules</string>
|
<string id="MwbPolicyDefinedIpMappingRules">Predefined IP Address mapping rules</string>
|
||||||
|
<string id="NewPlusHideTemplateFilenameExtension">Hide template filename extension</string>
|
||||||
</stringTable>
|
</stringTable>
|
||||||
|
|
||||||
<presentationTable>
|
<presentationTable>
|
||||||
|
|||||||
@@ -175,6 +175,16 @@ bool NewSettings::GetEnabled()
|
|||||||
|
|
||||||
bool NewSettings::GetHideFileExtension() const
|
bool NewSettings::GetHideFileExtension() const
|
||||||
{
|
{
|
||||||
|
auto gpoSetting = powertoys_gpo::getConfiguredNewPlusHideTemplateFilenameExtensionValue();
|
||||||
|
if (gpoSetting == powertoys_gpo::gpo_rule_configured_enabled)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (gpoSetting == powertoys_gpo::gpo_rule_configured_disabled)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return new_settings.hide_file_extension;
|
return new_settings.hide_file_extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,9 +68,19 @@
|
|||||||
</controls:SettingsGroup>
|
</controls:SettingsGroup>
|
||||||
|
|
||||||
<controls:SettingsGroup x:Uid="NewPlus_Display_Options" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
|
<controls:SettingsGroup x:Uid="NewPlus_Display_Options" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
|
||||||
<tkcontrols:SettingsCard x:Uid="NewPlus_Hide_File_Extension_Toggle">
|
<tkcontrols:SettingsCard x:Uid="NewPlus_Hide_File_Extension_Toggle" IsEnabled="{x:Bind ViewModel.IsHideFileExtSettingsCardEnabled, Mode=OneWay}">
|
||||||
<ToggleSwitch x:Uid="HideFileExtensionToggle" IsOn="{x:Bind ViewModel.HideFileExtension, Mode=TwoWay}" />
|
<ToggleSwitch x:Uid="HideFileExtensionToggle" IsOn="{x:Bind ViewModel.HideFileExtension, Mode=TwoWay}" />
|
||||||
</tkcontrols:SettingsCard>
|
</tkcontrols:SettingsCard>
|
||||||
|
<InfoBar
|
||||||
|
x:Uid="GPO_SettingIsManaged"
|
||||||
|
IsClosable="False"
|
||||||
|
IsOpen="{x:Bind ViewModel.IsHideFileExtSettingGPOConfigured, Mode=OneWay}"
|
||||||
|
IsTabStop="{x:Bind ViewModel.IsHideFileExtSettingGPOConfigured, Mode=OneWay}"
|
||||||
|
Severity="Informational">
|
||||||
|
<!-- InfoBar.IconSource>
|
||||||
|
<FontIconSource FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="" />
|
||||||
|
</InfoBar.IconSource-->
|
||||||
|
</InfoBar>
|
||||||
<tkcontrols:SettingsCard x:Uid="NewPlus_Hide_Starting_Digits_Toggle">
|
<tkcontrols:SettingsCard x:Uid="NewPlus_Hide_Starting_Digits_Toggle">
|
||||||
<ToggleSwitch x:Uid="HideStartingDigitsToggle" IsOn="{x:Bind ViewModel.HideStartingDigits, Mode=TwoWay}" />
|
<ToggleSwitch x:Uid="HideStartingDigitsToggle" IsOn="{x:Bind ViewModel.HideStartingDigits, Mode=TwoWay}" />
|
||||||
<tkcontrols:SettingsCard.Description>
|
<tkcontrols:SettingsCard.Description>
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
_hideStartingDigits = Settings.HideStartingDigits;
|
_hideStartingDigits = Settings.HideStartingDigits;
|
||||||
_templateLocation = Settings.TemplateLocation;
|
_templateLocation = Settings.TemplateLocation;
|
||||||
InitializeEnabledValue();
|
InitializeEnabledValue();
|
||||||
|
InitializeGpoValues();
|
||||||
|
|
||||||
// set the callback functions value to handle outgoing IPC message.
|
// set the callback functions value to handle outgoing IPC message.
|
||||||
SendConfigMSG = ipcMSGCallBackFunc;
|
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
|
public bool IsEnabled
|
||||||
{
|
{
|
||||||
get => _isNewPlusEnabled;
|
get => _isNewPlusEnabled;
|
||||||
@@ -82,6 +90,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
|
|
||||||
GeneralSettingsConfig.Enabled.NewPlus = value;
|
GeneralSettingsConfig.Enabled.NewPlus = value;
|
||||||
OnPropertyChanged(nameof(IsEnabled));
|
OnPropertyChanged(nameof(IsEnabled));
|
||||||
|
OnPropertyChanged(nameof(IsHideFileExtSettingsCardEnabled));
|
||||||
|
OnPropertyChanged(nameof(IsHideFileExtSettingGPOConfigured));
|
||||||
|
|
||||||
OutGoingGeneralSettings outgoingMessage = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
OutGoingGeneralSettings outgoingMessage = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||||
SendConfigMSG(outgoingMessage.ToString());
|
SendConfigMSG(outgoingMessage.ToString());
|
||||||
@@ -121,10 +131,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
|
|
||||||
public bool HideFileExtension
|
public bool HideFileExtension
|
||||||
{
|
{
|
||||||
get => _hideFileExtension;
|
get
|
||||||
|
{
|
||||||
|
if (_hideFileExtensionIsGPOConfigured)
|
||||||
|
{
|
||||||
|
return _hideFileExtensionGpoRuleConfiguration == GpoRuleConfigured.Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _hideFileExtension;
|
||||||
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_hideFileExtension != value)
|
if (_hideFileExtension != value && !_hideFileExtensionIsGPOConfigured)
|
||||||
{
|
{
|
||||||
_hideFileExtension = value;
|
_hideFileExtension = value;
|
||||||
Settings.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
|
public bool HideStartingDigits
|
||||||
{
|
{
|
||||||
get => _hideStartingDigits;
|
get => _hideStartingDigits;
|
||||||
@@ -209,13 +232,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GpoRuleConfigured _enabledGpoRuleConfiguration;
|
|
||||||
private bool _enabledStateIsGPOConfigured;
|
|
||||||
private bool _isNewPlusEnabled;
|
private bool _isNewPlusEnabled;
|
||||||
private string _templateLocation;
|
private string _templateLocation;
|
||||||
private bool _hideFileExtension;
|
private bool _hideFileExtension;
|
||||||
private bool _hideStartingDigits;
|
private bool _hideStartingDigits;
|
||||||
|
|
||||||
|
private GpoRuleConfigured _enabledGpoRuleConfiguration;
|
||||||
|
private bool _enabledStateIsGPOConfigured;
|
||||||
|
private GpoRuleConfigured _hideFileExtensionGpoRuleConfiguration;
|
||||||
|
private bool _hideFileExtensionIsGPOConfigured;
|
||||||
|
|
||||||
public void RefreshEnabledState()
|
public void RefreshEnabledState()
|
||||||
{
|
{
|
||||||
InitializeEnabledValue();
|
InitializeEnabledValue();
|
||||||
|
|||||||
@@ -91,4 +91,5 @@ void ReportGPOValues(const std::filesystem::path& tmpDir)
|
|||||||
report << "getConfiguredMwbDisableUserDefinedIpMappingRulesValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbDisableUserDefinedIpMappingRulesValue()) << std::endl;
|
report << "getConfiguredMwbDisableUserDefinedIpMappingRulesValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbDisableUserDefinedIpMappingRulesValue()) << std::endl;
|
||||||
report << "getConfiguredMwbPolicyDefinedIpMappingRules: " << gpo_string_to_string(powertoys_gpo::getConfiguredMwbPolicyDefinedIpMappingRules()) << std::endl;
|
report << "getConfiguredMwbPolicyDefinedIpMappingRules: " << gpo_string_to_string(powertoys_gpo::getConfiguredMwbPolicyDefinedIpMappingRules()) << std::endl;
|
||||||
report << "getConfiguredNewPlusEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredNewPlusEnabledValue()) << std::endl;
|
report << "getConfiguredNewPlusEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredNewPlusEnabledValue()) << std::endl;
|
||||||
|
report << "getConfiguredNewPlusHideTemplateFilenameExtensionValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredNewPlusHideTemplateFilenameExtensionValue()) << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user