Support password-protected PDF #155 #765

QL will display a UI prompting for a password. Upon entering the correct password, the PDF file will be reopened.
This commit is contained in:
ema
2024-12-13 11:23:57 +08:00
parent d09e9c48d8
commit cb59a3d082
7 changed files with 225 additions and 13 deletions

View File

@@ -0,0 +1,55 @@
<UserControl x:Class="QuickLook.Plugin.PDFViewer.PasswordControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:QuickLook.Plugin.PDFViewer"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid>
<Border HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="{DynamicResource CardBackground}"
BorderBrush="{DynamicResource CardBorderBrush}"
BorderThickness="1"
CornerRadius="5">
<Grid Margin="24">
<StackPanel>
<TextBlock x:Name="titleTextBlock"
FontSize="18"
FontWeight="DemiBold"
Text="Enter Password" />
<TextBlock x:Name="hintTextBlock"
Margin="0,20,0,0"
Text="This file is password protected. Please enter the password to open the file." />
<PasswordBox x:Name="passwordBox"
MinWidth="400"
Margin="0,16,0,0" />
<TextBlock x:Name="passwordErrorTextBlock"
MinWidth="400"
Margin="0,16,0,0"
Foreground="Red"
Text="Check your password"
Visibility="Collapsed" />
<Grid MinWidth="400" Margin="0,16,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button x:Name="openFileButton"
Grid.Column="0"
Margin="0,0,4,0"
HorizontalAlignment="Stretch"
Content="Open File" />
<Button x:Name="cancelButton"
Grid.Column="1"
Margin="4,0,0,0"
HorizontalAlignment="Stretch"
Content="Cancel" />
</Grid>
</StackPanel>
</Grid>
</Border>
</Grid>
</UserControl>