fix(reader): invert sidebar thumbnails only under dark theme - #388
deepin-bot[bot] merged 2 commits into
Conversation
Sidebar thumbnails followed eye-protection mode and stayed white in dark theme. Now they follow the system theme only: white pages are inverted via the shared NightFilter (CIELAB L*), image objects keep original colors through a mask prefetched by the worker and cached with the thumbnail, and scanned pages (>70% coverage) are fully inverted. Bookmark/notes lists and the search-result page thumbnails follow the same rules, and mask rects are scaled to the scaled pixmap before filtering. 侧边栏缩略图原先跟随护眼模式,深色主题下仍是白底。现改为只跟随系统 深浅主题:白底经主干夜间滤镜(CIELAB L*)反转为黑底白字,照片区域按 worker 预取、随缩略图缓存的图片对象蒙版保持原色,扫描页(覆盖率超 70%)整页反色;书签/注释列表与搜索结果页的页面小图同规则,蒙版坐标 先映射到缩放后的像素图再进滤镜。 Log: 侧边栏缩略图/书签/注释/搜索结果深色主题反色并支持图片对象蒙版 PMS: BUG-377151 Influence: 深色主题下侧边栏(含触发搜索后的结果页)观感与主视图一致,浅色主题显示不变。
Reviewer's GuideThe PR changes sidebar thumbnail inversion from unconditional/eye-protection-driven behavior to dark-theme-only rendering, centralizes inversion through NightFilter with image-object masking, and supplies pixel-aligned masks from the render thread through DocSheet/model thumbnail caches to all relevant sidebar delegates. It also adds focused unit coverage for theme behavior, mask preservation, render-thread propagation, caching state, and scanned-page handling. Sequence diagram for dark-theme thumbnail rendering with image maskssequenceDiagram
participant RenderThread
participant Renderer
participant DocSheet
participant Model
participant Delegate
participant NightFilter
RenderThread->>Renderer: getImage(index, 174, 174)
RenderThread->>Renderer: getImageObjectRects(index, 174, 174)
RenderThread->>Model: onDocPageThumbnailTask(task, pixmap)
Model->>DocSheet: setThumbnail(index, pixmap, imageRects)
Delegate->>Model: data(index, IMAGE_NIGHT_MASK)
Model->>DocSheet: thumbnailImageRects(index)
alt dark theme
Delegate->>NightFilter: applyPage(image, imageRects)
NightFilter-->>Delegate: masked inverted pixmap
else light theme
Delegate-->>Delegate: draw original pixmap
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto reviewAI 代码审查报告
总体评价
侧边栏缩略图原先跟随护眼模式,深色主题下仍是白底。本 PR 改为只跟随系统深浅主题:白底经主干夜间滤镜(CIELAB L*)反转为黑底白字,照片区域按 worker 预取、随缩略图缓存的图片对象蒙版保持原色,扫描页(覆盖率超 70%)整页反色;书签/注释列表与搜索结果页的页面小图同规则,蒙版坐标先映射到缩放后的像素图再进滤镜。代码实现与 commit message 目的一致,架构清晰,测试覆盖充分。 漏洞统计
漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个 四维度评分
维度1:语法逻辑(25/25 ✓)
变更分析
边界处理
维度2:代码质量(22/25 ✓)
正面评价
存在问题
// 建议提取的共享方法(可放入 Utils.h 或 DelegateHelper)
static QPixmap invertPixmapForDarkTheme(const QPixmap &pixmap, const QPixmap &scalePix,
const QVector<QRectF> &imageRects,
QCache<qint64, QPixmap> &cache)
{
QPixmap invertedPixmap;
if (QPixmap *cached = cache.object(pixmap.cacheKey())) {
invertedPixmap = *cached;
} else {
QVector<QRectF> scaledRects;
scaledRects.reserve(imageRects.size());
const qreal sx = pixmap.isNull() || pixmap.width() == 0
? 0.0 : qreal(scalePix.width()) / pixmap.width();
const qreal sy = pixmap.isNull() || pixmap.height() == 0
? 0.0 : qreal(scalePix.height()) / pixmap.height();
for (const QRectF &r : imageRects)
scaledRects.append(QRectF(r.x() * sx, r.y() * sy,
r.width() * sx, r.height() * sy));
invertedPixmap = QPixmap::fromImage(NightFilter::applyPage(scalePix.toImage(), scaledRects));
invertedPixmap.setDevicePixelRatio(scalePix.devicePixelRatio());
if (!invertedPixmap.isNull())
cache.insert(pixmap.cacheKey(), new QPixmap(invertedPixmap),
invertedPixmap.width() * invertedPixmap.height() * 4);
}
return invertedPixmap;
}维度3:代码性能(20/20 ✓)
性能优势
注意事项
维度4:代码安全(30/30 ✓)
安全分析
安全漏洞清单无安全漏洞。 改进建议建议1:提取共享反色逻辑(优先级:中)
建议2:统一缓存配置(优先级:低)
// BookMarkDelegate 构造函数中添加
m_darkPixmapCache.setMaxCost(8 * 1024 * 1024); // 8MB 反色缓存预算建议3:测试辅助类提取(优先级:低)
审查结论本 PR 修复了侧边栏缩略图在深色主题下仍显示白底的问题,改为统一跟随系统深浅主题并通过 NightFilter 主干管线反色。代码实现与 commit message 描述的目的完全一致:
主要改进点为 BookMarkDelegate 与 NotesDelegate 之间的代码重复,建议提取共享方法。整体代码质量优秀,建议合并。 |
Model.cpp is compiled with the global OFD_SUPPORT_ENABLED definition, but batchprint-convert neither built OfdModel.cpp (which implements OfdDocument::loadDocument) nor linked rofd_ffi/cairo, so linking deepin-reader-batchprint failed with an undefined reference. Add OfdModel.cpp and Navigation.cpp plus the rofd/cairo include dirs, compile options and link libraries behind OFD_SUPPORT_ENABLED, mirroring the existing XPS handling. batchprint-convert 编译 Model.cpp 时继承了全局 OFD_SUPPORT_ENABLED 宏, 但既未编译实现 OfdDocument::loadDocument 的 OfdModel.cpp,也未链接 rofd_ffi/cairo,导致 deepin-reader-batchprint 链接报未定义引用。仿照 XPS 的处理方式,在 OFD_SUPPORT_ENABLED 下补充 OfdModel.cpp、 Navigation.cpp 及 rofd/cairo 头文件路径、编译选项与链接库。 Log: 修复批量打印 OFD 开启时缺少 OfdModel/rofd 链接导致的编译失败 Influence: 仅构建调整:OFD 支持开启时 batchprint 可正常编译链接,关闭 OFD 时行为不变。
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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 |
|
/merge |
修改说明
侧栏缩略图此前无条件做夜间反色,浅色主题下观感异常。现改为仅在夜间/深色模式下反色,且反色时跳过图片对象区域(与主视图 BrowserPage 的蒙版行为一致):
DocSheet随缩略图一同缓存每页imageRects(thumbnailImageRects/setThumbnail新签名,带默认参数保持兼容)依赖说明
本 PR 原基于 #386 堆叠,#386 已合入,本分支已变基到最新 master,仅包含本项改动。
自测
Summary by Sourcery
Limit sidebar thumbnail inversion to dark themes and preserve embedded image regions while aligning sidebar rendering with the shared night filter.
Bug Fixes:
Enhancements:
Build:
Tests: