feat: add plugin interaction config for tray plugins - #488
Conversation
Reviewer's GuideAdds 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 PluginInteractionConfigsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
| } | ||
| } | ||
|
|
||
| PluginInteractionConfig::PluginInteractionConfig(const QString &pluginId, |
There was a problem hiding this comment.
可以使用下dconfig2cpp,生成对应配置文件的类,跟你这个封装类似,并且它还是异步的,也适合这里的需求,
https://github.com/linuxdeepin/dtkgui/blob/43e5e94c33c6124b43c9de8a76ef3903f77a647f/src/kernel/dguiapplicationhelper.cpp#L118
|
|
||
| void PluginItem::enterEvent(QEnterEvent *event) | ||
| { | ||
| if (m_interactionConfig && !m_interactionConfig->itemTooltipEnabled()) |
There was a problem hiding this comment.
这里是不是不需要在事件里拦截,之前的都是已经在实现里拦截了,
| "${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( |
There was a problem hiding this comment.
| this, | ||
| [this] { | ||
| if (!m_interactionConfig->itemContextMenuEnabled()) | ||
| m_menu->hide(); |
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 pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 --- 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 |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
PluginInteractionConfigthat controls plugin item interactionsLog: Added plugin interaction configuration for tray plugins to control activation, context menu, and tooltip features
Influence:
feat: 为托盘插件添加交互配置控制
PluginInteractionConfig,用于控制插件项 交互Log: 新增托盘插件交互配置功能,可独立控制插件的激活、上下文菜单和悬浮提
示特性
Influence:
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:
Enhancements:
Build: