From ef17dc5dccf3dece3503bbbd9679798f36c5e2db Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 8 Dec 2025 02:08:39 +0000
Subject: [PATCH 1/3] Initial plan
From 9a768b240181df1688d076c0358a6cdb7413ef60 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 8 Dec 2025 02:17:10 +0000
Subject: [PATCH 2/3] Add remember choice option for protected view notice
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
---
.../QuickLook.Plugin.OfficeViewer/Plugin.cs | 41 +++++++++----
.../ProtectedViewDialog.xaml | 60 +++++++++++++++++++
.../ProtectedViewDialog.xaml.cs | 45 ++++++++++++++
3 files changed, 133 insertions(+), 13 deletions(-)
create mode 100644 QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml
create mode 100644 QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml.cs
diff --git a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs
index 63e78971d..de8d32f3f 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs
@@ -108,19 +108,34 @@ 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 previously chosen to always unblock
+ var alwaysUnblock = SettingHelper.Get("AlwaysUnblockProtectedView", false, "QuickLook.Plugin.OfficeViewer");
+
+ bool shouldUnblock = alwaysUnblock;
+
+ if (!alwaysUnblock)
+ {
+ // Show dialog to ask user
+ var dialog = new ProtectedViewDialog();
+ var dialogResult = dialog.ShowDialog();
+
+ if (dialogResult == true)
+ {
+ shouldUnblock = true;
+
+ // Save preference if user checked "Remember my choice"
+ if (dialog.RememberChoice)
+ {
+ SettingHelper.Set("AlwaysUnblockProtectedView", true, "QuickLook.Plugin.OfficeViewer");
+ }
+ }
+ else
+ {
+ shouldUnblock = false;
+ }
+ }
+
+ 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?
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml.cs
new file mode 100644
index 000000000..b283e0dd8
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml.cs
@@ -0,0 +1,45 @@
+// Copyright © 2017-2025 QL-Win Contributors
+//
+// This file is part of QuickLook program.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using System.Windows;
+
+namespace QuickLook.Plugin.OfficeViewer;
+
+public partial class ProtectedViewDialog : Window
+{
+ public bool RememberChoice => RememberCheckBox.IsChecked ?? false;
+ public bool UserSelectedYes { get; private set; }
+
+ public ProtectedViewDialog()
+ {
+ InitializeComponent();
+ }
+
+ private void YesButton_Click(object sender, RoutedEventArgs e)
+ {
+ UserSelectedYes = true;
+ DialogResult = true;
+ Close();
+ }
+
+ private void NoButton_Click(object sender, RoutedEventArgs e)
+ {
+ UserSelectedYes = false;
+ DialogResult = false;
+ Close();
+ }
+}
From d91ef677f2ed7ed56638914666c72505731d1bfc Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 8 Dec 2025 02:21:31 +0000
Subject: [PATCH 3/3] Address code review feedback: improve logic and remove
redundant code
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
---
.../QuickLook.Plugin.OfficeViewer/Plugin.cs | 28 +++++++++----------
.../ProtectedViewDialog.xaml.cs | 1 -
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs
index de8d32f3f..0b271f249 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs
@@ -108,30 +108,28 @@ public void View(string path, ContextObject context)
{
context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}";
- // Check if user has previously chosen to always unblock
- var alwaysUnblock = SettingHelper.Get("AlwaysUnblockProtectedView", false, "QuickLook.Plugin.OfficeViewer");
+ // Check if user has a saved preference
+ var savedPreference = SettingHelper.Get("AlwaysUnblockProtectedView", null, "QuickLook.Plugin.OfficeViewer");
- bool shouldUnblock = alwaysUnblock;
+ bool shouldUnblock;
- if (!alwaysUnblock)
+ if (savedPreference.HasValue)
+ {
+ // Use saved preference
+ shouldUnblock = savedPreference.Value;
+ }
+ else
{
// Show dialog to ask user
var dialog = new ProtectedViewDialog();
var dialogResult = dialog.ShowDialog();
- if (dialogResult == true)
- {
- shouldUnblock = true;
+ shouldUnblock = dialogResult == true;
- // Save preference if user checked "Remember my choice"
- if (dialog.RememberChoice)
- {
- SettingHelper.Set("AlwaysUnblockProtectedView", true, "QuickLook.Plugin.OfficeViewer");
- }
- }
- else
+ // Save preference if user checked "Remember my choice"
+ if (dialog.RememberChoice)
{
- shouldUnblock = false;
+ SettingHelper.Set("AlwaysUnblockProtectedView", shouldUnblock, "QuickLook.Plugin.OfficeViewer");
}
}
diff --git a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml.cs
index b283e0dd8..387a000ba 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/ProtectedViewDialog.xaml.cs
@@ -38,7 +38,6 @@ private void YesButton_Click(object sender, RoutedEventArgs e)
private void NoButton_Click(object sender, RoutedEventArgs e)
{
- UserSelectedYes = false;
DialogResult = false;
Close();
}