mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-05-10 02:06:42 +08:00
Add setting to auto-unblock Protected View #1832
Introduce an "AlwaysUnblockProtectedView" setting (default: false, scope: QuickLook.Plugin.OfficeViewer) and use it to skip the confirmation dialog and automatically unblock the ZoneIdentifier for internet-downloaded files. If the setting is false, preserve the existing prompt flow and keep the previous behavior of showing a warning and only unblocking on user confirmation.
This commit is contained in:
@@ -107,34 +107,42 @@ public sealed class Plugin : IViewer
|
||||
if (ZoneIdentifierManager.IsZoneBlocked(path))
|
||||
{
|
||||
context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}";
|
||||
var alwaysUnblockProtectedView = SettingHelper.Get("AlwaysUnblockProtectedView", false, "QuickLook.Plugin.OfficeViewer");
|
||||
|
||||
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)
|
||||
if (alwaysUnblockProtectedView)
|
||||
{
|
||||
_ = ZoneIdentifierManager.UnblockZone(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.ViewerContent = new Label()
|
||||
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)
|
||||
{
|
||||
Content = "The Office interface prevents loading in Protected View.",
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
};
|
||||
context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}";
|
||||
context.IsBusy = false;
|
||||
return;
|
||||
_ = ZoneIdentifierManager.UnblockZone(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.ViewerContent = new Label()
|
||||
{
|
||||
Content = "The Office interface prevents loading in Protected View.",
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
};
|
||||
context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}";
|
||||
context.IsBusy = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user