Skip to content

fix: apply selected paper size after printer settings rebuild - #774

Open
18202781743 wants to merge 1 commit into
linuxdeepin:masterfrom
18202781743:fix-print-preview-custom-paper-size
Open

fix: apply selected paper size after printer settings rebuild#774
18202781743 wants to merge 1 commit into
linuxdeepin:masterfrom
18202781743:fix-print-preview-custom-paper-size

Conversation

@18202781743

@18202781743 18202781743 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • explicitly apply the selected paper size after rebuilding printer settings
  • keep the preview and printer page layout consistent when the default item is a custom paper size
  • add a regression test for restoring a custom paper-size selection

Tests

  • cmake --build build -j6 --target ut-dtkwidget
  • print-preview regression test: passed
  • cmake --build build6 -j6 --target dtk6widget

Summary by Sourcery

Reapply the selected paper size when printer settings change so custom paper selections remain effective.

Bug Fixes:

  • Ensure the selected custom paper size is reapplied after printer settings are rebuilt, keeping the preview and printer page layout consistent.

Tests:

  • Add a regression test covering restoration of a custom paper-size selection after changing printers.

1. Fix issue where printing preview's default custom paper size was not
synchronized to printer parameters
2. Add explicit matchFitablePageSize() call in _q_printerChanged() after
paper list rebuild
3. The combo-box signal was not guaranteed to fire when the current
index remained unchanged after rebuilding the paper list
4. Add unit test verifying the paper size is applied and printer
parameters are updated correctly

Log: Fixed printing preview issue where custom paper size was not synced
to printer parameters

Influence:
1. Verify printing preview opens with default custom paper size
correctly applied
2. Test printer switching while a custom paper size is selected
3. Confirm the printer parameters reflect the selected paper size after
printer changes
4. Test with various paper sizes including custom and standard formats
5. Verify paper size selection remains consistent between the dialog and
printer settings

fix: 修复打印预览默认自定义纸张未同步到打印机参数的问题

1. 修复打印预览中默认自定义纸张未同步到打印机参数的问题
2. 在 _q_printerChanged() 中纸张列表重建后显式调用
matchFitablePageSize()
3. 当重建纸张列表后当前索引未改变时,下拉框信号可能不会触发
4. 添加单元测试验证纸张大小正确应用且打印机参数同步更新

Log: 修复打印预览中自定义纸张大小未同步到打印机参数的问题

Influence:
1. 验证打印预览以默认自定义纸张大小正常打开
2. 测试在选中自定义纸张时切换打印机
3. 确认打印机切换后打印机参数反映所选纸张大小
4. 测试各种纸张大小,包括自定义和标准格式
5. 验证对话框和打印机设置之间纸张大小选择保持一致
@18202781743
18202781743 requested review from BLumia and mhduiy August 21, 2026 09:14

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @18202781743, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensures the selected custom paper size is explicitly reapplied after printer settings are rebuilt and adds a regression test to lock in this behavior.

Sequence diagram for applying selected paper size after printer change

sequenceDiagram
    actor User
    participant DPrintPreviewDialog
    participant PaperSizeCombo

    User->>DPrintPreviewDialog:_q_printerChanged(index)
    DPrintPreviewDialog->>PaperSizeCombo:blockSignals(true)
    DPrintPreviewDialog->>DPrintPreviewDialog:rebuildPaperSizeList()
    note over DPrintPreviewDialog: current index may not change
    DPrintPreviewDialog->>DPrintPreviewDialog:matchFitablePageSize()
    DPrintPreviewDialog->>DPrintPreviewDialog:marginsUpdate(true)
    DPrintPreviewDialog->>PaperSizeCombo:blockSignals(false)
Loading

File-Level Changes

Change Details Files
Ensure selected paper size is reapplied when printer settings are rebuilt during printer change handling.
  • Call matchFitablePageSize() immediately after rebuilding the paper list in _q_printerChanged to explicitly apply the selected page size when combo-box signals are blocked
  • Keep marginsUpdate(true) and signal unblocking logic intact so layout and behavior remain consistent with existing flow
src/widgets/dprintpreviewdialog.cpp
Add regression coverage to ensure custom paper-size selection is preserved and applied after printer changes.
  • Extend SPDX copyright range to 2026 to reflect ongoing maintenance
  • Add testPaperSizeAppliedAfterPrinterChanged test to set a custom paper size, trigger printer change (with list rebuild), and assert that both the combo current text and printer pageSize remain on the custom size
tests/testcases/printpreview/ut_dprintpreviewdialog.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants