Skip to content

feat: add folder menu registry for plugin menu extensions - #1782

Open
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:pr/folder-menu-registry
Open

wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:pr/folder-menu-registry

Conversation

@wjyrich

@wjyrich wjyrich commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
  1. Add FolderMenuRegistry class to manage folder context menu extensions
  2. Support plugin-provided custom menu items via registerProvider interface
  3. Provide standard items (open-folder, undock-folder) plus plugin custom items
  4. Validate provider methods via Qt meta-object system before registration
  5. Prevent reserved IDs from being overridden by plugins
  6. Filter invalid, duplicate, hidden, and malformed menu items
  7. Revalidate actions at click time to handle plugin unload or state changes
  8. Guard against stale action IDs and disabled actions during dispatch
  9. Add unit tests covering registration, dispatch, validation, and lifecycle

Log: Added support for folder context menu extensions from plugins

Influence:

  1. Test default menu shows only folder name and Undock when no provider registered
  2. Verify custom actions from registered plugin are appended after standard items
  3. Test that reserved IDs (open-folder, undock-folder) cannot be overridden by plugins
  4. Verify duplicate, empty, or malformed menu item IDs are filtered out
  5. Test hidden items (visible=false) are not displayed
  6. Verify enabled/checkable/checked states are properly passed through
  7. Test trigger dispatch only reaches the correct provider plugin
  8. Verify actions are revalidated at click time and stale actions are rejected
  9. Test provider destruction or unregistration restores the default menu
  10. Verify registration is rejected for null, invalid, or thread- mismatched providers
  11. Test that a second plugin cannot silently replace an existing provider for the same folder type

feat: 添加文件夹菜单注册表以支持插件菜单扩展

  1. 新增 FolderMenuRegistry 类用于管理文件夹上下文菜单扩展
  2. 通过 registerProvider 接口支持插件提供的自定义菜单项
  3. 提供标准菜单项(open-folder、undock-folder)以及插件自定义项
  4. 注册前通过 Qt 元对象系统校验插件方法签名
  5. 防止插件覆盖保留的菜单项 ID
  6. 过滤无效、重复、隐藏及格式错误的菜单项
  7. 点击时重新校验动作以处理插件卸载或状态变化
  8. 派发时防止过期动作 ID 及已禁用动作
  9. 添加单元测试覆盖注册、派发、校验及生命周期

Log: 新增插件文件夹上下文菜单扩展支持

Influence:

  1. 测试未注册插件时默认菜单仅显示文件夹名称和取消停靠
  2. 验证已注册插件的自定义动作追加在标准菜单项之后
  3. 测试保留 ID(open-folder、undock-folder)无法被插件覆盖
  4. 验证重复、空或格式错误的菜单项 ID 被过滤
  5. 测试隐藏项(visible=false)不显示
  6. 验证 enabled/checkable/checked 状态正确传递
  7. 测试触发派发仅到达正确的插件提供者
  8. 验证点击时动作重新校验,过期动作被拒绝
  9. 测试插件销毁或注销后恢复默认菜单
  10. 验证空指针、无效或线程不匹配的插件注册被拒绝
  11. 测试第二个插件无法静默替换同一文件夹类型的现有提供者

PMS: TASK-397255

Summary by Sourcery

Enable safe plugin-provided folder context-menu actions through a validated registry.

New Features:

  • Add folder context-menu extensions supplied by registered plugins, combining standard actions with plugin-defined items.

Bug Fixes:

  • Prevent invalid, duplicate, hidden, reserved, stale, or disabled menu actions from being displayed or dispatched.

Enhancements:

  • Validate provider interfaces and ownership during registration, and restore default menus when providers are removed or destroyed.

Build:

  • Include the folder menu registry implementation in the task manager library and add a dedicated test target.

Tests:

  • Add unit coverage for menu generation, provider registration, action validation, dispatch, state changes, and provider lifecycle.

1. Add FolderMenuRegistry class to manage folder context menu extensions
2. Support plugin-provided custom menu items via registerProvider
interface
3. Provide standard items (open-folder, undock-folder) plus plugin
custom items
4. Validate provider methods via Qt meta-object system before
registration
5. Prevent reserved IDs from being overridden by plugins
6. Filter invalid, duplicate, hidden, and malformed menu items
7. Revalidate actions at click time to handle plugin unload or state
changes
8. Guard against stale action IDs and disabled actions during dispatch
9. Add unit tests covering registration, dispatch, validation, and
lifecycle

Log: Added support for folder context menu extensions from plugins

