Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[File Explorer] Added an overall toggle switch (#23723) #33475

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7e4e12b
Added stuff for an enabled toggle
acekirkpatrick Jun 11, 2024
79919c9
Removed incorrect summary
acekirkpatrick Jun 12, 2024
2b513b6
Added most of a GPO
acekirkpatrick Jun 13, 2024
9dabee3
Added to BugReportTool
acekirkpatrick Jun 13, 2024
d6bd83b
Updated .adml and .admx
acekirkpatrick Jun 13, 2024
b65f633
Added a card to the Dashboard
acekirkpatrick Jun 13, 2024
a40d5c5
Fixed adml
acekirkpatrick Jun 17, 2024
cd3172c
Reordered things so File Explorer appears in the right place
acekirkpatrick Jun 17, 2024
40707c4
Finished copying from other modules
acekirkpatrick Jun 17, 2024
75e8ed9
Made sure it was using its own GPO
acekirkpatrick Jun 17, 2024
43074da
Allowed it to save the setting
acekirkpatrick Jun 18, 2024
877d12c
Disabled settings when module is not enabled
acekirkpatrick Jun 18, 2024
e5798ee
Reformatted .adml and .admx
acekirkpatrick Jun 21, 2024
9e85b63
Added a check to stop it from starting the handlers if the module is …
acekirkpatrick Jun 21, 2024
b35df52
Made sure enable() called apply_settings so that the modules start
acekirkpatrick Jun 21, 2024
f197ee3
Updated .adml and .admx
acekirkpatrick Jun 26, 2024
4f15ce6
Reordered .adml and .admx
acekirkpatrick Jun 26, 2024
7d1f213
Renamed File Previewer to File Explorer add-on
acekirkpatrick Jun 28, 2024
b905634
Improved C++ code
acekirkpatrick Jun 28, 2024
e3e9583
Hid the info bars when the module is disabled
acekirkpatrick Jun 28, 2024
1470338
Changed the dashboard text
acekirkpatrick Jun 28, 2024
4c42c90
Updated for consistent behavior
acekirkpatrick Jun 30, 2024
c9174f9
Stopped the global utility policy from affecting individual previewers
acekirkpatrick Jul 3, 2024
7a4052d
Turned off previewers if module is disabled
acekirkpatrick Jul 3, 2024
779214e
Updated .adml
acekirkpatrick Jul 3, 2024
115d3e8
Merge branch 'main' into 23723
jaimecbernardo Jul 22, 2024
9c83638
Update .adml for clarification
acekirkpatrick Jul 22, 2024
b31bcab
Update .adml for clarification
acekirkpatrick Jul 25, 2024
7f6ab6f
Updated version information in the .admx and .adml
acekirkpatrick Aug 8, 2024
893e5de
Updated .adml and .admx to version 0.85.0
acekirkpatrick Sep 4, 2024
34381ad
Change to revision comment
acekirkpatrick Sep 4, 2024
dc1746a
Merged main into 23723
acekirkpatrick Sep 4, 2024
304ca76
Merged main into 23723
acekirkpatrick Sep 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/common/GPOWrapper/GPOWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,8 @@ namespace winrt::PowerToys::GPOWrapper::implementation
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getAllowedAdvancedPasteOnlineAIModelsValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredFileExplorerPreviewEnabledValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredFileExplorerPreviewEnabledValue());
}
}
1 change: 1 addition & 0 deletions src/common/GPOWrapper/GPOWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace winrt::PowerToys::GPOWrapper::implementation
static GpoRuleConfigured GetConfiguredQoiPreviewEnabledValue();
static GpoRuleConfigured GetConfiguredQoiThumbnailsEnabledValue();
static GpoRuleConfigured GetAllowedAdvancedPasteOnlineAIModelsValue();
static GpoRuleConfigured GetConfiguredFileExplorerPreviewEnabledValue();
};
}

