Skip to content

fix(shot): align image border with rounded alpha outline - #951

Merged
deepin-bot[bot] merged 8 commits into
linuxdeepin:masterfrom
dengzhongyuan365-dev:newfeat-1012
Oct 12, 2026
Merged

deepin-bot[bot] merged 8 commits into
linuxdeepin:masterfrom
dengzhongyuan365-dev:newfeat-1012

Conversation

@dengzhongyuan365-dev

@dengzhongyuan365-dev dengzhongyuan365-dev commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Draw shadow and border from alpha contour for rounded screenshots.

圆角截图按透明轮廓绘制投影和描边,避免出现直角阴影与边框。

Log: 修复圆角截图投影与描边
PMS: TASK-393987
Influence: 圆角截图的投影和保存边框与圆角轮廓保持一致。

Summary by Sourcery

Align rounded screenshot effects with their alpha contours while improving screenshot selection adjustment, magnifier tooling, and annotation-mode interactions.

New Features:

  • Add pixel-level shortcut guidance for moving and resizing screenshot selections.
  • Provide a redesigned pixel magnifier with cursor coordinates, sampled color values, and clipboard copying.
  • Allow screenshot selection resizing during annotation through border dragging and keyboard shortcuts.

Bug Fixes:

  • Render shadows and borders for transparent or rounded screenshots according to their alpha contours instead of rectangular bounds.
  • Preserve annotation placement and reset stale annotation interaction state while resizing or drawing.

Enhancements:

  • Improve magnifier positioning, scaling, caching, and visibility behavior during screenshot selection.
  • Change the AI Screenshot shortcut to Alt+A and update its labels and translations.

Build:

  • Include the new FineAdjustTips widget in the project build.

Draw shadow and border from alpha contour for rounded screenshots.

圆角截图按透明轮廓绘制投影和描边,避免出现直角阴影与边框。

Log: 修复圆角截图投影与描边
PMS: TASK-393987
Influence: 圆角截图的投影和保存边框与圆角轮廓保持一致。
Add a bottom-left hint panel that describes moving the pointer or the
capture area by one pixel with W/A/S/D, arrow keys and Ctrl/Shift.

在截图界面左下角新增像素级微调快捷键提示:未框选时提示移动鼠标指针,
框选完成后提示移动/扩大/缩小选区,固定比例时扩大/缩小两行置灰,
面板与光标或选区重叠时自动隐藏。

Log: 新增截图像素级微调快捷键提示面板
PMS: TASK-393987
Influence: 截图界面左下角常驻快捷键提示,帮助用户发现像素级微调能力;
固定比例激活时扩大/缩小快捷键置灰不可用。
Use Alt+A for AI screenshot so that the A key is free to move the
cursor and the capture area left by one pixel, and update tooltips.

AI截图快捷键由 A 改为 Alt+A,释放 A 键用于像素级向左微调,
并同步更新截图工具栏与滚动截图工具栏的 tooltip。

Log: AI截图快捷键改为Alt+A
PMS: TASK-393987
Influence: 截图模式下按 Alt+A 触发AI截图;AI截图按钮 tooltip 显示为
"AI截图 (Alt+A)";A 键恢复为像素级向左微调。
@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Sorry @dengzhongyuan365-dev, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 23 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR fixes rounded screenshot output by deriving shadows and borders from alpha contours, while also adding a context-aware pixel-adjustment shortcut overlay and changing the AI screenshot shortcut to Alt+A.

Sequence diagram for alpha-contour screenshot rendering

sequenceDiagram
    participant Caller
    participant ShadowBorderProcess
    participant QPainter

    Caller->>ShadowBorderProcess: getPixmapAddBorder(pix)
    ShadowBorderProcess->>ShadowBorderProcess: detect alpha transparency
    alt rounded or transparent screenshot
        ShadowBorderProcess->>ShadowBorderProcess: drawShadow(painter, rect, color, radius, shapeImage, shaped)
        ShadowBorderProcess->>QPainter: draw shadow from alpha silhouette
        ShadowBorderProcess->>ShadowBorderProcess: drawShapeBorder(painter, imageRect, color, shapeImage)
        ShadowBorderProcess->>QPainter: fill alpha-contour border ring
    else opaque screenshot
        ShadowBorderProcess->>ShadowBorderProcess: drawShadow(painter, rect, color, radius, shapeImage, shaped)
        ShadowBorderProcess->>QPainter: draw rectangular shadow and border
    end
    ShadowBorderProcess-->>Caller: bordered pixmap with matching outline
Loading

File-Level Changes

Change Details Files
Makes saved screenshot shadows and borders follow the source image’s alpha contour for rounded screenshots.
  • Detects partially transparent pixels before selecting shaped rendering.
  • Builds the shadow mask from the source alpha channel instead of a rectangle.
  • Generates a one-pixel contour ring for the border while retaining rectangular behavior for opaque images.
src/utils/borderprocessinterface.cpp
src/utils/borderprocessinterface.h
Adds a contextual pixel-adjustment shortcut overlay to the standard screenshot workflow.
  • Introduces a custom translucent, rounded panel showing pointer or selection movement and resize shortcuts.
  • Updates mode, enabled state, position, visibility, and overlap handling as screenshot state, cursor, keyboard, and window geometry change.
  • Hides the panel when entering editing mode or in unsupported environments, and registers the new widget in the project build.
src/widgets/fineadjusttips.cpp
src/widgets/fineadjusttips.h
src/main_window.cpp
src/main_window.h
src/src.pro
Changes the AI screenshot shortcut from A to Alt+A and updates user-facing labels.
  • Updates the application shortcut and diagnostic logging.
  • Updates screenshot and scroll-screenshot tooltips and Chinese translation entries.
