Repository navigation
fix: use theme-aware color for magnifier background - #436
Draft
GongHeng2017 wants to merge 1 commit into
Draft
GongHeng2017 wants to merge 1 commit into
GongHeng2017 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates the magnifier’s non-content fallback rendering to obtain its fill color from the application palette, preventing a white center from clashing with dark mode while preserving existing content rendering behavior. Sequence diagram for theme-aware magnifier fallback renderingsequenceDiagram
participant BrowserMagniFier
participant DGuiApplicationHelper
participant QPainter
BrowserMagniFier->>BrowserMagniFier: setMagniFierImage(image)
alt image contains page content
BrowserMagniFier->>QPainter: drawImage()
else image is null
BrowserMagniFier->>DGuiApplicationHelper: instance()
DGuiApplicationHelper-->>BrowserMagniFier: applicationPalette()
BrowserMagniFier->>QPainter: fillRect(itemBackground().color())
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
GongHeng2017
marked this pull request as draft
October 29, 2026 20:28
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
GongHeng2017
force-pushed
the
fix/pms-193251-magnifier-dark-mode
branch
from
October 29, 2026 21:05
66168d4 to
f8c26bb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause Analysis
When the magnifier is moved to a non-content area (outside document pages),
BrowserMagniFier::setMagniFierImage()receives a nullQImageand enters theelsebranch, where it fills the magnifier center withQt::white. SinceQt::whiteis a fixed Qt color constant (QColor(255,255,255)) that does not respond to theme changes, the magnifier center displays pure white even in dark mode, creating a jarring contrast with the dark background (~#2B2B2B).Key evidence:
reader/browser/BrowserMagniFier.cpp:207hardcodesQt::white; the same module'sSheetBrowser.cpp:72already uses the theme-awareDGuiApplicationHelper::instance()->applicationPalette().itemBackground().color().Fix
Replace
Qt::whiteat line 207 withDGuiApplicationHelper::instance()->applicationPalette().itemBackground().color(), and add#include <DGuiApplicationHelper>. This is consistent with the existing pattern inSheetBrowser.cpp:72.Change Safety Assessment
Code Safety
9417b7de8, 2020-07-14), not a previous bug fix product; this change does not revert any historical fixsetMagniFierImage()is a private rendering method with only 3 internal callers; no signature change, no caller impactBusiness Impact Scope
Verification Suggestion
Test the magnifier tool in both light and dark modes: move it onto and off document pages, verify the center area follows the theme in dark mode and remains consistent in light mode.
根因分析
深色模式下放大镜移至非内容区域时,
BrowserMagniFier::setMagniFierImage()收到空QImage进入else分支,使用Qt::white填充放大镜中心。Qt::white是 Qt 固定常量(QColor(255,255,255)),不随主题变化,导致深色模式下放大镜中心显示纯白,与深色背景(约 #2B2B2B)形成刺眼反差。关键证据:
reader/browser/BrowserMagniFier.cpp:207硬编码Qt::white;同模块SheetBrowser.cpp:72已使用主题感知的DGuiApplicationHelper::instance()->applicationPalette().itemBackground().color()。修复方案
将第 207 行的
Qt::white替换为DGuiApplicationHelper::instance()->applicationPalette().itemBackground().color(),并添加#include <DGuiApplicationHelper>,与SheetBrowser.cpp:72保持一致。改动安全评估
代码安全评估
9417b7de8, 2020-07-14),非历史 bug 修复产物;本次改动不撤销任何历史修复setMagniFierImage()是私有渲染方法,仅 3 个内部调用方;签名不变,调用方无影响业务影响范围
验证建议
在浅色和深色模式下测试放大镜工具:将放大镜移入和移出文档页面,验证深色模式下中心区域跟随主题,浅色模式保持一致。
Summary by Sourcery
Make the document magnifier’s empty-area background follow the application theme.
Bug Fixes:
Chores: