Skip to content

feat: add plugin interaction config for tray plugins - #488

Open
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:task-393299
Open

feat: add plugin interaction config for tray plugins#488
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:task-393299

Conversation

@wjyrich

@wjyrich wjyrich commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
  1. Added a new DConfig-based configuration module PluginInteractionConfig that controls plugin item interactions
  2. Supports three configurable items: itemActivationEnabled, itemContextMenuEnabled, and itemTooltipEnabled
  3. Each plugin can have its own per-plugin configuration using subpath identifiers
  4. Integrated the interaction config into PluginItem to conditionally disable popup, context menu, tooltip, and command execution
  5. Updated CMakeLists.txt to include Dtk::Core dependency and install the new config meta file

Log: Added plugin interaction configuration for tray plugins to control activation, context menu, and tooltip features

Influence:

  1. Test that plugin item popup applet is blocked when itemActivationEnabled is false
  2. Test that plugin context menu is hidden when itemContextMenuEnabled is false
  3. Test that tooltip is not shown when itemTooltipEnabled is false
  4. Verify that command execution is prevented when itemActivationEnabled is false
  5. Test dynamic config changes: enabling/disabling features should take effect immediately
  6. Verify per-plugin configuration isolation works correctly
  7. Test with plugins that have quick items to ensure they are excluded
  8. Verify that invalid DConfig falls back to all features enabled

feat: 为托盘插件添加交互配置控制

  1. 新增基于 DConfig 的配置模块 PluginInteractionConfig,用于控制插件项 交互
  2. 支持三个可配置项:itemActivationEnabled、itemContextMenuEnabled 和 itemTooltipEnabled
  3. 每个插件可以使用子路径标识符拥有独立的配置
  4. 将交互配置集成到 PluginItem 中,根据配置条件性地禁用弹出窗口、上下文 菜单、悬浮提示和命令执行
  5. 更新 CMakeLists.txt,添加 Dtk::Core 依赖并安装新的配置元文件

Log: 新增托盘插件交互配置功能,可独立控制插件的激活、上下文菜单和悬浮提
示特性

Influence:

  1. 测试当 itemActivationEnabled 为 false 时,插件项弹出窗口被阻止
  2. 测试当 itemContextMenuEnabled 为 false 时,插件上下文菜单被隐藏
  3. 测试当 itemTooltipEnabled 为 false 时,悬浮提示不显示
  4. 验证当 itemActivationEnabled 为 false 时,命令执行被阻止
  5. 测试动态配置变更:启用/禁用功能应即时生效
  6. 验证每个插件的配置隔离正常工作
  7. 测试快捷项插件以确保它们被排除在外
  8. 验证无效 DConfig 时回退为所有功能启用

PMS: TASK-393299

Summary by Sourcery

Add configurable interaction controls for tray plugin items, allowing activation, context menu and tooltip behavior to be managed per plugin via DConfig.

New Features:

  • Introduce PluginInteractionConfig DConfig module to control tray plugin item activation, context menu and tooltip visibility on a per-plugin basis.

Enhancements:

  • Integrate interaction configuration into PluginItem to conditionally block popups, context menus, tooltips and command execution, with dynamic response to config changes and excluding quick items.

Build:

  • Update trayplugin-loader build to depend on Dtk::Core, compile the new PluginInteractionConfig sources and install the plugin interaction DConfig meta file.

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

Sorry @wjyrich, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a DConfig-based PluginInteractionConfig module and wires it into tray PluginItem so per-plugin activation, context menu, tooltip, and command execution can be dynamically enabled/disabled, with build and config metadata updated to support the new behavior.

Sequence diagram for command execution with PluginInteractionConfig

sequenceDiagram
    actor User
    participant PluginItem
    participant PluginInteractionConfig
    participant PluginsItemInterface

    User->>PluginItem: executeCommand()
    PluginItem->>PluginInteractionConfig: itemActivationEnabled()
    alt [itemActivationEnabled is true]
        PluginItem->>PluginsItemInterface: itemCommand(m_itemKey)
        PluginsItemInterface-->>PluginItem: command
        PluginItem->>PluginItem: QProcess::startDetached(command)
        PluginItem-->>User: true
    else [itemActivationEnabled is false]
        PluginItem-->>User: false
    end