Expand Down
1 change: 1 addition & 0 deletions src/common/GPOWrapper/GPOWrapper.idl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace PowerToys
static GpoRuleConfigured GetConfiguredQoiPreviewEnabledValue();
static GpoRuleConfigured GetConfiguredQoiThumbnailsEnabledValue();
static GpoRuleConfigured GetAllowedAdvancedPasteOnlineAIModelsValue();
static GpoRuleConfigured GetConfiguredFileExplorerPreviewEnabledValue();
}
}
}
1 change: 1 addition & 0 deletions src/common/ManagedCommon/ModuleType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum ModuleType
CropAndLock,
EnvironmentVariables,
FancyZones,
PowerPreview,
FileLocksmith,
FindMyMouse,
Hosts,
Expand Down
12 changes: 9 additions & 3 deletions src/common/utils/gpo.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace powertoys_gpo {
const std::wstring POLICY_CONFIGURE_ENABLED_ENVIRONMENT_VARIABLES = L"ConfigureEnabledUtilityEnvironmentVariables";
const std::wstring POLICY_CONFIGURE_ENABLED_QOI_PREVIEW = L"ConfigureEnabledUtilityFileExplorerQOIPreview";
const std::wstring POLICY_CONFIGURE_ENABLED_QOI_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerQOIThumbnails";
const std::wstring POLICY_CONFIGURE_ENABLED_FILE_EXPLORER_PREVIEW = L"ConfigureEnabledUtilityFileExplorerPreview";

// The registry value names for PowerToys installer and update policies.
const std::wstring POLICY_DISABLE_PER_USER_INSTALLATION = L"PerUserInstallationDisabled";
Expand Down Expand Up @@ -422,7 +423,7 @@ namespace powertoys_gpo {
}

inline gpo_rule_configured_t getRunPluginEnabledValue(std::string pluginID)
{
{
if (pluginID == "" || pluginID == " ")
{
// this plugin id can't exist in the registry
Expand All @@ -431,7 +432,7 @@ namespace powertoys_gpo {

std::wstring plugin_id(pluginID.begin(), pluginID.end());
auto individual_plugin_setting = getPolicyListValue(POWER_LAUNCHER_INDIVIDUAL_PLUGIN_ENABLED_LIST_PATH, plugin_id);

if (individual_plugin_setting.has_value())
{
if (*individual_plugin_setting == L"0")
Expand All @@ -458,7 +459,7 @@ namespace powertoys_gpo {
{
// If no individual plugin policy exists, we check the policy with the setting for all plugins.
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_POWER_LAUNCHER_ALL_PLUGINS);
}
}
}

inline gpo_rule_configured_t getConfiguredQoiPreviewEnabledValue()
Expand All @@ -475,4 +476,9 @@ namespace powertoys_gpo {
{
return getUtilityEnabledValue(POLICY_ALLOW_ADVANCED_PASTE_ONLINE_AI_MODELS);
}

inline gpo_rule_configured_t getConfiguredFileExplorerPreviewEnabledValue()
{
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_FILE_EXPLORER_PREVIEW);
}
}
15 changes: 13 additions & 2 deletions src/gpo/assets/PowerToys.admx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<policyDefinitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.10" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyDefinitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.11" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyNamespaces>
<target prefix="powertoys" namespace="Microsoft.Policies.PowerToys" />
</policyNamespaces>
<resources minRequiredRevision="1.10"/><!-- Last changed with PowerToys v0.81.1 -->
<resources minRequiredRevision="1.11"/><!-- Last changed with PowerToys v0.82.0 -->
<supportedOn>
<definitions>
<definition name="SUPPORTED_POWERTOYS_0_64_0" displayName="$(string.SUPPORTED_POWERTOYS_0_64_0)"/>
Expand All @@ -19,6 +19,7 @@
<definition name="SUPPORTED_POWERTOYS_0_78_0" displayName="$(string.SUPPORTED_POWERTOYS_0_78_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_81_0" displayName="$(string.SUPPORTED_POWERTOYS_0_81_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_81_1" displayName="$(string.SUPPORTED_POWERTOYS_0_81_1)"/>
<definition name="SUPPORTED_POWERTOYS_0_82_0" displayName="$(string.SUPPORTED_POWERTOYS_0_82_0)"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be 0.83.0 . Please update all occurrences.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

</definitions>
</supportedOn>
<categories>
Expand Down Expand Up @@ -136,6 +137,16 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="ConfigureEnabledUtilityFileExplorerPreview" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerPreview)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerPreview">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We need a new description with the addition that disabling also disabled all single previewer. ANd with the info that force enabling it not force enables the toggles of the single previewers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (line 49).

<parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_82_0" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="ConfigureEnabledUtilityFileExplorerSVGPreview" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerSVGPreview)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerSVGPreview">
<parentCategory ref="PowerToys" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could move all this File Explorer preview GPOs into a new subcategory "File Previewers". That makes it easier to find the GPOs for the single previewers. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that when I made the GPO. I think we should. It was hard to find the overall GPO even when I knew exactly what I was looking for.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the overall gpo has to keep in the main folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<supportedOn ref="SUPPORTED_POWERTOYS_0_64_0" />
Expand Down
4 changes: 3 additions & 1 deletion src/gpo/assets/en-US/PowerToys.adml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.10" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.11" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<displayName>PowerToys</displayName>
<description>PowerToys</description>
<resources>
Expand All @@ -22,6 +22,7 @@
<string id="SUPPORTED_POWERTOYS_0_78_0">PowerToys version 0.78.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_81_0">PowerToys version 0.81.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_81_1">PowerToys version 0.81.1 or later</string>
<string id="SUPPORTED_POWERTOYS_0_82_0">PowerToys version 0.82.0 or later</string>

<string id="ConfigureGlobalUtilityEnabledStateDescription">This policy configures the enabled state for all PowerToys utilities.

Expand Down Expand Up @@ -137,6 +138,7 @@ If you disable this policy, the user won't be able to enable Enable paste with A
<string id="ConfigureEnabledUtilityEnvironmentVariables">Environment Variables: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFancyZones">FancyZones: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileLocksmith">File Locksmith: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileExplorerPreview">File Explorer add-ons: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileExplorerSVGPreview">SVG file preview: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileExplorerMarkdownPreview">Markdown file preview: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileExplorerMonacoPreview">Source code file preview: Configure enabled state</string>
Expand Down
111 changes: 63 additions & 48 deletions src/modules/previewpane/powerpreview/powerpreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ void PowerPreviewModule::enable()
}

m_enabled = true;

try
{
PowerToysSettings::PowerToyValues settings =
PowerToysSettings::PowerToyValues::load_from_settings_file(PowerPreviewModule::get_key());

apply_settings(settings);
}
catch (std::exception const& e)
{
Trace::InitSetErrorLoadingFile(e.what());
}
}

// Disable active preview handlers.
Expand Down Expand Up @@ -218,56 +230,59 @@ void PowerPreviewModule::apply_settings(const PowerToysSettings::PowerToyValues&
{
bool notifyShell = false;

for (auto& fileExplorerModule : m_fileExplorerModules)
if (m_enabled)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htcfreek
For point 5, I added a check that should prevent any preview handlers from running if the module is not enabled.

Copy link
Collaborator

@htcfreek htcfreek Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. But the policy state won't be written into the settings file. You have to explicit query the policy values and evaluate them.

Like here:

.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredSvgPreviewEnabledValue,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you shouldn't be able to bypass a force-enabled add-on by turning off all extensions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what about force disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of powerpreview.cpp now?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it does look good to me now.

{
const auto toggle = settings.get_bool_value(fileExplorerModule.settingName);
const auto gpo_rule = fileExplorerModule.checkModuleGPOEnabledRuleFunction();
const auto gpo_is_configured = gpo_rule == powertoys_gpo::gpo_rule_configured_enabled || gpo_rule == powertoys_gpo::gpo_rule_configured_disabled;

if (gpo_rule == powertoys_gpo::gpo_rule_configured_unavailable)
{
Logger::warn(L"Couldn't read the gpo rule for Power Preview module {}", fileExplorerModule.settingName);
}
if (gpo_rule == powertoys_gpo::gpo_rule_configured_wrong_value)
{
Logger::warn(L"gpo rule for Power Preview module {} is set to an unknown value", fileExplorerModule.settingName);
}

// Skip if no need to update
if (!toggle.has_value() && !gpo_is_configured)
{
continue;
}

bool module_new_state = false;
if (toggle.has_value())
{
module_new_state = *toggle;
}
if (gpo_is_configured)
{
// gpo rule overrides settings state
module_new_state = gpo_rule == powertoys_gpo::gpo_rule_configured_enabled;
}

// Skip if no need to update
if (module_new_state == fileExplorerModule.registryChanges.isApplied())
{
continue;
}

// (Un)Apply registry changes depending on the new setting value
const bool updated = module_new_state ? fileExplorerModule.registryChanges.apply() : fileExplorerModule.registryChanges.unApply();

if (updated)
{
notifyShell = true;
Trace::PowerPreviewSettingsUpdated(fileExplorerModule.settingName.c_str(), !*toggle, *toggle, true);
}
else
for (auto& fileExplorerModule : m_fileExplorerModules)
{
Logger::error(L"Couldn't {} file explorer module {} during apply_settings", *toggle ? L"enable " : L"disable", fileExplorerModule.settingName);
Trace::PowerPreviewSettingsUpdateFailed(fileExplorerModule.settingName.c_str(), !*toggle, *toggle, true);
const auto toggle = settings.get_bool_value(fileExplorerModule.settingName);
const auto gpo_rule = fileExplorerModule.checkModuleGPOEnabledRuleFunction();
const auto gpo_is_configured = gpo_rule == powertoys_gpo::gpo_rule_configured_enabled || gpo_rule == powertoys_gpo::gpo_rule_configured_disabled;

if (gpo_rule == powertoys_gpo::gpo_rule_configured_unavailable)
{
Logger::warn(L"Couldn't read the gpo rule for Power Preview module {}", fileExplorerModule.settingName);
}
if (gpo_rule == powertoys_gpo::gpo_rule_configured_wrong_value)
{
Logger::warn(L"gpo rule for Power Preview module {} is set to an unknown value", fileExplorerModule.settingName);
}

// Skip if no need to update
if (!toggle.has_value() && !gpo_is_configured)
{
continue;
}

bool module_new_state = false;
if (toggle.has_value())
{
module_new_state = *toggle;
}
if (gpo_is_configured)
{
// gpo rule overrides settings state
module_new_state = gpo_rule == powertoys_gpo::gpo_rule_configured_enabled;
}

// Skip if no need to update
if (module_new_state == fileExplorerModule.registryChanges.isApplied())
{
continue;
}

// (Un)Apply registry changes depending on the new setting value
const bool updated = module_new_state ? fileExplorerModule.registryChanges.apply() : fileExplorerModule.registryChanges.unApply();

if (updated)
{
notifyShell = true;
Trace::PowerPreviewSettingsUpdated(fileExplorerModule.settingName.c_str(), !*toggle, *toggle, true);
}
else
{
Logger::error(L"Couldn't {} file explorer module {} during apply_settings", *toggle ? L"enable " : L"disable", fileExplorerModule.settingName);
Trace::PowerPreviewSettingsUpdateFailed(fileExplorerModule.settingName.c_str(), !*toggle, *toggle, true);
}
}
}
if (notifyShell)
Expand Down
2 changes: 1 addition & 1 deletion src/settings-ui/Settings.UI.Library/EnabledModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public bool ImageResizer

private bool fileExplorerPreview = true;

[JsonPropertyName("File Explorer Preview")]
[JsonPropertyName("File Explorer")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change breake existing settings that users made?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property PowerPreview had no references in the source code before.

public bool PowerPreview
{
get => fileExplorerPreview;
Expand Down
7 changes: 6 additions & 1 deletion src/settings-ui/Settings.UI/Helpers/ModuleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Views;
using Windows.UI;

namespace Microsoft.PowerToys.Settings.UI.Helpers
{
Expand All @@ -22,6 +21,7 @@ public static string GetModuleLabelResourceName(ModuleType moduleType)
case ModuleType.MouseHighlighter:
case ModuleType.MouseJump:
case ModuleType.MousePointerCrosshairs: return $"MouseUtils_{moduleType}/Header";
case ModuleType.PowerPreview: return "FileExplorerPreview/ModuleTitle";
default: return $"{moduleType}/ModuleTitle";
}
}
Expand All @@ -36,6 +36,7 @@ public static string GetModuleTypeFluentIconName(ModuleType moduleType)
case ModuleType.MousePointerCrosshairs: return "ms-appx:///Assets/Settings/Icons/MouseCrosshairs.png";
case ModuleType.MeasureTool: return "ms-appx:///Assets/Settings/Icons/ScreenRuler.png";
case ModuleType.PowerLauncher: return $"ms-appx:///Assets/Settings/Icons/PowerToysRun.png";
case ModuleType.PowerPreview: return $"ms-appx:///Assets/Settings/Icons/FileExplorerPreview.png";
default: return $"ms-appx:///Assets/Settings/Icons/{moduleType}.png";
}
}
Expand All @@ -51,6 +52,7 @@ public static bool GetIsModuleEnabled(Library.GeneralSettings generalSettingsCon
case ModuleType.CropAndLock: return generalSettingsConfig.Enabled.CropAndLock;
case ModuleType.EnvironmentVariables: return generalSettingsConfig.Enabled.EnvironmentVariables;
case ModuleType.FancyZones: return generalSettingsConfig.Enabled.FancyZones;
case ModuleType.PowerPreview: return generalSettingsConfig.Enabled.PowerPreview;
case ModuleType.FileLocksmith: return generalSettingsConfig.Enabled.FileLocksmith;
case ModuleType.FindMyMouse: return generalSettingsConfig.Enabled.FindMyMouse;
case ModuleType.Hosts: return generalSettingsConfig.Enabled.Hosts;
Expand Down Expand Up @@ -83,6 +85,7 @@ internal static void SetIsModuleEnabled(GeneralSettings generalSettingsConfig, M
case ModuleType.CropAndLock: generalSettingsConfig.Enabled.CropAndLock = isEnabled; break;
case ModuleType.EnvironmentVariables: generalSettingsConfig.Enabled.EnvironmentVariables = isEnabled; break;
case ModuleType.FancyZones: generalSettingsConfig.Enabled.FancyZones = isEnabled; break;
case ModuleType.PowerPreview: generalSettingsConfig.Enabled.PowerPreview = isEnabled; break;
case ModuleType.FileLocksmith: generalSettingsConfig.Enabled.FileLocksmith = isEnabled; break;
case ModuleType.FindMyMouse: generalSettingsConfig.Enabled.FindMyMouse = isEnabled; break;
case ModuleType.Hosts: generalSettingsConfig.Enabled.Hosts = isEnabled; break;
Expand Down Expand Up @@ -114,6 +117,7 @@ public static GpoRuleConfigured GetModuleGpoConfiguration(ModuleType moduleType)
case ModuleType.CropAndLock: return GPOWrapper.GetConfiguredCropAndLockEnabledValue();
case ModuleType.EnvironmentVariables: return GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue();
case ModuleType.FancyZones: return GPOWrapper.GetConfiguredFancyZonesEnabledValue();
case ModuleType.PowerPreview: return GPOWrapper.GetConfiguredFileExplorerPreviewEnabledValue();
case ModuleType.FileLocksmith: return GPOWrapper.GetConfiguredFileLocksmithEnabledValue();
case ModuleType.FindMyMouse: return GPOWrapper.GetConfiguredFindMyMouseEnabledValue();
case ModuleType.Hosts: return GPOWrapper.GetConfiguredHostsFileEditorEnabledValue();
Expand Down Expand Up @@ -146,6 +150,7 @@ public static System.Type GetModulePageType(ModuleType moduleType)
ModuleType.CropAndLock => typeof(CropAndLockPage),
ModuleType.EnvironmentVariables => typeof(EnvironmentVariablesPage),
ModuleType.FancyZones => typeof(FancyZonesPage),
ModuleType.PowerPreview => typeof(PowerPreviewPage),
ModuleType.FileLocksmith => typeof(FileLocksmithPage),
ModuleType.FindMyMouse => typeof(MouseUtilsPage),
ModuleType.Hosts => typeof(HostsPage),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@
<controls:SettingsPageControl x:Uid="FileExplorerPreview" ModuleImageSource="ms-appx:///Assets/Settings/Modules/FileExplorerPreview.png">
<controls:SettingsPageControl.ModuleContent>
<StackPanel ChildrenTransitions="{StaticResource SettingsCardsAnimations}" Orientation="Vertical">
<controls:SettingsGroup x:Uid="FileExplorerPreview_PreviewPane">
<tkcontrols:SettingsCard
x:Uid="FileExplorerPreview_EnableToggleControl_HeaderText"
HeaderIcon="{ui:BitmapIcon Source=/Assets/Settings/Icons/FileExplorerPreview.png}"
IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.IsEnabled, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<InfoBar
x:Uid="GPO_SettingIsManaged"
IsClosable="False"
IsOpen="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay}"
IsTabStop="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay}"
Severity="Informational" />

<controls:SettingsGroup x:Uid="FileExplorerPreview_PreviewPane" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<InfoBar
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please hide all this info bars that are not related to the overall Module enabled GPO when the GPO is disabled. (We make it on the other pages the same.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The incompatibility warnings and the reboot required notice should be hidden when the GPO is set to Disabled?

Copy link
Contributor Author

@acekirkpatrick acekirkpatrick Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should I hide them whenever the switch is off regardless of GPO setting?

Copy link
Collaborator

@htcfreek htcfreek Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The incompatibility warnings and the reboot required notice should be hidden when the GPO is set to Disabled?

yes.

should I hide them whenever the switch is off regardless of GPO setting?

yes


You can implement a view model property "showInfobars" that is false if gpo is disabled or toggle is disabled (overall: if toggle is not enabled).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just used IsEnabled. Is that okay?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works as expected, yes. I didn't thought about this solution yet.

x:Uid="FileExplorerPreview_PreviewHandlerOutlookIncompatibility"
IsClosable="False"
Expand Down Expand Up @@ -147,7 +160,7 @@
</tkcontrols:SettingsCard>
</controls:SettingsGroup>

<controls:SettingsGroup x:Uid="FileExplorerPreview_IconThumbnail_GroupSettings">
<controls:SettingsGroup x:Uid="FileExplorerPreview_IconThumbnail_GroupSettings" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<InfoBar
x:Uid="FileExplorerPreview_RebootRequired"
IsClosable="False"
Expand Down
Loading
Loading