From 2229c1691a44219664898790ab911eac883a5d60 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 00:24:21 +0800 Subject: [PATCH] Align Acrylic10 tint behavior with official dark/light acrylic palette (#1915) * Initial plan * Align Acrylic10 tint color and opacity with official dark/light values Agent-Logs-Url: https://github.com/QL-Win/QuickLook/sessions/7856deeb-578c-4683-879b-e2d924eb4224 Co-authored-by: emako <24737061+emako@users.noreply.github.com> * Refine Acrylic10 constants for tint palette and opacity Agent-Logs-Url: https://github.com/QL-Win/QuickLook/sessions/7856deeb-578c-4683-879b-e2d924eb4224 Co-authored-by: emako <24737061+emako@users.noreply.github.com> * Narrow color parsing exception handling in ViewerWindow Agent-Logs-Url: https://github.com/QL-Win/QuickLook/sessions/7856deeb-578c-4683-879b-e2d924eb4224 Co-authored-by: emako <24737061+emako@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: emako <24737061+emako@users.noreply.github.com> --- QuickLook.Common/Helpers/WindowHelper.cs | 4 +-- QuickLook/ViewerWindow.xaml.cs | 31 +++++++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/QuickLook.Common/Helpers/WindowHelper.cs b/QuickLook.Common/Helpers/WindowHelper.cs index 2c13af1..f9475f7 100644 --- a/QuickLook.Common/Helpers/WindowHelper.cs +++ b/QuickLook.Common/Helpers/WindowHelper.cs @@ -168,7 +168,7 @@ public static class WindowHelper Marshal.FreeHGlobal(accentPtr); } - public static void EnableAcrylicBlur(Window window, Color tintColor, bool isDarkTheme) + public static void EnableAcrylicBlur(Window window, Color tintColor, bool isDarkTheme, double tintOpacity = 0.8) { window.Background = Brushes.Transparent; @@ -193,7 +193,7 @@ public static class WindowHelper var accent = new AccentPolicy(); var accentStructSize = Marshal.SizeOf(accent); accent.AccentState = AccentState.AccentEnableAcrylicblurbehind; - accent.GradientColor = ToAbgr(tintColor, 0.8); + accent.GradientColor = ToAbgr(tintColor, tintOpacity); var accentPtr = Marshal.AllocHGlobal(accentStructSize); Marshal.StructureToPtr(accent, accentPtr, false); diff --git a/QuickLook/ViewerWindow.xaml.cs b/QuickLook/ViewerWindow.xaml.cs index bd96dec..44b4d01 100644 --- a/QuickLook/ViewerWindow.xaml.cs +++ b/QuickLook/ViewerWindow.xaml.cs @@ -41,6 +41,10 @@ namespace QuickLook; public partial class ViewerWindow : Window { + private const double Acrylic10TintOpacity = 0.7; + private static readonly Color Acrylic10DarkTintColor = Color.FromRgb(0x17, 0x17, 0x17); + private static readonly Color Acrylic10LightTintColor = Color.FromRgb(0xF2, 0xF2, 0xF2); + private Size _customWindowSize = Size.Empty; private bool _ignoreNextWindowSizeChange; private string _path = string.Empty; @@ -204,7 +208,7 @@ public partial class ViewerWindow : Window { Background = (Brush)new BrushConverter().ConvertFromString(customColor); } - catch + catch (Exception ex) when (ex is FormatException || ex is NotSupportedException) { // Ignore invalid color } @@ -279,11 +283,11 @@ public partial class ViewerWindow : Window case SystembackdropType.Acrylic10: if (App.IsWin10 || App.IsWin11) { - var acrylicTint = GetAcrylicTintColor(); + var acrylicTint = GetAcrylic10TintColor(); WindowChrome.GetWindowChrome(this)?.GlassFrameThickness = new Thickness(0d); WindowHelper.DisableDwmBlur(this); // Restore rounded corners on Windows 11 - WindowHelper.EnableAcrylicBlur(this, acrylicTint, CurrentTheme == Themes.Dark); + WindowHelper.EnableAcrylicBlur(this, acrylicTint, CurrentTheme == Themes.Dark, Acrylic10TintOpacity); Background = Brushes.Transparent; } else @@ -356,7 +360,7 @@ public partial class ViewerWindow : Window { return ((SolidColorBrush)new BrushConverter().ConvertFromString(customColor)).Color; } - catch + catch (Exception ex) when (ex is FormatException || ex is NotSupportedException) { // Ignore invalid color } @@ -365,6 +369,25 @@ public partial class ViewerWindow : Window return ((SolidColorBrush)FindResource("MainWindowBackground")).Color; } + private Color GetAcrylic10TintColor() + { + var customColor = SettingHelper.Get("WindowBackgroundColor", string.Empty, "QuickLook"); + + if (!string.IsNullOrEmpty(customColor)) + { + try + { + return ((SolidColorBrush)new BrushConverter().ConvertFromString(customColor)).Color; + } + catch (Exception ex) when (ex is FormatException || ex is NotSupportedException) + { + // Ignore invalid color + } + } + + return CurrentTheme == Themes.Dark ? Acrylic10DarkTintColor : Acrylic10LightTintColor; + } + private static SystembackdropType GetBackdropOption() { var option = SettingHelper.Get("WindowBackdrop", nameof(SystembackdropType.Auto), "QuickLook")?.Trim();