feat: add applet visibility control to DAppletItemModel and - #1676
feat: add applet visibility control to DAppletItemModel and#1676wjyrich wants to merge 1 commit into
Conversation
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| } | ||
|
|
||
| if (m_dconfig && m_dconfig->isValid()) { | ||
| connect(m_dconfig, &Dtk::Core::DConfig::valueChanged, |
There was a problem hiding this comment.
配置用subpath的方式去获取,而不是把所有插件都放在一个hiddenApplets里,每个插件都有一个单独的配置,方便后面override, https://github.com/18202781743/cskills/blob/4745ee77b82d808182f2a8681db135b0933fb2ba/dtk-development/references/config/concepts.md?plain=1#L74
| { | ||
| } | ||
|
|
||
| QList<QObject *> DAppletItemModel::rootObjects() const |
There was a problem hiding this comment.
这里rootObjects要改成visibleRootObjects么,要不要加个新的visibleRootObjects属性,
|
|
||
| QList<QObject *> rootObjects() const; | ||
| void append(QObject *rootObject); | ||
| void append(QObject *rootObject, bool visible = true); |
There was a problem hiding this comment.
这个是公共接口,不能直接加,另外也不需要,在添加的地方去拦截比较合适,
Add the ability to enable or disable DApplet instances via DConfig, controlling whether their root objects appear in the parent containment model. The new `enable` property is exposed as a Q_PROPERTY on DApplet, backed by a DConfig key `enable` under `org.deepin.dde.shell`. When loading, DApplet reads this config and watches for changes. Disabled applets remain loaded but their root objects are removed from the containment's `appletItems` model; re-enabling re-inserts them. This enables runtime toggling of applet visibility without unloading/ reloading plugins. Unit tests are added for the DAppletItemModel (append/remove) and the enable property change notification logic. Log: Added DApplet enable/disable feature via DConfig Influence: 1. Test creating an applet and verifying its enable property is true by default 2. Set enable to false via dde-dconfig and verify the applet root object is removed from the containment model 3. Set enable to true and verify the root object reappears 4. Verify that setEnable with the same value does not emit enableChanged signal 5. Test loading a root plugin (like dock) - its enable should not be affected (skipped) 6. Verify DConfig changes are watched and applied dynamically at runtime 7. Run unit tests: EnablePropertyNotifiesOnlyOnChange, AppendsRootObjects, RemovesRootObject feat: 添加支持通过 DConfig 启用/禁用 Applet 的接口 新增通过 DConfig 控制 DApplet 实例启用的能力,决定其根对象是否显示在父容 器模型中。 新的 `enable` 属性作为 DApplet 的 Q_PROPERTY 暴露,由 `org.deepin.dde.shell` 下的 DConfig 键 `enable` 驱动。加载时 DApplet 读 取该配置并监听变化。 被禁用的 Applet 实例仍保持加载,但根对象从容器的 `appletItems` 模型中 移除;重新启用后会重新追加。这实现了无需卸载/重新加载插件即可运行时切换 Applet 可见性。 新增了 DAppletItemModel(追加/移除)以及 enable 属性变更通知逻辑的单元 测试。 Log: 新增 DApplet 启用/禁用功能 Influence: 1. 测试创建 Applet 并验证其 enable 属性默认为 true 2. 通过 dde-dconfig 将 enable 设为 false,验证根对象已从容器模型中移除 3. 设为 true 后验证根对象重新出现 4. 验证 setEnable 相同值时不会触发 enableChanged 信号 5. 测试加载根插件(如 dock),其 enable 不应受影响(跳过) 6. 验证 DConfig 变化能被监听并在运行时动态生效 7. 运行单元测试:EnablePropertyNotifiesOnlyOnChange、 AppendsRootObjects、RemovesRootObject PMS: TASK-393299
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已足够健壮,无需修改。以下为性能优化的潜在方向示例(非必须):
// 在 DAppletItemModel 中使用 QSet<QObject*> 加速 contains 查找
// class DAppletItemModel {
// ...
// QSet<QObject*> m_objectSet;
// bool contains(QObject *obj) const { return m_objectSet.contains(obj); }
// }; |
DPluginLoader
Implement a framework-level hidden applets mechanism that allows suppressing individual applet root objects from the containment model without destroying them. The DAppletItemModel now maintains both a complete root objects list and a filtered visible subset. A new
setRootObjectVisiblemethod enables toggling visibility while preserving the original insertion order upon restoration. The DPluginLoader exposeshiddenApplets,isAppletHidden, andsetHiddenAppletsAPIs, and the shell synchronizes these with a DConfig keyhiddenApplets. Hidden applets remain loaded but their root objects are reparented to the applet and removed from the visual model. Unit tests verify order preservation and removal semantics.Log: Added applet visibility control API and DConfig integration
Influence:
feat: 为 DAppletItemModel 和 DPluginLoader 添加 Applet 显隐控制
实现框架级隐藏 Applet 机制,可在不销毁实例的前提下将其根对象从容
器模型中移除。DAppletItemModel 维护完整的根对象列表和可见子集,
新增
setRootObjectVisible方法支持按需切换显隐,恢复时保持原有插入顺序。DPluginLoader 提供
hiddenApplets、isAppletHidden和setHiddenApplets接口,Shell 通过 DConfig 键hiddenApplets同步配 置。隐藏的 Applet 仍保持加载,其根对象重新挂载到 Applet 自身并从视觉模型中移除。单元测试验证了顺序保持和移除语义。
Log: 新增 Applet 显隐控制接口和 DConfig 集成
Influence:
PMS: TASK-393299