Loading

File-Level Changes

Change Details Files
Introduce DConfig-backed per-plugin interaction configuration and default behavior.
  • Implemented PluginInteractionConfig as a QObject wrapping Dtk::Core::DConfig with per-plugin subpath selection based on pluginId.
  • Defined three boolean interaction flags (itemActivationEnabled, itemContextMenuEnabled, itemTooltipEnabled) with default-true semantics and fallback to enabled when DConfig is invalid.
  • Hooked DConfig::valueChanged to update cached flags and emit change signals for context menu and tooltip enablement.
src/loader/plugininteractionconfig.h
src/loader/plugininteractionconfig.cpp
Integrate interaction config into tray PluginItem behavior to gate activation, context menus, tooltips, and commands.
  • Added a PluginInteractionConfig pointer member to PluginItem and instantiated it in init() for non-quick items using pluginId-based subpaths.
  • Short-circuited itemPopupApplet(), executeCommand(), pluginContextMenu(), pluginTooltip(), and itemTooltip() when corresponding interaction flags are disabled.
  • Adjusted enterEvent() to skip custom tooltip handling when tooltip interaction is disabled, delegating directly to QWidget.
  • Connected interaction config change signals so disabling context menu hides the current menu and disabling tooltip closes any visible tooltip, ensuring dynamic behavior.
src/loader/pluginitem.h
src/loader/pluginitem.cpp
Exclude quick plugin items from interaction configuration control.
  • Guarded PluginInteractionConfig creation in PluginItem::init() with a check against Dock::QUICK_ITEM_KEY so quick items are unaffected by interaction config.
src/loader/pluginitem.cpp
Update build configuration and DConfig metadata to support the new module and config schema.
  • Extended Dtk dependency to include the Core component and linked Dtk::Core to trayplugin-loader.
  • Added PluginInteractionConfig sources to the trayplugin-loader executable target.
  • Registered the new org.deepin.dde.dock.plugin.interaction.json meta file for org.deepin.dde.tray-loader in CMake, enabling DConfig-based interaction settings.
  • Updated SPDX copyright years where needed.
src/loader/CMakeLists.txt
src/loader/pluginitem.h
src/loader/configs/org.deepin.dde.dock.plugin.interaction.json

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

Comment thread src/loader/plugininteractionconfig.cpp Outdated
}
}

PluginInteractionConfig::PluginInteractionConfig(const QString &pluginId,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

可以使用下dconfig2cpp,生成对应配置文件的类,跟你这个封装类似,并且它还是异步的,也适合这里的需求,
https://github.com/linuxdeepin/dtkgui/blob/43e5e94c33c6124b43c9de8a76ef3903f77a647f/src/kernel/dguiapplicationhelper.cpp#L118

Comment thread src/loader/pluginitem.cpp Outdated

void PluginItem::enterEvent(QEnterEvent *event)
{
if (m_interactionConfig && !m_interactionConfig->itemTooltipEnabled())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这里是不是不需要在事件里拦截,之前的都是已经在实现里拦截了,

Comment thread src/loader/CMakeLists.txt Outdated
"${CMAKE_CURRENT_SOURCE_DIR}/configs/org.deepin.dde.dock.plugin.interaction.json")
set(PLUGIN_INTERACTION_CONFIG_HEADER
"${CMAKE_CURRENT_BINARY_DIR}/plugininteractionconfig.h")
add_custom_command(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread src/loader/pluginitem.cpp Outdated
this,
[this] {
if (!m_interactionConfig->itemContextMenuEnabled())
m_menu->hide();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

使用close吧,

18202781743
18202781743 previously approved these changes Jul 30, 2026
1. Added a new DConfig-based configuration module
`PluginInteractionConfig` that controls plugin item interactions
2. Supports three configurable items: itemActivationEnabled,
itemContextMenuEnabled, and itemTooltipEnabled
3. Each plugin can have its own per-plugin configuration using subpath
identifiers
4. Integrated the interaction config into PluginItem to conditionally
disable popup, context menu, tooltip, and command execution
5. Updated CMakeLists.txt to include Dtk::Core dependency and install
the new config meta file

Log: Added plugin interaction configuration for tray plugins to control
activation, context menu, and tooltip features

Influence:
1. Test that plugin item popup applet is blocked when
itemActivationEnabled is false
2. Test that plugin context menu is hidden when itemContextMenuEnabled
is false
3. Test that tooltip is not shown when itemTooltipEnabled is false
4. Verify that command execution is prevented when itemActivationEnabled
is false
5. Test dynamic config changes: enabling/disabling features should take
effect immediately
6. Verify per-plugin configuration isolation works correctly
7. Test with plugins that have quick items to ensure they are excluded
8. Verify that invalid DConfig falls back to all features enabled

feat: 为托盘插件添加交互配置控制

1. 新增基于 DConfig 的配置模块 `PluginInteractionConfig`,用于控制插件项
交互
2. 支持三个可配置项:itemActivationEnabled、itemContextMenuEnabled 和
itemTooltipEnabled
3. 每个插件可以使用子路径标识符拥有独立的配置
4. 将交互配置集成到 PluginItem 中,根据配置条件性地禁用弹出窗口、上下文
菜单、悬浮提示和命令执行
5. 更新 CMakeLists.txt,添加 Dtk::Core 依赖并安装新的配置元文件

Log: 新增托盘插件交互配置功能,可独立控制插件的激活、上下文菜单和悬浮提
示特性

Influence:
1. 测试当 itemActivationEnabled 为 false 时,插件项弹出窗口被阻止
2. 测试当 itemContextMenuEnabled 为 false 时,插件上下文菜单被隐藏
3. 测试当 itemTooltipEnabled 为 false 时,悬浮提示不显示
4. 验证当 itemActivationEnabled 为 false 时,命令执行被阻止
5. 测试动态配置变更:启用/禁用功能应即时生效
6. 验证每个插件的配置隔离正常工作
7. 测试快捷项插件以确保它们被排除在外
8. 验证无效 DConfig 时回退为所有功能启用

PMS: TASK-393299
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码通过DConfig机制实现了插件交互行为的动态控制,逻辑清晰且安全性良好
功能实现完整,路径处理使用了URL编码防止注入,但因版权年份存在笔误扣5分

■ 【详细分析】

  • 1.语法逻辑(基本正确)✓

PluginItem::init() 中对 m_interactionConfig 的初始化条件判断准确,各交互入口的配置检查逻辑无误。pluginInteractionConfigSubpath 使用 QStringLiteralQUrl::toPercentEncoding 构建子路径,语法正确。
潜在问题:无
建议:无

  • 2.代码质量(良好)✓

新增的配置文件结构规范,注释和描述完整。C++ 代码遵循了 Qt 的命名规范,使用匿名命名空间封装局部函数,避免全局污染。Lambda 表达式的使用简洁明了。
潜在问题:pluginitem.h 中的版权年份被修改为 2026,当前年份为 2024,存在明显的笔误。
建议:将版权年份修正为当前年份或保留原有年份范围。

  • 3.代码性能(无性能问题)✓

DConfig 对象在 init() 中按需创建一次,后续直接读取内存缓存,信号槽连接也是一次性操作,不会引入额外的性能开销。
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码在处理插件ID生成配置子路径时,使用了 QUrl::toPercentEncoding 进行编码,有效防止了路径遍历风险。DConfig 配置项设置为 private 可见性,限制了非授权修改。未发现安全风险。

  • 建议:无

■ 【改进建议代码示例】

--- a/src/loader/pluginitem.h
+++ b/src/loader/pluginitem.h
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
+// SPDX-FileCopyrightText: 2011 - 2024 UnionTech Software Technology Co., Ltd.
 //
 // SPDX-License-Identifier: LGPL-3.0-or-later

@deepin-ci-robot

Copy link
Copy Markdown

[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

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