From f8c26bb6a3af683d34d8a55f95ae53fd7eccece8 Mon Sep 17 00:00:00 2001 From: gongheng Date: Fri, 30 Oct 2026 04:22:15 +0800 Subject: [PATCH] fix: use theme-aware color for magnifier background MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: BrowserMagniFier::setMagniFierImage() hardcoded Qt::white to fill magnifier center when image is null, which does not adapt to dark mode 2. Fix: replace Qt::white with DGuiApplicationHelper palette itemBackground color, consistent with SheetBrowser.cpp:72 3. Impact: magnifier center now follows system theme in dark mode, no behavior change for light mode users Log: Fix magnifier background color not adapting to dark mode Influence: 1. Test magnifier on non-content area in light mode 2. Test magnifier on non-content area in dark mode 3. Verify magnifier still shows page content correctly fix: 放大镜背景色适配深色模式 1. 根因:BrowserMagniFier::setMagniFierImage() 在图像为空时 硬编码 Qt::white 填充放大镜中心,不随系统主题变化 2. 方案:将 Qt::white 替换为 DGuiApplicationHelper 调色板 itemBackground 颜色,与 SheetBrowser.cpp:72 保持一致 3. 影响:深色模式下放大镜中心跟随主题,浅色模式无行为变化 Log: 修复放大镜背景色不适配深色模式的问题 Influence: 1. 浅色模式下放大镜移至非内容区域测试 2. 深色模式下放大镜移至非内容区域测试 3. 验证放大镜正常显示页面内容无回归 Bug: #193251 --- reader/browser/BrowserMagniFier.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/reader/browser/BrowserMagniFier.cpp b/reader/browser/BrowserMagniFier.cpp index 1db316097..186a258f5 100644 --- a/reader/browser/BrowserMagniFier.cpp +++ b/reader/browser/BrowserMagniFier.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -16,6 +16,8 @@ #include #include +#include + ReadMagnifierManager::ReadMagnifierManager(QWidget *parent) : QThread(parent) { // qCDebug(appLog) << "ReadMagnifierManager created"; @@ -204,7 +206,7 @@ void BrowserMagniFier::setMagniFierImage(const QImage &image) painter.drawImage(0, 0, im.scaled(static_cast(240 * dApp->devicePixelRatio()), static_cast(240 * dApp->devicePixelRatio()), Qt::KeepAspectRatio, Qt::SmoothTransformation)); } else { // qCDebug(appLog) << "BrowserMagniFier::setMagniFierImage() - Drawing white background for null image"; - painter.fillRect(this->rect(), Qt::white); + painter.fillRect(this->rect(), DGuiApplicationHelper::instance()->applicationPalette().itemBackground().color()); } painter.restore();