mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-05-16 01:08:03 +08:00
Add blocked file type handling to viewer
Updates the InsvBlocker plugin to mark files as blocked and sets a blocked message in the viewer window. The viewer now displays a message for blocked file types instead of attempting to preview them.
This commit is contained in:
+1
-1
Submodule QuickLook.Common updated: ffda8978fa...709f26fa38
@@ -45,31 +45,16 @@ public class Plugin : IViewer
|
|||||||
|
|
||||||
public void Prepare(string path, ContextObject context)
|
public void Prepare(string path, ContextObject context)
|
||||||
{
|
{
|
||||||
// Set a minimal window size (1x1 pixels) to make the window as small as possible
|
// Set Ignore to true to display "blocked" in the preview window
|
||||||
// This window will be closed immediately in View() before becoming visible
|
context.IsBlocked = true;
|
||||||
context.PreferredSize = new Size { Width = 1, Height = 1 };
|
context.Title = $"[BLOCKED] {Path.GetFileName(path)}";
|
||||||
|
context.PreferredSize = new Size(400, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void View(string path, ContextObject context)
|
public void View(string path, ContextObject context)
|
||||||
{
|
{
|
||||||
// Create an empty text block as content (required to avoid errors)
|
// This should not be called since Ignore is set to true in Prepare
|
||||||
var textBlock = new TextBlock
|
// But if called, do nothing
|
||||||
{
|
|
||||||
Text = "",
|
|
||||||
Visibility = Visibility.Collapsed
|
|
||||||
};
|
|
||||||
context.ViewerContent = textBlock;
|
|
||||||
context.IsBusy = false;
|
|
||||||
|
|
||||||
// Close the window immediately using Send priority for immediate execution
|
|
||||||
// This prevents the window from becoming visible to the user
|
|
||||||
Application.Current?.Dispatcher?.BeginInvoke(new Action(() =>
|
|
||||||
{
|
|
||||||
if (context.Source is Window window)
|
|
||||||
{
|
|
||||||
window.Close();
|
|
||||||
}
|
|
||||||
}), DispatcherPriority.Send);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cleanup()
|
public void Cleanup()
|
||||||
|
|||||||
@@ -201,6 +201,19 @@ public partial class ViewerWindow
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ContextObject.IsBlocked)
|
||||||
|
{
|
||||||
|
ContextObject.ViewerContent = new System.Windows.Controls.TextBlock
|
||||||
|
{
|
||||||
|
Text = "This file type is blocked.",
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Center,
|
||||||
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
FontSize = 14,
|
||||||
|
};
|
||||||
|
ContextObject.IsBusy = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetOpenWithButtonAndPath();
|
SetOpenWithButtonAndPath();
|
||||||
|
|
||||||
// Revert UI changes
|
// Revert UI changes
|
||||||
|
|||||||
Reference in New Issue
Block a user