mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-12-12 02:00:27 +08:00
Compare commits
4 Commits
copilot/ad
...
copilot/pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d91ef677f2 | ||
|
|
9a768b2401 | ||
|
|
ef17dc5dcc | ||
|
|
7211c2ebdd |
@@ -108,19 +108,32 @@ public class Plugin : IViewer
|
||||
{
|
||||
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.
|
||||
// Check if user has a saved preference
|
||||
var savedPreference = SettingHelper.Get<bool?>("AlwaysUnblockProtectedView", null, "QuickLook.Plugin.OfficeViewer");
|
||||
|
||||
Would you like OfficeViewer-Native to unblock the ZoneIdentifier of Internet?
|
||||
""",
|
||||
"PROTECTED VIEW",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question
|
||||
);
|
||||
bool shouldUnblock;
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<Window x:Class="QuickLook.Plugin.OfficeViewer.ProtectedViewDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="PROTECTED VIEW"
|
||||
Width="500"
|
||||
Height="250"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False">
|
||||
<Grid Margin="20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
TextWrapping="Wrap"
|
||||
FontSize="14"
|
||||
Margin="0,0,0,10">
|
||||
<Run FontWeight="Bold">Be careful - files from the Internet can contain viruses.</Run>
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
TextWrapping="Wrap"
|
||||
Margin="0,0,0,10">
|
||||
The Office interface prevents loading in Protected View.
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="2"
|
||||
TextWrapping="Wrap"
|
||||
Margin="0,0,0,20">
|
||||
Would you like OfficeViewer-Native to unblock the ZoneIdentifier of Internet?
|
||||
</TextBlock>
|
||||
|
||||
<StackPanel Grid.Row="3">
|
||||
<CheckBox x:Name="RememberCheckBox"
|
||||
Content="Remember my choice"
|
||||
Margin="0,0,0,15" />
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
<Button x:Name="YesButton"
|
||||
Content="Yes"
|
||||
Width="80"
|
||||
Height="30"
|
||||
Margin="0,0,10,0"
|
||||
IsDefault="True"
|
||||
Click="YesButton_Click" />
|
||||
<Button x:Name="NoButton"
|
||||
Content="No"
|
||||
Width="80"
|
||||
Height="30"
|
||||
IsCancel="True"
|
||||
Click="NoButton_Click" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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)
|
||||
{
|
||||
DialogResult = false;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@
|
||||
<Key word="workflow"/>
|
||||
</KeyWords>
|
||||
|
||||
<KeyWords name="Keywords2" color="Purple" bold="false" italic="false">
|
||||
<KeyWords name="Keywords2" color="#D8A0DF" bold="false" italic="false">
|
||||
<Key word="Add-Computer"/>
|
||||
<Key word="Add-Content"/>
|
||||
<Key word="Add-History"/>
|
||||
@@ -439,7 +439,7 @@
|
||||
<Key word="Write-Zip"/>
|
||||
</KeyWords>
|
||||
|
||||
<KeyWords name="Keywords3" color="Teal" bold="false" italic="false">
|
||||
<KeyWords name="Keywords3" color="#80CBC4" bold="false" italic="false">
|
||||
<Key word="ac"/>
|
||||
<Key word="asnp"/>
|
||||
<Key word="cat"/>
|
||||
|
||||
Reference in New Issue
Block a user