Repository navigation
fix: magnifier shows white in dark theme - #432
Open
GongHeng2017 wants to merge 1 commit into
Open
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 fallback background to use Dtk’s theme-aware item background color, fixing the white center shown in dark mode while preserving page-content rendering and existing APIs. Flow diagram for theme-aware magnifier fallbackflowchart TD
A[setMagniFierImage] --> B{Image available?}
B -->|Yes| C[Draw scaled page image]
B -->|No| D[DGuiApplicationHelper.applicationPalette]
D --> E[itemBackground.color]
E --> F[Fill magnifier background with theme color]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Root cause: BrowserMagniFier::setMagniFierImage() else branch hardcodes Qt::white as fill color when mouse is over non-page background area, ignoring the system theme 2. Fix: replace Qt::white with DGuiApplicationHelper theme-aware itemBackground().color(), consistent with SheetBrowser background color at SheetBrowser.cpp:2073 3. Impact: magnifier background follows theme in dark mode; no visible change in light mode; no signature or logic change Log: Magnifier background now follows system theme in dark mode Influence: 1. Test magnifier over non-page background in dark mode 2. Test magnifier over non-page background in light mode 3. Verify magnifier over page content is unaffected fix: 放大镜深色模式下显示白色 1. 根因:BrowserMagniFier::setMagniFierImage() else 分支在鼠标位于 非页面背景区域时硬编码 Qt::white 填充色,未跟随系统主题 2. 方案:将 Qt::white 替换为 DGuiApplicationHelper 主题感知色 itemBackground().color(),与 SheetBrowser 背景色一致 3. 影响:深色模式下放大镜背景跟随主题,浅色模式无可见变化, 无签名或逻辑变更 Log: 放大镜背景色在深色模式下跟随系统主题 Influence: 1. 测试深色模式下放大镜悬停在非页面背景区域 2. 测试浅色模式下放大镜悬停在非页面背景区域 3. 验证放大镜悬停在页面内容上不受影响 PMS: BUG-193251
GongHeng2017
force-pushed
the
fix/bug-193251-magnifier-dark-theme
branch
from
October 27, 2026 22:48
e306318 to
c137838
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 当前修改已为最佳实践,无需额外修改。 // 使用 DGuiApplicationHelper 主题调色板替代硬编码白色, // 使放大镜背景在深色主题下正确显示: // // painter.fillRect(this->rect(), // Dtk::Gui::DGuiApplicationHelper::instance() // ->applicationPalette() // .itemBackground() // .color());本报告由 AI 代码审查工具自动生成 |
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
BrowserMagniFier::setMagniFierImage()(reader/browser/BrowserMagniFier.cpp:178) hardcodesQt::whiteas the fill color in theelsebranch when the mouse is over a non-page background area. This constant does not follow the system theme — in dark mode the background is dark (#2B2B2B) but the magnifier center shows pure white (#FFFFFF). The code was written in 2020 (commit9417b7de) without dark mode consideration, whileSheetBrowseralready usesDGuiApplicationHelper::applicationPalette().itemBackground().color()for theme-aware background atSheetBrowser.cpp:2073.Fix
Replace
Qt::whiteatBrowserMagniFier.cpp:178withDtk::Gui::DGuiApplicationHelper::instance()->applicationPalette().itemBackground().color(), consistent withSheetBrowser's background color. Added#include <DGuiApplicationHelper>.Change Safety Assessment
Code Safety
Qt::whitefill) was introduced in commit9417b7de(2020-07-14, "chore: 放大镜功能优化"), not a bug fix product — this change does not revert any historical fixtests/browser/ut_browsermagnifier.cpp— the test stubsfillRectby signature(const QRect&, const QColor&), fix still passes aQColor, so no test breakage expectedBusiness Impact Scope
The change affects only the magnifier feature: when the mouse is over a non-page background area in dark mode, the magnifier center follows the theme color instead of hardcoded white. Callers (
updateImage(),showMagnigierImage(),onUpdateMagnifierImage()) are unaffected — normal image path uses theifbranch, empty image path gets theme-aware fill.Verification Suggestion
根因分析
BrowserMagniFier::setMagniFierImage()(reader/browser/BrowserMagniFier.cpp:178)的else分支在鼠标悬停于非页面背景区域时,使用Qt::white硬编码填充放大镜中心。该常量不随系统主题变化——深色模式下背景为深色(#2B2B2B),放大镜中心却显示纯白(#FFFFFF)。代码写于 2020 年(commit9417b7de),未考虑深色模式,而SheetBrowser已在SheetBrowser.cpp:2073使用DGuiApplicationHelper::applicationPalette().itemBackground().color()作为主题感知背景色。修复方案
将
BrowserMagniFier.cpp:178的Qt::white替换为Dtk::Gui::DGuiApplicationHelper::instance()->applicationPalette().itemBackground().color(),与SheetBrowser背景色保持一致,并新增#include <DGuiApplicationHelper>头文件。改动安全评估
代码安全评估
Qt::white填充)由 commit9417b7de(2020-07-14,"chore: 放大镜功能优化")引入,非 bug 修复产物——本次改动不撤销任何历史修复tests/browser/ut_browsermagnifier.cpp——测试 stubfillRect签名为(const QRect&, const QColor&),修复后仍传入QColor,预期不会破坏测试业务影响范围
改动仅影响放大镜功能:深色模式下鼠标悬停在非页面背景区域时,放大镜中心跟随主题色而非硬编码白色。调用方(
updateImage()、showMagnigierImage()、onUpdateMagnifierImage())不受影响——正常图像路径走if分支,空图像路径获得主题感知填充色。验证建议
Summary by Sourcery
Make the browser magnifier follow the application theme when displaying non-page background areas.
Bug Fixes:
Chores: