diff --git a/src/common/GPOWrapper/GPOWrapper.cpp b/src/common/GPOWrapper/GPOWrapper.cpp index 62b5b49a9dae..d2d49fa6a4d7 100644 --- a/src/common/GPOWrapper/GPOWrapper.cpp +++ b/src/common/GPOWrapper/GPOWrapper.cpp @@ -188,6 +188,10 @@ namespace winrt::PowerToys::GPOWrapper::implementation { return static_cast(powertoys_gpo::getConfiguredWorkspacesEnabledValue()); } + GpoRuleConfigured GPOWrapper::GetConfiguredFileExplorerPreviewEnabledValue() + { + return static_cast(powertoys_gpo::getConfiguredFileExplorerPreviewEnabledValue()); + } GpoRuleConfigured GPOWrapper::GetConfiguredMwbClipboardSharingEnabledValue() { return static_cast(powertoys_gpo::getConfiguredMwbClipboardSharingEnabledValue()); diff --git a/src/common/GPOWrapper/GPOWrapper.h b/src/common/GPOWrapper/GPOWrapper.h index 0d7783883bbb..7f40136af60c 100644 --- a/src/common/GPOWrapper/GPOWrapper.h +++ b/src/common/GPOWrapper/GPOWrapper.h @@ -53,6 +53,7 @@ namespace winrt::PowerToys::GPOWrapper::implementation static GpoRuleConfigured GetAllowedAdvancedPasteOnlineAIModelsValue(); static GpoRuleConfigured GetConfiguredNewPlusEnabledValue(); static GpoRuleConfigured GetConfiguredWorkspacesEnabledValue(); + static GpoRuleConfigured GetConfiguredFileExplorerPreviewEnabledValue(); static GpoRuleConfigured GetConfiguredMwbClipboardSharingEnabledValue(); static GpoRuleConfigured GetConfiguredMwbFileTransferEnabledValue(); static GpoRuleConfigured GetConfiguredMwbUseOriginalUserInterfaceValue(); diff --git a/src/common/GPOWrapper/GPOWrapper.idl b/src/common/GPOWrapper/GPOWrapper.idl index 1e3c3a19f5ed..be22871fe3f6 100644 --- a/src/common/GPOWrapper/GPOWrapper.idl +++ b/src/common/GPOWrapper/GPOWrapper.idl @@ -57,6 +57,7 @@ namespace PowerToys static GpoRuleConfigured GetAllowedAdvancedPasteOnlineAIModelsValue(); static GpoRuleConfigured GetConfiguredNewPlusEnabledValue(); static GpoRuleConfigured GetConfiguredWorkspacesEnabledValue(); + static GpoRuleConfigured GetConfiguredFileExplorerPreviewEnabledValue(); static GpoRuleConfigured GetConfiguredMwbClipboardSharingEnabledValue(); static GpoRuleConfigured GetConfiguredMwbFileTransferEnabledValue(); static GpoRuleConfigured GetConfiguredMwbUseOriginalUserInterfaceValue(); diff --git a/src/common/ManagedCommon/ModuleType.cs b/src/common/ManagedCommon/ModuleType.cs index 65b00d4b5a9f..45a2f5ee7821 100644 --- a/src/common/ManagedCommon/ModuleType.cs +++ b/src/common/ManagedCommon/ModuleType.cs @@ -14,6 +14,7 @@ public enum ModuleType CropAndLock, EnvironmentVariables, FancyZones, + PowerPreview, FileLocksmith, FindMyMouse, Hosts, diff --git a/src/common/utils/gpo.h b/src/common/utils/gpo.h index 5d79fa3b016a..bc6ac9a2eb2f 100644 --- a/src/common/utils/gpo.h +++ b/src/common/utils/gpo.h @@ -65,6 +65,7 @@ namespace powertoys_gpo const std::wstring POLICY_CONFIGURE_ENABLED_QOI_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerQOIThumbnails"; const std::wstring POLICY_CONFIGURE_ENABLED_NEWPLUS = L"ConfigureEnabledUtilityNewPlus"; const std::wstring POLICY_CONFIGURE_ENABLED_WORKSPACES = L"ConfigureEnabledUtilityWorkspaces"; + 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"; @@ -305,47 +306,47 @@ namespace powertoys_gpo inline gpo_rule_configured_t getConfiguredSvgPreviewEnabledValue() { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_SVG_PREVIEW); + return getConfiguredValue(POLICY_CONFIGURE_ENABLED_SVG_PREVIEW); } inline gpo_rule_configured_t getConfiguredMarkdownPreviewEnabledValue() { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_MARKDOWN_PREVIEW); + return getConfiguredValue(POLICY_CONFIGURE_ENABLED_MARKDOWN_PREVIEW); } inline gpo_rule_configured_t getConfiguredMonacoPreviewEnabledValue() { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_MONACO_PREVIEW); + return getConfiguredValue(POLICY_CONFIGURE_ENABLED_MONACO_PREVIEW); } inline gpo_rule_configured_t getConfiguredPdfPreviewEnabledValue() { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_PDF_PREVIEW); + return getConfiguredValue(POLICY_CONFIGURE_ENABLED_PDF_PREVIEW); } inline gpo_rule_configured_t getConfiguredGcodePreviewEnabledValue() { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_GCODE_PREVIEW); + return getConfiguredValue(POLICY_CONFIGURE_ENABLED_GCODE_PREVIEW); } inline gpo_rule_configured_t getConfiguredSvgThumbnailsEnabledValue() { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_SVG_THUMBNAILS); + return getConfiguredValue(POLICY_CONFIGURE_ENABLED_SVG_THUMBNAILS); } inline gpo_rule_configured_t getConfiguredPdfThumbnailsEnabledValue() { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_PDF_THUMBNAILS); + return getConfiguredValue(POLICY_CONFIGURE_ENABLED_PDF_THUMBNAILS); } inline gpo_rule_configured_t getConfiguredGcodeThumbnailsEnabledValue() { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_GCODE_THUMBNAILS); + return getConfiguredValue(POLICY_CONFIGURE_ENABLED_GCODE_THUMBNAILS); } inline gpo_rule_configured_t getConfiguredStlThumbnailsEnabledValue() { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_STL_THUMBNAILS); + return getConfiguredValue(POLICY_CONFIGURE_ENABLED_STL_THUMBNAILS); } inline gpo_rule_configured_t getConfiguredHostsFileEditorEnabledValue() @@ -557,6 +558,10 @@ namespace powertoys_gpo return getConfiguredValue(POLICY_ALLOW_ADVANCED_PASTE_ONLINE_AI_MODELS); } + inline gpo_rule_configured_t getConfiguredFileExplorerPreviewEnabledValue() + { + return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_FILE_EXPLORER_PREVIEW); + } inline gpo_rule_configured_t getConfiguredMwbClipboardSharingEnabledValue() { return getConfiguredValue(POLICY_MWB_CLIPBOARD_SHARING_ENABLED); diff --git a/src/gpo/assets/PowerToys.admx b/src/gpo/assets/PowerToys.admx index 9bbd0d7ff382..eb331d228d2a 100644 --- a/src/gpo/assets/PowerToys.admx +++ b/src/gpo/assets/PowerToys.admx @@ -40,6 +40,9 @@ + + + @@ -167,8 +170,18 @@ - + + + + + + + + + + + @@ -177,8 +190,8 @@ - - + + @@ -187,8 +200,8 @@ - - + + @@ -197,8 +210,8 @@ - - + + @@ -207,8 +220,8 @@ - - + + @@ -217,8 +230,8 @@ - - + + @@ -227,8 +240,8 @@ - - + + @@ -237,8 +250,8 @@ - - + + @@ -247,8 +260,8 @@ - - + + @@ -257,8 +270,8 @@ - - + + @@ -267,8 +280,8 @@ - - + + diff --git a/src/gpo/assets/en-US/PowerToys.adml b/src/gpo/assets/en-US/PowerToys.adml index 95deba2bd68e..844478e6c234 100644 --- a/src/gpo/assets/en-US/PowerToys.adml +++ b/src/gpo/assets/en-US/PowerToys.adml @@ -10,6 +10,7 @@ Installer and Updates PowerToys Run Advanced Paste + File Explorer add-ons Mouse Without Borders General settings New+ @@ -56,15 +57,13 @@ If you don't configure this setting, users are able to enable or disable the uti This policy has a higher priority than the policy "Configure global utility enabled state" and overrides it. - (Note: There have been reports of incompatibility between the PDF Preview Handler and Outlook) + This policy configures the enabled state for a PowerToys utility. -This policy configures the enabled state for a PowerToys utility. +If you enable this setting, the utility will be always enabled and the user won't be able to disable it. They can still disable individual add-ons. -If you enable this setting, the utility will be always enabled and the user won't be able to disable it. +If you disable this setting, the utility will be always disabled and the user won't be able to enable it or any individual add-ons. -If you disable this setting, the utility will be always disabled and the user won't be able to enable it. - -If you don't configure this setting, users are able to enable or disable the utility. +If you don't configure this setting, users are able to enable or disable the utility and any individual add-ons. This policy has a higher priority than the policy "Configure global utility enabled state" and overrides it. @@ -154,6 +153,28 @@ Note: Changes require a restart of PowerToys Run. If you enable or don't configure this policy, the user takes control over the enabled state of the Enable paste with AI Advanced Paste setting. If you disable this policy, the user won't be able to enable Enable paste with AI Advanced Paste setting and use Advanced Paste AI prompt nor set up the Open AI key in PowerToys Settings. + + This policy configures the enabled state for a File Explorer add-on. + +If you enable this setting, the add-on will be always enabled and the user won't be able to disable it. + +If you disable this setting, the add-on will be always disabled and the user won't be able to enable it. + +If you don't configure this setting, users are able to enable or disable the add-on. + +Note: If you disable the policy "File Explorer add-ons: Configure enabled state" all File Explorer Add-ons are disabled. + + (Note: There have been reports of incompatibility between the PDF Preview Handler and Outlook) + +This policy configures the enabled state for a File Explorer add-on. + +If you enable this setting, the add-on will be always enabled and the user won't be able to disable it. + +If you disable this setting, the add-on will be always disabled and the user won't be able to enable it. + +If you don't configure this setting, users are able to enable or disable the add-on. + +Note: If you disable the policy "File Explorer add-ons: Configure enabled state" all File Explorer Add-ons are disabled. This policy configures if the user can share the clipboard between machines. @@ -248,6 +269,7 @@ If you don't configure this policy, the user will be able to control the setting Environment Variables: Configure enabled state FancyZones: Configure enabled state File Locksmith: Configure enabled state + File Explorer add-ons: Configure enabled state SVG file preview: Configure enabled state Markdown file preview: Configure enabled state Source code file preview: Configure enabled state @@ -257,6 +279,8 @@ If you don't configure this policy, the user will be able to control the setting PDF file thumbnail: Configure enabled state Gcode file thumbnail: Configure enabled state STL file thumbnail: Configure enabled state + QOI file preview: Configure enabled state + QOI file thumbnail: Configure enabled state Hosts file editor: Configure enabled state Image Resizer: Configure enabled state Keyboard Manager: Configure enabled state @@ -285,8 +309,6 @@ If you don't configure this policy, the user will be able to control the setting Allow Experimentation Configure enabled state for all plugins Configure enabled state for individual plugins - QOI file preview: Configure enabled state - QOI file thumbnail: Configure enabled state Allow using online AI models Clipboard sharing enabled File transfer enabled diff --git a/src/modules/previewpane/powerpreview/powerpreview.cpp b/src/modules/previewpane/powerpreview/powerpreview.cpp index 84d2a590dc3a..6f57a3da8cf6 100644 --- a/src/modules/previewpane/powerpreview/powerpreview.cpp +++ b/src/modules/previewpane/powerpreview/powerpreview.cpp @@ -165,25 +165,41 @@ 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. void PowerPreviewModule::disable() { - for (auto& fileExplorerModule : m_fileExplorerModules) - { - if (!fileExplorerModule.registryChanges.unApply()) - { - Logger::error(L"Couldn't disable file explorer module {} during module disable() call", fileExplorerModule.settingName); - } - } - if (m_enabled) { Trace::EnabledPowerPreview(false); } m_enabled = false; + + 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()); + } } // Returns if the powertoys is enabled @@ -217,6 +233,20 @@ void PowerPreviewModule::apply_settings(const PowerToysSettings::PowerToyValues& { bool notifyShell = false; + // check gpo for Power Preview module + const auto enabled_gpo_rule = powertoys_gpo::getConfiguredFileExplorerPreviewEnabledValue(); + const auto enabled_gpo_is_configured = enabled_gpo_rule == powertoys_gpo::gpo_rule_configured_enabled || enabled_gpo_rule == powertoys_gpo::gpo_rule_configured_disabled; + const auto is_enabled = enabled_gpo_is_configured ? enabled_gpo_rule == powertoys_gpo::gpo_rule_configured_enabled : m_enabled; + + if (enabled_gpo_rule == powertoys_gpo::gpo_rule_configured_unavailable) + { + Logger::warn(L"Couldn't read the gpo rule for Power Preview"); + } + if (enabled_gpo_rule == powertoys_gpo::gpo_rule_configured_wrong_value) + { + Logger::warn(L"gpo rule for Power Preview is set to an unknown value"); + } + for (auto& fileExplorerModule : m_fileExplorerModules) { const auto toggle = settings.get_bool_value(fileExplorerModule.settingName); @@ -249,6 +279,9 @@ void PowerPreviewModule::apply_settings(const PowerToysSettings::PowerToyValues& module_new_state = gpo_rule == powertoys_gpo::gpo_rule_configured_enabled; } + //Don't start previewer if the File Explorer module is disabled + module_new_state = module_new_state && is_enabled; + // Skip if no need to update if (module_new_state == fileExplorerModule.registryChanges.isApplied()) { diff --git a/src/settings-ui/Settings.UI.Library/EnabledModules.cs b/src/settings-ui/Settings.UI.Library/EnabledModules.cs index 0e0556d44276..2adf9d17f79c 100644 --- a/src/settings-ui/Settings.UI.Library/EnabledModules.cs +++ b/src/settings-ui/Settings.UI.Library/EnabledModules.cs @@ -57,7 +57,7 @@ public bool ImageResizer private bool fileExplorerPreview = true; - [JsonPropertyName("File Explorer Preview")] + [JsonPropertyName("File Explorer")] public bool PowerPreview { get => fileExplorerPreview; diff --git a/src/settings-ui/Settings.UI/Helpers/ModuleHelper.cs b/src/settings-ui/Settings.UI/Helpers/ModuleHelper.cs index f21ca2bfac8e..871bc4d0e2da 100644 --- a/src/settings-ui/Settings.UI/Helpers/ModuleHelper.cs +++ b/src/settings-ui/Settings.UI/Helpers/ModuleHelper.cs @@ -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 { @@ -23,6 +22,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_DashboardTitle"; default: return $"{moduleType}/ModuleTitle"; } } @@ -38,6 +38,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"; } } @@ -54,6 +55,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; @@ -90,6 +92,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; @@ -125,6 +128,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(); @@ -161,6 +165,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), diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml index 489a1a8b7d0a..b092ea0d5ac9 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml @@ -13,12 +13,25 @@ - + + + + + + - + - /// An empty page that can be used on its own or navigated to within a Frame. - /// - public sealed partial class PowerPreviewPage : Page + public sealed partial class PowerPreviewPage : Page, IRefreshablePage { public PowerPreviewViewModel ViewModel { get; set; } @@ -22,5 +20,10 @@ public PowerPreviewPage() ViewModel = new PowerPreviewViewModel(SettingsRepository.GetInstance(settingsUtils), SettingsRepository.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage); DataContext = ViewModel; } + + public void RefreshEnabledState() + { + ViewModel.RefreshEnabledState(); + } } } diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw index a95cdb86cd18..082ef9f7ff15 100644 --- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw @@ -4371,6 +4371,15 @@ Activate by holding the key for the character you want to add an accent to, then If you do not have credits you will see an 'API key quota exceeded' error + + Enable File Explorer add-ons + + + Custom preview handlers for Windows File Explorer + + + File Explorer add-ons + Automatically close the AdvancedPaste window after it loses focus AdvancedPaste is a product name, do not loc diff --git a/src/settings-ui/Settings.UI/ViewModels/DashboardViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/DashboardViewModel.cs index bc40b5b1cb21..6ec0411f3786 100644 --- a/src/settings-ui/Settings.UI/ViewModels/DashboardViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/DashboardViewModel.cs @@ -178,6 +178,7 @@ private ObservableCollection GetModuleItems(ModuleType modu ModuleType.CropAndLock => GetModuleItemsCropAndLock(), ModuleType.EnvironmentVariables => GetModuleItemsEnvironmentVariables(), ModuleType.FancyZones => GetModuleItemsFancyZones(), + ModuleType.PowerPreview => GetModuleItemsPowerPreview(), ModuleType.FileLocksmith => GetModuleItemsFileLocksmith(), ModuleType.FindMyMouse => GetModuleItemsFindMyMouse(), ModuleType.Hosts => GetModuleItemsHosts(), @@ -535,6 +536,15 @@ private ObservableCollection GetModuleItemsNewPlus() return new ObservableCollection(list); } + private ObservableCollection GetModuleItemsPowerPreview() + { + var list = new List + { + new DashboardModuleTextItem() { Label = resourceLoader.GetString("FileExplorerPreview_ShortDescription") }, + }; + return new ObservableCollection(list); + } + private ObservableCollection GetModuleItemsZoomIt() { var list = new List diff --git a/src/settings-ui/Settings.UI/ViewModels/PowerPreviewViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/PowerPreviewViewModel.cs index 86089a2d5df4..c9c66e739aba 100644 --- a/src/settings-ui/Settings.UI/ViewModels/PowerPreviewViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/PowerPreviewViewModel.cs @@ -210,8 +210,35 @@ public PowerPreviewViewModel(ISettingsRepository moduleSet { _qoiThumbnailIsEnabled = Settings.Properties.EnableQoiThumbnail; } + + InitializeEnabledValue(); + } + + private void InitializeEnabledValue() + { + _enabledGpoRuleConfiguration = GPOWrapper.GetConfiguredFileExplorerPreviewEnabledValue(); + if (_enabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _enabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) + { + // Get the enabled state from GPO. + _enabledStateIsGPOConfigured = true; + _isEnabled = _enabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; + } + else + { + _isEnabled = GeneralSettingsConfig.Enabled.PowerPreview; + } + } + + public void RefreshEnabledState() + { + InitializeEnabledValue(); + OnPropertyChanged(nameof(IsEnabled)); } + private GpoRuleConfigured _enabledGpoRuleConfiguration; + private bool _enabledStateIsGPOConfigured; + private bool _isEnabled; + private GpoRuleConfigured _svgRenderEnabledGpoRuleConfiguration; private bool _svgRenderEnabledStateIsGPOConfigured; private bool _svgRenderIsGpoEnabled; @@ -288,13 +315,45 @@ public PowerPreviewViewModel(ISettingsRepository moduleSet private bool _qoiThumbnailIsGpoDisabled; private bool _qoiThumbnailIsEnabled; + public bool IsEnabled + { + get => _isEnabled; + set + { + if (_enabledStateIsGPOConfigured) + { + // If it's GPO configured, shouldn't be able to change this state. + return; + } + + if (_isEnabled != value) + { + _isEnabled = value; + OnPropertyChanged(nameof(IsEnabled)); + OnPropertyChanged(nameof(SomePreviewPaneEnabledGposConfigured)); + OnPropertyChanged(nameof(SomeThumbnailEnabledGposConfigured)); + + // Set the status in the general settings + GeneralSettingsConfig.Enabled.PowerPreview = value; + var outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig); + + SendConfigMSG(outgoing.ToString()); + } + } + } + + public bool IsEnabledGpoConfigured + { + get => _enabledStateIsGPOConfigured; + } + public bool SomePreviewPaneEnabledGposConfigured { get { - return _svgRenderEnabledStateIsGPOConfigured || _mdRenderEnabledStateIsGPOConfigured + return IsEnabled && (_svgRenderEnabledStateIsGPOConfigured || _mdRenderEnabledStateIsGPOConfigured || _monacoRenderEnabledStateIsGPOConfigured || _pdfRenderEnabledStateIsGPOConfigured - || _gcodeRenderEnabledStateIsGPOConfigured || _qoiRenderEnabledStateIsGPOConfigured; + || _gcodeRenderEnabledStateIsGPOConfigured || _qoiRenderEnabledStateIsGPOConfigured); } } @@ -302,9 +361,9 @@ public bool SomeThumbnailEnabledGposConfigured { get { - return _svgThumbnailEnabledStateIsGPOConfigured || _pdfThumbnailEnabledStateIsGPOConfigured + return IsEnabled && (_svgThumbnailEnabledStateIsGPOConfigured || _pdfThumbnailEnabledStateIsGPOConfigured || _gcodeThumbnailEnabledStateIsGPOConfigured || _stlThumbnailEnabledStateIsGPOConfigured - || _qoiThumbnailEnabledStateIsGPOConfigured; + || _qoiThumbnailEnabledStateIsGPOConfigured); } } diff --git a/tools/BugReportTool/BugReportTool/ReportGPOValues.cpp b/tools/BugReportTool/BugReportTool/ReportGPOValues.cpp index 02e04a2c5e5b..c86d7ec4d628 100644 --- a/tools/BugReportTool/BugReportTool/ReportGPOValues.cpp +++ b/tools/BugReportTool/BugReportTool/ReportGPOValues.cpp @@ -84,6 +84,7 @@ void ReportGPOValues(const std::filesystem::path &tmpDir) report << "getConfiguredQoiPreviewEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredQoiPreviewEnabledValue()) << std::endl; report << "getConfiguredQoiThumbnailsEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredQoiThumbnailsEnabledValue()) << std::endl; report << "getAllowedAdvancedPasteOnlineAIModelsValue: " << gpo_rule_configured_to_string(powertoys_gpo::getAllowedAdvancedPasteOnlineAIModelsValue()) << std::endl; + report << "getConfiguredFileExplorerPreviewEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredFileExplorerPreviewEnabledValue()) << std::endl; report << "getConfiguredMwbClipboardSharingEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbClipboardSharingEnabledValue()) << std::endl; report << "getConfiguredMwbFileTransferEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbFileTransferEnabledValue()) << std::endl; report << "getConfiguredMwbUseOriginalUserInterfaceValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbUseOriginalUserInterfaceValue()) << std::endl;