fix(print): render page with white background - #218
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Resurgamz 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 GuideThis PR ensures printed/previewed pages use a white background instead of treating transparent canvas regions as black by passing an explicit background color when rendering the page image for the print dialog. Sequence diagram for updated print preview background renderingsequenceDiagram
actor User
participant TopTilte
participant DrawApp as drawApp
participant DrawBoard as drawBoard
participant Page as page
participant Context as page_context
participant CPrintManager as CPrintManager
User ->> TopTilte: trigger Print action
TopTilte ->> DrawApp: topMainWindowWidget()
TopTilte ->> DrawApp: drawBoard()
DrawApp ->> DrawBoard: currentPage()
DrawBoard ->> Page: currentPage
Page ->> Page: context()
Page ->> Context: context
Context ->> Context: renderToImage(Qt::white)
Context -->> TopTilte: rendered_image
TopTilte ->> CPrintManager: CPrintManager(topMainWindowWidget)
TopTilte ->> CPrintManager: showPrintDialog(rendered_image, topMainWindowWidget, page->name())
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider whether using a hardcoded
Qt::whiteis always appropriate for printing (e.g., dark themes or custom page backgrounds) and, if not, derive the background color from the page or user settings instead. - It may be clearer to guard
showPrintDialogwith an early return whenpageorpage->context()is null, rather than nesting the call inside the conditional.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider whether using a hardcoded `Qt::white` is always appropriate for printing (e.g., dark themes or custom page backgrounds) and, if not, derive the background color from the page or user settings instead.
- It may be clearer to guard `showPrintDialog` with an early return when `page` or `page->context()` is null, rather than nesting the call inside the conditional.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已是最优修复方案,无需进一步改进
void TopTilte::initMenu()
{
// ...
CPrintManager manager(drawApp->topMainWindowWidget());
auto page = drawApp->drawBoard()->currentPage();
if (page != nullptr && page->context() != nullptr)
manager.showPrintDialog(page->context()->renderToImage(Qt::white), drawApp->topMainWindowWidget(),
page->name());
// ...
} |
问题\n修复打印预览中透明画布区域显示黑色矩形框的问题。\n\n## 修复方案\n在打印入口渲染页面图像时显式传入
Qt::white作为背景色,避免透明像素在预览或打印后端按黑色合成。\n\n## 验证\n-cmake --build obj-x86_64-linux-gnu -j2\n\n## PMS\n- BUG-221301\n- 根因分析:analysis-report.mdSummary by Sourcery
Bug Fixes: