Skip to content

refactor: move dock context menu implementation to loader module#317

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
mhduiy:remind
May 28, 2025
Merged

refactor: move dock context menu implementation to loader module#317
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
mhduiy:remind

Conversation

@mhduiy

@mhduiy mhduiy commented May 28, 2025

Copy link
Copy Markdown
Contributor
  1. Deleted old dock context menu files from plugins/dde-dock/common
  2. Created new simplified DockContextMenu class in src/loader
  3. Simplified menu implementation by removing width calculation and Wayland specific code
  4. Changed PluginItem to use new DockContextMenu class
  5. Moved reminder dot painting logic directly into paintEvent
  6. Updated CMakeLists.txt to include new files

The change was made to:

  1. Reduce complexity by removing unused features
  2. Move menu implementation closer to where it's actually used
  3. Simplify maintenance by having a single implementation
  4. Remove dependency on Wayland-specific code in common module

refactor: 将停靠栏上下文菜单实现移至加载器模块

  1. 从 plugins/dde-dock/common 删除旧的停靠栏上下文菜单文件
  2. 在 src/loader 中创建新的简化版 DockContextMenu 类
  3. 通过移除宽度计算和Wayland特定代码简化菜单实现
  4. 修改 PluginItem 使用新的 DockContextMenu 类
  5. 将提醒点绘制逻辑直接移到 paintEvent 中
  6. 更新 CMakeLists.txt 包含新文件

这些修改的目的:

  1. 通过移除未使用功能降低复杂性
  2. 将菜单实现移到实际使用的位置
  3. 通过单一实现简化维护
  4. 移除公共模块中对Wayland特定代码的依赖

pms: TASK-377199

Summary by Sourcery

Move and streamline the dock context menu implementation into the loader module by deleting the old implementation and consolidating menu behavior into a single class.

Enhancements:

  • Introduce a unified DockContextMenu class in src/loader and remove width calculation and legacy Wayland handling.
  • Migrate reminder dot drawing into DockContextMenu’s paintEvent.
  • Update PluginItem to instantiate and configure the new DockContextMenu.

Chores:

  • Remove legacy dock context menu files from the common plugins module.
  • Update CMakeLists.txt to include the new DockContextMenu source files.

@mhduiy mhduiy requested a review from 18202781743 May 28, 2025 09:00
1. Deleted old dock context menu files from plugins/dde-dock/common
2. Created new simplified DockContextMenu class in src/loader
3. Simplified menu implementation by removing width calculation and
Wayland specific code
4. Changed PluginItem to use new DockContextMenu class
5. Moved reminder dot painting logic directly into paintEvent
6. Updated CMakeLists.txt to include new files

The change was made to:
1. Reduce complexity by removing unused features
2. Move menu implementation closer to where it's actually used
3. Simplify maintenance by having a single implementation
4. Remove dependency on Wayland-specific code in common module

refactor: 将停靠栏上下文菜单实现移至加载器模块

1. 从 plugins/dde-dock/common 删除旧的停靠栏上下文菜单文件
2. 在 src/loader 中创建新的简化版 DockContextMenu 类
3. 通过移除宽度计算和Wayland特定代码简化菜单实现
4. 修改 PluginItem 使用新的 DockContextMenu 类
5. 将提醒点绘制逻辑直接移到 paintEvent 中
6. 更新 CMakeLists.txt 包含新文件

这些修改的目的:
1. 通过移除未使用功能降低复杂性
2. 将菜单实现移到实际使用的位置
3. 通过单一实现简化维护
4. 移除公共模块中对Wayland特定代码的依赖

pms: TASK-377199
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

关键摘要:

  • DockContextMenu 类中的 suitableWidth 方法可以优化,避免每次都遍历所有动作来计算最大宽度。
  • DockContextMenu 类中的 paintEvent 方法在绘制小红点时,可以优化绘制逻辑,避免重复计算动作的几何信息。
  • DockContextMenuHelper 类中的 showContextMenu 方法在处理 JSON 数据时,应该添加错误处理逻辑,以防止无效的 JSON 数据导致程序崩溃。
  • DockContextMenuHelper 类中的 showContextMenu 方法在设置菜单的父窗口时,应该检查父窗口是否为空,以避免潜在的空指针异常。
  • DockContextMenuHelper 类中的 showContextMenu 方法在执行菜单时,应该确保菜单的显示和隐藏逻辑正确,避免菜单在显示后立即消失的问题。

是否建议立即修改:

@sourcery-ai

sourcery-ai Bot commented May 28, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR refactors the dock context menu by removing the legacy common-module implementation, introducing a streamlined DockContextMenu in the loader, integrating it into PluginItem, and updating the build configuration accordingly.

Sequence diagram for displaying context menu with reminder dots

sequenceDiagram
    participant User
    participant PluginItem
    participant DockContextMenu

    User->>PluginItem: Right-clicks to open context menu
    PluginItem->>DockContextMenu: new DockContextMenu()
    PluginItem->>DockContextMenu: addAction(action)
    Note right of PluginItem: Sets 'showReminder' property on action
    PluginItem->>DockContextMenu: exec()
    DockContextMenu->>DockContextMenu: paintEvent(e)
    Note right of DockContextMenu: If action.property("showReminder") is true, draws reminder dot
    DockContextMenu-->>User: Shows context menu with reminder dots
Loading

Class diagram for DockContextMenu and PluginItem

classDiagram
    class QMenu {
        <<Qt Class>>
    }
    class QWidget {
        <<Qt Class>>
    }
    class PluginItem {
        -DockContextMenu* m_menu
        +PluginItem(PluginsItemInterface*, QString)
        +initPluginMenu()
    }
    class DockContextMenu {
        +DockContextMenu(QWidget* parent)
        #paintEvent(QPaintEvent* e)
    }

    QMenu <|-- DockContextMenu
    QWidget <|-- PluginItem
    PluginItem o-- DockContextMenu : uses
Loading

File-Level Changes

Change Details Files
Remove legacy dock context menu implementation
  • Deleted old dockcontextmenu files in common module
plugins/dde-dock/common/dockcontextmenu.cpp
plugins/dde-dock/common/dockcontextmenu.h
Introduce simplified DockContextMenu class in loader
  • Created dockcontextmenu.h and dockcontextmenu.cpp
  • Implemented constructor with optional Wayland handling
  • Moved reminder dot painting into paintEvent
src/loader/dockcontextmenu.h
src/loader/dockcontextmenu.cpp
Integrate DockContextMenu into PluginItem
  • Replaced QMenu with DockContextMenu forward declaration
  • Updated menu instantiation to use DockContextMenu
  • Set showReminder property on actions
src/loader/pluginitem.h
src/loader/pluginitem.cpp
Update build configuration
  • Added dockcontextmenu sources to CMakeLists
src/loader/CMakeLists.txt

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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 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 @mhduiy - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@mhduiy

mhduiy commented May 28, 2025

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented May 28, 2025

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit 76218d6 into linuxdeepin:master May 28, 2025
7 of 10 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