Skip to content

fix: correct nav mask coords after image rotation - #430

Open
JWWTSL wants to merge 1 commit into
linuxdeepin:masterfrom
JWWTSL:agent/pms-bug-bot/7550c2be3556
Open

JWWTSL wants to merge 1 commit into
linuxdeepin:masterfrom
JWWTSL:agent/pms-bug-bot/7550c2be3556

Conversation

@JWWTSL

@JWWTSL JWWTSL commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

fix: correct nav mask coords after image rotation

  1. Root cause: refreshNaviMaskImpl() and updateImagePositionBasedOnMask()
    mapped main-view X/Y directly to nav-thumbnail X/Y without rotation
    transform; after 90°/270° rotation swapWidthAndHeight() swaps
    paintedWidth/paintedHeight so axes are transposed but mapping was not
  2. Fix: when currentRotation % 180 !== 0, swap targetImage.x/y,
    paintedWidth/Height, and Window.width/height in refreshNaviMaskImpl();
    swap xRatio/yRatio in updateImagePositionBasedOnMask() for drag
  3. Impact: only NavigationWidget.qml mask position/drag direction for
    90°/270° rotations; 0°/180° behavior unchanged

Log: 修复放大图片旋转后导航窗口蒙皮位置和拖拽方向错乱

Influence:

  1. Zoom image and rotate 90°/270°, verify mask position matches main view
  2. Drag nav mask after 90°/270° rotation, verify main view moves correctly
  3. Rotate 180° and no rotation, verify no regression in mask behavior

fix: 修复图片旋转后导航窗口蒙皮坐标错乱

  1. 根因:refreshNaviMaskImpl() 和 updateImagePositionBasedOnMask() 将主视图
    X/Y 坐标直接映射到导航缩略图 X/Y,未做旋转变换;旋转 90°/270° 时
    swapWidthAndHeight() 交换 paintedWidth/paintedHeight 导致坐标轴转置但
    映射未同步交换
  2. 方案:当 currentRotation % 180 !== 0 时,在 refreshNaviMaskImpl() 中交换
    targetImage.x/y、paintedWidth/Height、Window.width/height;在
    updateImagePositionBasedOnMask() 中交换 xRatio/yRatio 实现拖拽方向映射
  3. 影响:仅影响 NavigationWidget.qml 在 90°/270° 旋转下的蒙皮位置和拖拽
    方向;0°/180° 行为不变

Log: 修复放大图片旋转后导航窗口蒙皮位置和拖拽方向错乱

Influence:

  1. 放大图片并旋转 90°/270°,验证蒙皮位置与主视图可视区域一致
  2. 旋转 90°/270° 后拖拽导航蒙皮,验证主视图移动方向正确
  3. 旋转 180° 和不旋转时,验证蒙皮行为无回归

PMS: BUG-373837

Summary by Sourcery

Fix navigation mask synchronization after image rotation by refreshing it after the rotated image state is ready.

Bug Fixes:

  • Correct navigation mask positioning and drag behavior after rotating images by 90° or 270°.
  • Defer mask refresh after rotation so it uses the updated image dimensions and coordinates.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JWWTSL

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 Oct 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates NavigationWidget.qml to transpose navigation-mask coordinates, dimensions, and drag ratios for 90°/270° rotations, fixing mask placement and drag direction while preserving unrotated and 180° behavior.

Sequence diagram for rotated navigation mask dragging

sequenceDiagram
    participant User
    participant NavigationWidget
    participant MainImage

    User->>NavigationWidget: Drag navigation mask
    NavigationWidget->>NavigationWidget: updateImagePositionBasedOnMask()
    alt 90°/270° rotation
        NavigationWidget->>NavigationWidget: Swap xRatio and yRatio
    else 0°/180° rotation
        NavigationWidget->>NavigationWidget: Keep xRatio and yRatio
    end
    NavigationWidget->>MainImage: Update targetImage.x and targetImage.y
Loading

Flow diagram for rotation-aware navigation mask mapping