Influence:
1. Test default menu shows only folder name and Undock when no provider
registered
2. Verify custom actions from registered plugin are appended after
standard items
3. Test that reserved IDs (open-folder, undock-folder) cannot be
overridden by plugins
4. Verify duplicate, empty, or malformed menu item IDs are filtered out
5. Test hidden items (visible=false) are not displayed
6. Verify enabled/checkable/checked states are properly passed through
7. Test trigger dispatch only reaches the correct provider plugin
8. Verify actions are revalidated at click time and stale actions are
rejected
9. Test provider destruction or unregistration restores the default menu
10. Verify registration is rejected for null, invalid, or thread-
mismatched providers
11. Test that a second plugin cannot silently replace an existing
provider for the same folder type

feat: 添加文件夹菜单注册表以支持插件菜单扩展

1. 新增 FolderMenuRegistry 类用于管理文件夹上下文菜单扩展
2. 通过 registerProvider 接口支持插件提供的自定义菜单项
3. 提供标准菜单项(open-folder、undock-folder)以及插件自定义项
4. 注册前通过 Qt 元对象系统校验插件方法签名
5. 防止插件覆盖保留的菜单项 ID
6. 过滤无效、重复、隐藏及格式错误的菜单项
7. 点击时重新校验动作以处理插件卸载或状态变化
8. 派发时防止过期动作 ID 及已禁用动作
9. 添加单元测试覆盖注册、派发、校验及生命周期

Log: 新增插件文件夹上下文菜单扩展支持

Influence:
1. 测试未注册插件时默认菜单仅显示文件夹名称和取消停靠
2. 验证已注册插件的自定义动作追加在标准菜单项之后
3. 测试保留 ID(open-folder、undock-folder)无法被插件覆盖
4. 验证重复、空或格式错误的菜单项 ID 被过滤
5. 测试隐藏项(visible=false)不显示
6. 验证 enabled/checkable/checked 状态正确传递
7. 测试触发派发仅到达正确的插件提供者
8. 验证点击时动作重新校验,过期动作被拒绝
9. 测试插件销毁或注销后恢复默认菜单
10. 验证空指针、无效或线程不匹配的插件注册被拒绝
11. 测试第二个插件无法静默替换同一文件夹类型的现有提供者

PMS: TASK-397255
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 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

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a Qt-based FolderMenuRegistry that validates and owns one plugin provider per folder type, combines standard and filtered custom actions, safely revalidates actions at dispatch time, and includes unit coverage for registration, lifecycle, filtering, and triggering.

Sequence diagram for folder menu extension and safe action dispatch

sequenceDiagram
    participant Consumer as FolderMenuConsumer
    participant Registry as FolderMenuRegistry
    participant Provider as PluginProvider

    Consumer->>Registry: registerProvider(folderType, provider)
    Registry->>Provider: folderMenuActions(QString)
    Registry-->>Consumer: registration result
    Consumer->>Registry: menuItems(folderType, folderId, folderName)
    Registry->>Provider: folderMenuActions(folderId)
    Registry-->>Consumer: standardItems plus filtered custom items
    Consumer->>Registry: trigger(folderType, folderId, actionId)
    Registry->>Provider: folderMenuActions(folderId)
    alt action is valid and enabled
        Registry->>Provider: triggerFolderMenuAction(folderId, actionId)
        Provider-->>Registry: dispatch result
    else action is stale, hidden, disabled, or unknown
        Registry-->>Consumer: false
    end
Loading

File-Level Changes

Change Details Files
Introduces a registry that associates folder types with plugin-owned menu providers and composes framework and plugin menu actions.
  • Adds provider registration and explicit unregistration with null, folder-type, thread, method-signature, and duplicate-owner validation.
  • Builds standard open-folder and undock-folder items, then appends normalized plugin items.
  • Uses QPointer ownership tracking so destroyed providers automatically fall back to the default menu.
panels/dock/taskmanager/foldermenuregistry.cpp
panels/dock/taskmanager/foldermenuregistry.h
panels/dock/taskmanager/CMakeLists.txt
Adds defensive filtering and click-time validation for plugin menu actions.
  • Rejects reserved, duplicate, empty-ID, missing-name, hidden, and malformed entries while preserving enabled and checkable state.
  • Re-queries the provider before dispatch and blocks stale, disabled, reserved, or unknown action IDs.
  • Dispatches valid actions only to the provider registered for the requested folder type.
panels/dock/taskmanager/foldermenuregistry.cpp
Adds focused Qt tests covering menu construction, provider lifecycle, validation, and dispatch behavior.
  • Tests default and provider-extended menus, reserved and malformed item filtering, and action state propagation.
  • Tests provider ownership, duplicate registration rejection, unregistration, destruction recovery, stale-action rejection, and dispatch isolation.
tests/panels/dock/taskmanager/foldermenuregistrytests.cpp
tests/panels/dock/taskmanager/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

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

@deepin-bot

deepin-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.61
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1786

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