mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-01-29 02:06:48 +08:00
Add theme toggle support to all WebView2-based image panels
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:
@@ -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/"));
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public partial class SvgImagePanel : UserControl, IWebImagePanel
|
||||
UpdateWebViewBackgroundColor();
|
||||
}
|
||||
|
||||
private void UpdateWebViewBackgroundColor()
|
||||
protected void UpdateWebViewBackgroundColor()
|
||||
{
|
||||
if (_webView == null) return;
|
||||
|
||||
|
||||
@@ -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/"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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}")
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user