Skip to content

Conversation

robertkill
Copy link
Contributor

@robertkill robertkill commented Oct 10, 2025

Added logic to make tray action icons (collapse/show stash) visible during drag operations over the tray area. When a drag event enters the tray container, the action icons become visible to provide better visual feedback. When the drag leaves without dropping, the action icons are hidden again to maintain normal UI state.

Log: Tray action icons now appear during drag operations over the tray

Influence:

  1. Test dragging items over the system tray area
  2. Verify action icons become visible when dragging over tray
  3. Confirm action icons hide when drag leaves without dropping
  4. Check that normal tray functionality remains unchanged
  5. Test with various drag sources and file types

feat: 在拖拽操作期间显示托盘操作图标

添加了在拖拽操作期间使托盘操作图标(收起/显示隐藏)可见的逻辑。当拖拽事
件进入托盘容器时,操作图标变为可见以提供更好的视觉反馈。当拖拽离开而没有
放置时,操作图标再次隐藏以保持正常的UI状态。

Log: 托盘操作图标现在在拖拽操作期间出现在托盘上方

Influence:

  1. 测试在系统托盘区域上方拖拽项目
  2. 验证拖拽到托盘上方时操作图标是否可见
  3. 确认拖拽离开而没有放置时操作图标是否隐藏
  4. 检查正常托盘功能是否保持不变
  5. 使用各种拖拽源和文件类型进行测试

PMS: BUG-336195

Summary by Sourcery

Bug Fixes:

  • Show tray action icons during drag operations over the tray area and hide them when the drag leaves without dropping

Added logic to make tray action icons (collapse/show stash) visible
during drag operations over the tray area. When a drag event enters the
tray container, the action icons become visible to provide better visual
feedback. When the drag leaves without dropping, the action icons are
hidden again to maintain normal UI state.

Log: Tray action icons now appear during drag operations over the tray

Influence:
1. Test dragging items over the system tray area
2. Verify action icons become visible when dragging over tray
3. Confirm action icons hide when drag leaves without dropping
4. Check that normal tray functionality remains unchanged
5. Test with various drag sources and file types

feat: 在拖拽操作期间显示托盘操作图标

添加了在拖拽操作期间使托盘操作图标(收起/显示隐藏)可见的逻辑。当拖拽事
件进入托盘容器时,操作图标变为可见以提供更好的视觉反馈。当拖拽离开而没有
放置时,操作图标再次隐藏以保持正常的UI状态。

Log: 托盘操作图标现在在拖拽操作期间出现在托盘上方

Influence:
1. 测试在系统托盘区域上方拖拽项目
2. 验证拖拽到托盘上方时操作图标是否可见
3. 确认拖拽离开而没有放置时操作图标是否隐藏
4. 检查正常托盘功能是否保持不变
5. 使用各种拖拽源和文件类型进行测试

PMS: BUG-336195
Copy link

sourcery-ai bot commented Oct 10, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR enhances drag-and-drop UX by toggling the tray action icons’ visibility during drag operations: it sets the "actionsAlwaysVisible" flag to true when a drag enters the tray area and resets it to false when the drag leaves without dropping, all within the TrayContainer component.

Sequence diagram for tray action icons visibility during drag operations

sequenceDiagram
actor User
participant "TrayContainer"
participant "TraySortOrderModel"
User->>"TrayContainer": Drag enters tray area
"TrayContainer"->>"TraySortOrderModel": Set actionsAlwaysVisible = true
User->>"TrayContainer": Drag leaves tray area (without drop)
"TrayContainer"->>"TraySortOrderModel": Set actionsAlwaysVisible = false
Loading

File-Level Changes

Change Details Files
Toggle tray action icons visibility during drag events
  • Set DDT.TraySortOrderModel.actionsAlwaysVisible to true on drag enter
  • Reset DDT.TraySortOrderModel.actionsAlwaysVisible to false on drag leave without drop
panels/dock/tray/package/TrayContainer.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

@deepin-ci-robot
Copy link

deepin pr auto review

我来审查这段代码,并提供改进意见:

  1. 代码逻辑和功能:
  • 代码处理了拖放事件,通过设置actionsAlwaysVisible来控制动作图标的可见性
  • 在拖拽开始时显示动作图标,在拖拽离开但未放置时隐藏动作图标
  • 逻辑基本清晰,但有一些可以改进的地方
  1. 语法问题:
  • 代码语法没有明显错误,符合QML的语法规范
  1. 代码质量改进建议:
  • 添加注释说明actionsAlwaysVisible属性的具体用途和影响范围
  • console.log(surfaceId, source)替换为更合适的日志方式,如使用Qt的日志系统
  • 考虑将动作图标的可见性控制逻辑封装为一个独立函数,提高代码复用性
  1. 代码性能改进建议:
  • 当前的实现方式是合理的,没有明显的性能问题
  • 可以考虑在不需要时及时清理资源,如确保Timer在不再使用时被正确停止
  1. 代码安全改进建议:
  • 建议对surfaceIdsource进行有效性验证,确保它们不为空或无效值
  • 考虑添加错误处理机制,防止在访问TraySortOrderModel时出现异常

改进后的代码建议:

Item {
    // ... 其他代码保持不变 ...

    // 拖拽进入处理
    onDragEntered: {
        surfaceId = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-surfaceId")
        source = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-source")
        
        // 验证拖拽数据的有效性
        if (surfaceId && source) {
            Qt.debug(`Drag entered - Surface ID: ${surfaceId}, Source: ${source}`)
            
            // 显示动作图标
            DDT.TraySortOrderModel.actionsAlwaysVisible = true
            
            if (source !== "" && DDT.TraySortOrderModel.isDisplayedSurface(surfaceId)) {
                dragEvent.accepted = false
            } else {
                dragEvent.accepted = true
                dropTrayTimer.restart()
            }
        } else {
            dragEvent.accepted = false
        }
    }

    // 拖拽离开处理
    onDragExited: {
        dropTrayTimer.stop()
        
        if (surfaceId) {
            DDT.TraySortOrderModel.setSurfaceVisible(surfaceId, false)
        }
        
        // 隐藏动作图标
        if (!isDropped) {
            DDT.TraySortOrderModel.actionsAlwaysVisible = false
        }
    }

    // ... 其他代码保持不变 ...
}

主要改进点:

  1. 添加了数据有效性验证
  2. 使用Qt的日志系统替代console.log
  3. 改进了代码注释
  4. 优化了条件判断结构
  5. 确保资源被正确释放

这些改进可以提高代码的健壮性和可维护性,同时保持原有功能不变。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: robertkill, wjyrich

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

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

@robertkill
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Oct 10, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit 48d909d into linuxdeepin:master Oct 10, 2025
8 of 11 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