From 2a8b71a89c6fef3edeb2e6206384f057808d6e77 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 09:23:28 +0000 Subject: [PATCH] Add theme toggle support to all WebView2-based image panels Co-authored-by: emako <24737061+emako@users.noreply.github.com> --- .../Webview/Lottie/LottieImagePanel.cs | 4 ++++ .../Webview/Svg/SvgImagePanel.cs | 2 +- .../Webview/Svga/SvgaImagePanel.cs | 4 ++++ .../Webview/Tgs/TgsImagePanel.cs | 4 ++++ .../QuickLook.Plugin.ImageViewer/Webview/WebHandler.cs | 6 +++--- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Lottie/LottieImagePanel.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Lottie/LottieImagePanel.cs index 1c4aa2a..82d70bd 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Lottie/LottieImagePanel.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Lottie/LottieImagePanel.cs @@ -35,6 +35,10 @@ public class LottieImagePanel : SvgImagePanel ObjectForScripting ??= new ScriptHandler(path); _homePage = _resources["/lottie2html.html"]; + + // Update WebView2 background color based on current theme + UpdateWebViewBackgroundColor(); + NavigateToUri(new Uri("file://quicklook/")); } diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Svg/SvgImagePanel.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Svg/SvgImagePanel.cs index d90facd..8252bfa 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Svg/SvgImagePanel.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Svg/SvgImagePanel.cs @@ -126,7 +126,7 @@ public partial class SvgImagePanel : UserControl, IWebImagePanel UpdateWebViewBackgroundColor(); } - private void UpdateWebViewBackgroundColor() + protected void UpdateWebViewBackgroundColor() { if (_webView == null) return; diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Svga/SvgaImagePanel.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Svga/SvgaImagePanel.cs index 27e0857..ab4ccf6 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Svga/SvgaImagePanel.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Svga/SvgaImagePanel.cs @@ -34,6 +34,10 @@ public class SvgaImagePanel(IWebMetaProvider metaWeb) : SvgImagePanel() ObjectForScripting ??= new ScriptHandler(path, _metaWeb); _homePage = _resources["/svga2html.html"]; + + // Update WebView2 background color based on current theme + UpdateWebViewBackgroundColor(); + NavigateToUri(new Uri("file://quicklook/")); } } diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Tgs/TgsImagePanel.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Tgs/TgsImagePanel.cs index 10da24d..49d38ce 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Tgs/TgsImagePanel.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/Tgs/TgsImagePanel.cs @@ -35,6 +35,10 @@ public class TgsImagePanel : SvgImagePanel ObjectForScripting ??= new TgsScriptHandler(path); _homePage = _resources["/lottie2html.html"]; + + // Update WebView2 background color based on current theme + UpdateWebViewBackgroundColor(); + NavigateToUri(new Uri("file://quicklook/")); } diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/WebHandler.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/WebHandler.cs index c04978c..839dda9 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/WebHandler.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Webview/WebHandler.cs @@ -103,9 +103,9 @@ internal static class WebHandler ipWeb = ext switch { ".svg" => new SvgImagePanel() { ContextObject = context }, - ".svga" => new SvgaImagePanel(metaWeb), - ".lottie" or ".json" => new LottieImagePanel(), - ".tgs" => new TgsImagePanel(), + ".svga" => new SvgaImagePanel(metaWeb) { ContextObject = context }, + ".lottie" or ".json" => new LottieImagePanel() { ContextObject = context }, + ".tgs" => new TgsImagePanel() { ContextObject = context }, _ => throw new NotSupportedException($"Unsupported file type: {ext}") };