src/main_window.cpp
src/widgets/subtoolwidget.cpp
translations/deepin-screen-recorder_zh_CN.ts

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 94 分,大于 70 分通过阈值,代码质量符合要求。本次变更包含3个功能点:圆角截图投影/描边修复、像素级微调快捷键提示面板、AI截图快捷键改为Alt+A,代码结构清晰,注释完整,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. src/widgets/fineadjusttips.cpp:127 - paintEvent() 中 static const 数组可提升为类级别常量

建议: 将 letterKeys 数组提升为类级别 static const 成员;reinterpret_cast 处添加格式断言确保安全性


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. src/widgets/fineadjusttips.cpp:20 - 魔法数字引用外部 Sketch 设计稿尺寸,设计变更时需手动同步
  2. src/main_window.cpp:1215 - aiAssistantSC connect lambda 中 qCWarning 日志重复输出两行相同内容

建议: 考虑将 Sketch 设计尺寸提取为配置文件或常量类;移除重复的 qCWarning 日志行


3. 代码性能 ✅

评价: 良好 ✅ 通过

潜在问题:

  1. src/utils/borderprocessinterface.cpp:695 - drawShapeBorder() QRegion 3x3膨胀操作对大尺寸截图可能有性能开销
  2. src/main_window.cpp:5691 - updateFineAdjustTips() 在每次鼠标移动时调用,可增加脏标记优化

建议: drawShapeBorder 可考虑使用 QImage 的形态学操作替代 QRegion 膨胀;updateFineAdjustTips 可增加脏标记避免重复布局计算


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 无安全漏洞,代码不涉及用户输入处理、网络通信、文件路径操作等安全敏感场景。建议保持现有的防御性编程实践。


💡 改进建议代码示例

// 优化1: drawShapeBorder 使用 QImage 形态学操作替代 QRegion
void ShadowBorderProcess::drawShapeBorder(QPainter *p, const QRect &imageRect,
                                          const QColor &color, const QImage &source)
{
    if (source.isNull()) return;

    // 使用 QImage 膨胀替代 QRegion,性能更优
    QImage mask = source.createAlphaMask(Qt::ThresholdDither).toImage();
    QImage dilated = mask.copy();
    // 3x3 膨胀 - 使用 QImage 像素操作
    for (int y = 0; y < mask.height(); ++y) {
        for (int x = 0; x < mask.width(); ++x) {
            if (mask.pixelIndex(x, y)) {
                for (int dy = -1; dy <= 1; ++dy)
                    for (int dx = -1; dx <= 1; ++dx) {
                        int nx = qBound(0, x+dx, mask.width()-1);
                        int ny2 = qBound(0, y+dy, mask.height()-1);
                        dilated.setPixel(nx, ny2, 1);
                    }
            }
        }
    }
    // ring = dilated - mask
    // ... fill ring with border color
}

// 优化2: updateFineAdjustTips 增加脏标记
void MainWindow::updateFineAdjustTips()
{
    if (m_fineAdjustTips == nullptr) return;
    // 缓存上次状态,避免不必要的布局计算
    static bool lastVisible = false;
    static Mode lastMode = FineAdjustTips::CursorMode;
    // ... 仅在状态变化时调用 dockToBottomLeft
}

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

lzwind
lzwind previously approved these changes Oct 12, 2026
Redesign the magnifier to match the Sketch spec and expose cursor color data.

按设计稿重做像素放大镜浮窗,并支持读取光标像素色值。

Log: 新增像素放大镜及取色浮窗
PMS: TASK-393987
Influence: 选区调整时显示符合设计稿的放大镜,为复制色值提供基础能力。
Display the pixel magnifier during selection and border resizing.

在框选和调整选区边框时显示像素放大镜,调整结束后隐藏。

Log: 优化放大镜显示时机与位置
PMS: TASK-393987
Influence: 放大镜跟随光标显示,避免浮窗超出屏幕,并在选区确认后自动隐藏。
Allow mouse and Ctrl shortcuts to resize the capture area after annotations start.

标注模式下支持鼠标和快捷键调整截图选区大小,并保持已有标注位置不变。

Log: 支持标注模式下调整截图选区
PMS: TASK-393987
Influence: 用户进入标注后可继续调整选区,已有标注保持屏幕绝对位置。
Copy the current magnifier pixel color as HEX and exit the capture flow.

放大镜显示时按 Ctrl+C 复制当前像素色值并退出截图。

Log: 支持快捷键复制像素色值
PMS: TASK-393987
Influence: 用户可直接复制带 # 的小写 HEX 色值,复制成功后退出截图。
Reset stale resize/rotate state, restore painter state in sequence
painting, and stop the selection border from stealing drag events.

修复序号标注:绘制序号会污染后续图形的画笔状态导致其它标注被填充、
复用上一个图形的缩放态导致选中拖动跳变,以及拖动时选区边框抢鼠标
事件导致标注只在起点和终点显示。

Log: 修复序号标注绘制与拖动异常
PMS: TASK-393987
Influence: 序号标注不再影响其它标注的填充样式;选中序号后可连续跟手
拖动,位置不再跳变。
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengzhongyuan365-dev

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

1 similar comment
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengzhongyuan365-dev

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

@dengzhongyuan365-dev

Copy link
Copy Markdown
Member Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit c1e1741 into linuxdeepin:master Oct 12, 2026
5 of 7 checks passed
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