diff --git a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs index 63e78971d..0b271f249 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs @@ -108,19 +108,32 @@ public void View(string path, ContextObject context) { context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}"; - MessageBoxResult result = MessageBox.Show( - """ - Be careful - files from the Internet can contain viruses. - The Office interface prevents loading in Protected View. - - Would you like OfficeViewer-Native to unblock the ZoneIdentifier of Internet? - """, - "PROTECTED VIEW", - MessageBoxButton.YesNo, - MessageBoxImage.Question - ); - - if (result == MessageBoxResult.Yes) + // Check if user has a saved preference + var savedPreference = SettingHelper.Get("AlwaysUnblockProtectedView", null, "QuickLook.Plugin.OfficeViewer"); + + bool shouldUnblock; + + if (savedPreference.HasValue) + { + // Use saved preference + shouldUnblock = savedPreference.Value; + } + else + { + // Show dialog to ask user + var dialog = new ProtectedViewDialog(); + var dialogResult = dialog.ShowDialog(); + + shouldUnblock = dialogResult == true; + + // Save preference if user checked "Remember my choice" + if (dialog.RememberChoice) + { + SettingHelper.Set("AlwaysUnblockProtectedView", shouldUnblock, "QuickLook.Plugin.OfficeViewer"); + } + } + + if (shouldUnblock) { _ = ZoneIdentifierManager.UnblockZone(path); } diff --git a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml new file mode 100644 index 000000000..41789c66c --- /dev/null +++ b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + Be careful - files from the Internet can contain viruses. + + + + The Office interface prevents loading in Protected View. + + + + Would you like OfficeViewer-Native to unblock the ZoneIdentifier of Internet? + + + + + + +