Skip to content

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Oct 28, 2025

  1. Added enabled property binding to prevent dock panel dragging when
    Panel.locked is true
  2. This ensures the dock panel cannot be accidentally moved when the
    panel is locked
  3. Maintains existing cursor shape behavior that shows locked state
  4. Improves user experience by preventing unintended interactions with
    locked panels

fix: 锁定状态下禁用停靠面板拖动

  1. 添加 enabled 属性绑定,当 Panel.locked 为 true 时防止停靠面板拖动
  2. 确保面板锁定时不会意外移动停靠面板
  3. 保持现有的光标形状行为以显示锁定状态
  4. 通过防止与锁定面板的意外交互来改善用户体验

PMS: TASK-383127

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 28, 2025

Reviewer's Guide

This PR enables activating applications by clicking on the taskbar when it’s locked by adding a click handler with coordinate mapping across all dock positions and exposing the app container for external access.

Sequence diagram for handling drag area click in locked taskbar state

sequenceDiagram
    participant User as actor User
    participant DragArea
    participant Panel
    participant TaskManager
    participant AppContainer
    participant DataModel

    User->>DragArea: Click (x, y)
    DragArea->>Panel: onClicked(mouse)
    alt Panel.locked == true
        Panel->>Panel: handleDragAreaClick(x, y)
        Panel->>TaskManager: Get appContainer, dataModel
        Panel->>AppContainer: mapToItem(x, y)
        Panel->>AppContainer: indexAt(targetPos.x, targetPos.y)
        AppContainer-->>Panel: clickedIndex
        Panel->>DataModel: index(clickedIndex, 0)
        Panel->>TaskManager: requestActivate(modelIndex)
    end
Loading

Class diagram for updated TaskManager and appContainer exposure

classDiagram
    class TaskManager {
        +int dockOrder
        +int remainingSpacesForTaskManager
        +int forceRelayoutWorkaround
        +appContainer
    }
    class AppContainer {
        +implicitWidth
        +height
        +width
        +indexAt(x, y)
    }
    TaskManager --> AppContainer: appContainer (alias)
Loading

File-Level Changes

Change Details Files
Added handleDragAreaClick function with coordinate mapping and activation logic
  • Guard early return if panel unlocked or task manager unavailable
  • Map drag area click to app container coordinates
  • Adjust target coordinates for each dock position
  • Determine clicked app index and call requestActivate
panels/dock/package/main.qml
Connected click handler in drag area’s onClicked event
  • Invoke handleDragAreaClick(mouse.x, mouse.y) when Panel.locked is true
panels/dock/package/main.qml
Exposed appContainer property in TaskManager for external usage
  • Added property alias appContainer to TaskManager
panels/dock/taskmanager/package/TaskManager.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

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 - here's some feedback:

  • handleDragAreaClick has duplicate logic for Dock.Bottom and Dock.Top—consider merging those branches to reduce duplication.
  • After invoking handleDragAreaClick, explicitly accept or stop the click event to prevent unintended propagation since onClicked handlers don’t use the returned boolean.
  • The alias property name 'appContainer' shadows the id inside TaskManager.qml—consider renaming the alias to avoid potential collisions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- handleDragAreaClick has duplicate logic for Dock.Bottom and Dock.Top—consider merging those branches to reduce duplication.
- After invoking handleDragAreaClick, explicitly accept or stop the click event to prevent unintended propagation since onClicked handlers don’t use the returned boolean.
- The alias property name 'appContainer' shadows the id inside TaskManager.qml—consider renaming the alias to avoid potential collisions.

## Individual Comments