flowchart LR
    A[NavigationWidget.qml] --> B{currentRotation % 180 !== 0}
    B -->|No| C[Use targetImage x/y and painted width/height]
    B -->|Yes| D[Transpose x/y, width/height, and Window dimensions]
    C --> E[refreshNaviMaskImpl]
    D --> E
    E --> F[Update navigation mask position and size]
Loading

File-Level Changes

Change Details Files
Correct navigation mask coordinate mapping for 90°/270° image rotations.
  • Detect quarter-turn rotations and transpose image coordinates, dimensions, and viewport dimensions before calculating mask position and size.
  • Preserve existing coordinate calculations for 0°/180° rotations while using swapped dimensions for rotated axes.
  • Swap drag ratios so navigation-mask movement updates the main image along the correct axes.
src/qml/NavigationWidget.qml

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

@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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

1. Root cause: onCurrentRotationChanged calls currentImage.updateMask()
   immediately, but targetImage has a 50ms delayUpdate timer before
   reload, so paintedWidth/paintedHeight are still pre-rotation values
2. Fix: add rotationRefreshTimer (200ms) to defer updateMask() until
   after targetImage finishes reloading with rotated pixel dimensions
3. Impact: only affects navigation mask position after rotation; existing
   onPaintedWidthChanged/onPaintedHeightChanged signals provide self-
   correction as a fallback

Log: Fixed navigation window mask position error after rotating zoomed image

Influence:
1. Test zoom in then rotate image, verify nav mask position is correct
2. Test rapid consecutive rotations, verify mask settles correctly
3. Test rotation on image smaller than window, verify no nav shown

fix: 修复旋转后导航窗口蒙皮位置错误

1. 根因:onCurrentRotationChanged 立即调用 currentImage.updateMask(),
   但 targetImage 有 50ms delayUpdate 延迟重载,paintedWidth/
   paintedHeight 仍为旋转前值,导致蒙皮位置计算使用过时数据
2. 方案:新增 rotationRefreshTimer(200ms)延迟调用 updateMask(),
   等待 targetImage 完成重载后再刷新蒙皮位置
3. 影响:仅影响旋转后导航窗口蒙皮位置;已有的
   onPaintedWidthChanged/onPaintedHeightChanged 信号提供自纠正兜底

Log: 修复放大图片旋转后导航窗口蒙皮位置错误

Influence:
1. 测试放大后旋转图片,验证导航蒙皮位置正确
2. 测试快速连续旋转,验证蒙皮最终位置正确
3. 测试小于窗口的图片旋转,验证不显示导航窗口

PMS: BUG-373837
@JWWTSL
JWWTSL force-pushed the agent/pms-bug-bot/7550c2be3556 branch from e43145f to 3cced3b Compare October 28, 2026 15:39
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 99 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了图片旋转后导航蒙皮坐标错误的问题,通过引入 200ms 延迟定时器等待图片重载完成后再刷新蒙皮,方案正确且注释充分。四维度均通过,无安全漏洞,仅有一个轻微性能建议(魔法数字可提取为常量)。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['无需修改,语法逻辑正确。']


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['代码质量良好,注释充分,无需修改。']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['建议将 interval: 200 提取为 property 常量,如 property int rotationRefreshInterval: 200,并在 Timer 中引用。']


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: ['无安全风险,无需安全加固。']


💡 改进建议代码示例

// 建议将魔法数字提取为属性常量 Item {
    // 旋转后主视图 targetImage 有 50ms delayUpdate 延迟重载,立即刷新蒙皮
    // 会使用旋转前的 paintedWidth/paintedHeight,导致蒙皮位置错误
    // 200ms = 50ms delayUpdate + ~150ms 异步图片重载余量
    property int rotationRefreshInterval: 200

    Timer {
        id: rotationRefreshTimer

        interval: rotationRefreshInterval
        repeat: false

        onTriggered: currentImage.updateMask()
    }
}

本报告由 AI 代码审查工具自动生成

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.

2 participants