From 236ce03fff0e6dc921f80281c8c9ed1f8ef36be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Thu, 9 Jan 2025 23:17:47 +0800 Subject: [PATCH] . --- cpp/winsharedutils/AreoAcrylic.cpp | 37 ++++++++++++++--------------- py/LunaTranslator/LunaTranslator.py | 4 +--- py/files/LunaTranslator_qss | 2 +- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/cpp/winsharedutils/AreoAcrylic.cpp b/cpp/winsharedutils/AreoAcrylic.cpp index 086c6674..14d12793 100644 --- a/cpp/winsharedutils/AreoAcrylic.cpp +++ b/cpp/winsharedutils/AreoAcrylic.cpp @@ -144,13 +144,22 @@ DECLARE_API bool clearEffect(HWND hwnd) } uint32_t GetOSversion() noexcept; -DECLARE_API bool setbackdropX(HWND hwnd, bool corner, bool dark) +DECLARE_API bool setbackdropX(HWND hwnd, bool good, bool dark) { #ifndef WINXP if (GetOSversion() <= 6) return false; - ACCENT_POLICY accent; - accent.AccentState = ACCENT_ENABLE_ACRYLICBLURBEHIND; + + DWORD corner_ = good ? 2 : 0; + DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_, sizeof(corner_)); + + common if (!good) + { + + accentPolicy.AccentState = ACCENT_DISABLED; + return setWindowCompositionAttribute(hwnd, &winCompAttrData); + } + accentPolicy.AccentState = ACCENT_ENABLE_ACRYLICBLURBEHIND; CRegKey key; if (ERROR_SUCCESS != key.Open(HKEY_CURRENT_USER, LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent)")) @@ -159,27 +168,17 @@ DECLARE_API bool setbackdropX(HWND hwnd, bool corner, bool dark) if (ERROR_SUCCESS != key.QueryDWORDValue(L"AccentColorMenu", accent_int)) return false; if (dark) - accent.GradientColor = 0x40212121; + accentPolicy.GradientColor = 0x40212121; else - accent.GradientColor = 0x40f7f7fa; - WINDOWCOMPOSITIONATTRIBDATA data; - data.Attrib = WCA_ACCENT_POLICY; - data.cbData = sizeof(accent); - data.pvData = &accent; - auto setWindowCompositionAttribute = (pfnSetWindowCompositionAttribute)GetProcAddress(GetModuleHandle(L"user32.dll"), "SetWindowCompositionAttribute"); - if (!setWindowCompositionAttribute) - return false; - setWindowCompositionAttribute(hwnd, &data); + accentPolicy.GradientColor = 0x40f7f7fa; + setWindowCompositionAttribute(hwnd, &winCompAttrData); if (dark) { - data.Attrib = WCA_USEDARKMODECOLORS; - setWindowCompositionAttribute(hwnd, &data); + winCompAttrData.Attrib = WCA_USEDARKMODECOLORS; + setWindowCompositionAttribute(hwnd, &winCompAttrData); } - DWORD corner_ = corner ? 2 : 0; - DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_, sizeof(corner_)); - - return true; #endif + return true; } \ No newline at end of file diff --git a/py/LunaTranslator/LunaTranslator.py b/py/LunaTranslator/LunaTranslator.py index cf0a45b3..82a23cc0 100644 --- a/py/LunaTranslator/LunaTranslator.py +++ b/py/LunaTranslator/LunaTranslator.py @@ -970,9 +970,7 @@ class MAINUI: if ismenulist: darklight = ["light", "dark"][self.currentisdark] name = globalconfig[darklight + "theme2"] - if name == "QTWin11": - # 这个东西会导致其他主题看起来很怪,而且没办法撤销 - winsharedutils.setbackdropX(int(widget.winId()), True, dark) + winsharedutils.setbackdropX(int(widget.winId()), name == "QTWin11", dark) @threader def clickwordcallback(self, word, append=False): diff --git a/py/files/LunaTranslator_qss b/py/files/LunaTranslator_qss index 0ccbf59b..82812f01 160000 --- a/py/files/LunaTranslator_qss +++ b/py/files/LunaTranslator_qss @@ -1 +1 @@ -Subproject commit 0ccbf59b08fd7458820ede53833a8968e93b0d0c +Subproject commit 82812f0105b32b4cd6f28f2caa292f57c6af00c3