### Comment 1
<location> `panels/dock/package/main.qml:284-295` </location>
<code_context>
+        
+        // 根据dock位置调整坐标映射逻辑
+        let targetPos = Qt.point(0, 0)
+        if (Panel.position === Dock.Bottom) {
+            targetPos.x = dragAreaPos.x
+            targetPos.y = appContainer.height / 2
+        } else if (Panel.position === Dock.Top) {
+            targetPos.x = dragAreaPos.x  
+            targetPos.y = appContainer.height / 2
+        } else if (Panel.position === Dock.Left) {
+            targetPos.x = appContainer.width / 2
+            targetPos.y = dragAreaPos.y
+        } else if (Panel.position === Dock.Right) {
+            targetPos.x = appContainer.width / 2
+            targetPos.y = dragAreaPos.y
</code_context>

<issue_to_address>
**suggestion:** Coordinate mapping logic for dock positions is duplicated for Top and Bottom.

Consolidate the Dock.Top and Dock.Bottom cases since they share identical logic, which will simplify the code and make future maintenance easier.

```suggestion
        if (Panel.position === Dock.Top || Panel.position === Dock.Bottom) {
            targetPos.x = dragAreaPos.x
            targetPos.y = appContainer.height / 2
        } else if (Panel.position === Dock.Left) {
            targetPos.x = appContainer.width / 2
            targetPos.y = dragAreaPos.y
        } else if (Panel.position === Dock.Right) {
            targetPos.x = appContainer.width / 2
            targetPos.y = dragAreaPos.y
```
</issue_to_address>

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.

@wjyrich wjyrich force-pushed the task-appLauncherWithLockdock branch from 9fc7ca4 to ff12740 Compare October 28, 2025 07:34
1. Added enabled property binding to prevent dock panel dragging when
Panel.locked is true
2. This ensures the dock panel cannot be accidentally moved when the
panel is locked
3. Maintains existing cursor shape behavior that shows locked state
4. Improves user experience by preventing unintended interactions with
locked panels

fix: 锁定状态下禁用停靠面板拖动

1. 添加 enabled 属性绑定,当 Panel.locked 为 true 时防止停靠面板拖动
2. 确保面板锁定时不会意外移动停靠面板
3. 保持现有的光标形状行为以显示锁定状态
4. 通过防止与锁定面板的意外交互来改善用户体验

PMS: TASK-383127
@wjyrich wjyrich force-pushed the task-appLauncherWithLockdock branch from ff12740 to 8e10276 Compare October 28, 2025 08:23
@deepin-ci-robot
Copy link

deepin pr auto review

我来分析这段代码的变更:

  1. 语法逻辑分析:
  • 新增了 enabled: !Panel.locked 属性绑定
  • 这个改动与下面的 cursorShape 判断形成了呼应,都是基于 Panel.locked 状态
  • 逻辑上是合理的:当面板被锁定时,禁用鼠标交互
  1. 代码质量评价:
  • 优点:
    • 代码简洁明了
    • 与现有的锁定状态判断保持一致
    • 提高了代码的可维护性
  • 建议:
    • 可以考虑添加注释说明这个属性的作用
    • 建议将 Panel.locked 的判断逻辑统一管理,避免多处重复判断
  1. 性能影响:
  • 这个改动对性能影响很小
  • 属性绑定的开销很小
  • 不会影响整体性能
  1. 安全性考虑:
  • 这个改动提高了安全性
  • 通过禁用鼠标交互,防止了在锁定状态下的意外操作
  • 降低了误操作的风险

改进建议:

  1. 添加注释说明:
// 当面板锁定时禁用鼠标交互
enabled: !Panel.locked
  1. 考虑将锁定状态的判断逻辑提取为一个单独的属性:
readonly property bool isInteractionEnabled: !Panel.locked
enabled: isInteractionEnabled
  1. 如果这个锁定状态判断在多处使用,建议创建一个专门的工具类来管理这些状态。

总体来说,这是一个很好的改进,提高了代码的安全性和用户体验。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@wjyrich wjyrich changed the title feat: add taskbar click handler for locked state fix: disable dock panel dragging when locked Oct 28, 2025
@wjyrich
Copy link
Contributor Author

wjyrich commented Oct 28, 2025

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Oct 28, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit 2230135 into linuxdeepin:master Oct 28, 2025
8 of 11 checks passed
@wjyrich wjyrich deleted the task-appLauncherWithLockdock branch October 28, 2025 08:27
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