Skip to content

feat: add DConfig toggles for dock context menu and docked applications - #1674

Merged
wjyrich merged 1 commit into
linuxdeepin:masterfrom
wjyrich:task-393299
Jul 30, 2026
Merged

feat: add DConfig toggles for dock context menu and docked applications#1674
wjyrich merged 1 commit into
linuxdeepin:masterfrom
wjyrich:task-393299

Conversation

@wjyrich

@wjyrich wjyrich commented Jul 27, 2026

Copy link
Copy Markdown
Contributor
  1. Add DConfig "enableContextMenu" to control the dock empty area context menu and touch-and-hold menu. The setting is applied in QML to conditionally show/hide the menu.
  2. Add DConfig "enableDockedApplications" to control docked applications on the taskbar. When disabled, non-running docked apps are hidden, docking changes are rejected, but the saved list is preserved. The setting propagates through C++ models and settings classes to block dock/undock requests and menu items.
  3. Update DConfig JSON files for both dock and taskmanager with appropriate metadata and translations.
  4. Add signals and properties for both settings in DockPanel, DockSettings, and TaskManagerSettings.
  5. Refactor DockGlobalElementModel::loadDockedElements to conditionally load docked elements based on the setting.
  6. Modify desktop file parsers and task manager to check the setting before allowing dock/undock operations.
  7. Update QML to close open context menu if disabled during runtime.

Log: Added DConfig options to enable/disable dock empty area context menu and docked applications.

Influence:

  1. Test dock empty area context menu with enableContextMenu set to true and false.
  2. Test dock touch-and-hold menu on tablets with enableContextMenu.
  3. Test docked applications with enableDockedApplications set to true and false.
  4. Verify non-running docked applications are hidden when disabled.
  5. Verify dock/undock operations are blocked when disabled.
  6. Verify the saved docked application list is preserved when toggling the setting.
  7. Test that opening dock menu is prevented when disabled at runtime.
  8. Test that currently open dock menu is closed when setting is disabled.

feat: 添加任务栏右键菜单和驻留应用功能的DConfig开关

  1. 添加DConfig配置项"enableContextMenu",控制任务栏空白区域右键菜单及触 摸长按菜单的显示与隐藏,该设置在QML中条件启用。
  2. 添加DConfig配置项"enableDockedApplications",控制任务栏驻留应用。禁用 时,隐藏未运行的驻留应用并拒绝驻留状态更改,但保留已保存的驻留列表。该设
    置通过C++模型和设置类传播,阻止驻留/取消驻留请求及菜单项。
  3. 更新任务栏和任务管理器的DConfig JSON文件,包含元数据和翻译。
  4. 在DockPanel、DockSettings和TaskManagerSettings中添加对应信号和属性。
  5. 重构DockGlobalElementModel::loadDockedElements,根据设置条件加载驻留 元素。
  6. 修改桌面文件解析器和任务管理器,在执行驻留/取消驻留操作前检查该设置。
  7. 在QML中,若运行时禁用设置,则关闭已打开的任务栏菜单。

Log: 新增DConfig选项,用于启用或禁用任务栏空白区域右键菜单和驻留应用
功能。

Influence:

  1. 测试enableContextMenu分别为true和false时,任务栏空白区域右键菜单是否 正常显示或隐藏。
  2. 测试平板模式下enableContextMenu对触摸长按菜单的影响。
  3. 测试enableDockedApplications分别为true和false时,驻留应用的状态。
  4. 验证禁用后,未运行的驻留应用是否被隐藏。
  5. 验证禁用后,驻留/取消驻留操作是否被阻止。
  6. 验证切换设置时,已保存的驻留应用列表是否被保留。
  7. 测试运行时禁用设置时,打开任务栏菜单是否被阻止。
  8. 测试运行时禁用设置时,已打开的任务栏菜单是否被关闭。

PMS: TASK-393299

@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

auto pair = elementInfo.split('/');
if (pair.size() != 2)
continue;
if (TaskManagerSettings::instance()->dockedApplicationsEnabled()) {

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.

dockedApplicationsEnabled 如果为false,后面的都不用执行了吧,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

最后一部分是在 禁用驻留的时候, 保证任务栏已驻留应用能够消失 的判断。

@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

1. Add DConfig "enableContextMenu" to control the dock empty area
context menu and touch-and-hold menu. The setting is applied in QML to
conditionally show/hide the menu.
2. Add DConfig "enableDockedApplications" to control docked applications
on the taskbar. When disabled, non-running docked apps are hidden,
docking changes are rejected, but the saved list is preserved. The
setting propagates through C++ models and settings classes to block
dock/undock requests and menu items.
3. Update DConfig JSON files for both dock and taskmanager with
appropriate metadata and translations.
4. Add signals and properties for both settings in DockPanel,
DockSettings, and TaskManagerSettings.
5. Refactor DockGlobalElementModel::loadDockedElements to conditionally
load docked elements based on the setting.
6. Modify desktop file parsers and task manager to check the setting
before allowing dock/undock operations.
7. Update QML to close open context menu if disabled during runtime.

Log: Added DConfig options to enable/disable dock empty area context
menu and docked applications.

Influence:
1. Test dock empty area context menu with enableContextMenu set to true
and false.
2. Test dock touch-and-hold menu on tablets with enableContextMenu.
3. Test docked applications with enableDockedApplications set to true
and false.
4. Verify non-running docked applications are hidden when disabled.
5. Verify dock/undock operations are blocked when disabled.
6. Verify the saved docked application list is preserved when toggling
the setting.
7. Test that opening dock menu is prevented when disabled at runtime.
8. Test that currently open dock menu is closed when setting is
disabled.

feat: 添加任务栏右键菜单和驻留应用功能的DConfig开关

1. 添加DConfig配置项"enableContextMenu",控制任务栏空白区域右键菜单及触
摸长按菜单的显示与隐藏,该设置在QML中条件启用。
2. 添加DConfig配置项"enableDockedApplications",控制任务栏驻留应用。禁用
时,隐藏未运行的驻留应用并拒绝驻留状态更改,但保留已保存的驻留列表。该设
置通过C++模型和设置类传播,阻止驻留/取消驻留请求及菜单项。
3. 更新任务栏和任务管理器的DConfig JSON文件,包含元数据和翻译。
4. 在DockPanel、DockSettings和TaskManagerSettings中添加对应信号和属性。
5. 重构DockGlobalElementModel::loadDockedElements,根据设置条件加载驻留
元素。
6. 修改桌面文件解析器和任务管理器,在执行驻留/取消驻留操作前检查该设置。
7. 在QML中,若运行时禁用设置,则关闭已打开的任务栏菜单。

Log: 新增DConfig选项,用于启用或禁用任务栏空白区域右键菜单和驻留应用
功能。

Influence:
1. 测试enableContextMenu分别为true和false时,任务栏空白区域右键菜单是否
正常显示或隐藏。
2. 测试平板模式下enableContextMenu对触摸长按菜单的影响。
3. 测试enableDockedApplications分别为true和false时,驻留应用的状态。
4. 验证禁用后,未运行的驻留应用是否被隐藏。
5. 验证禁用后,驻留/取消驻留操作是否被阻止。
6. 验证切换设置时,已保存的驻留应用列表是否被保留。
7. 测试运行时禁用设置时,打开任务栏菜单是否被阻止。
8. 测试运行时禁用设置时,已打开的任务栏菜单是否被关闭。

PMS: TASK-393299
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:92分

■ 【总体评价】

代码成功实现了任务栏右键菜单和驻留应用的动态开关功能,逻辑结构清晰且符合规范。
逻辑正确且无明显安全漏洞,仅在状态同步和条件判断的简洁性上存在轻微优化空间,扣除少量分数。

■ 【详细分析】

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

dockglobalelementmodel.cpploadDockedElements 函数中,当 dockedApplicationsEnabled 为 false 时,newDocked 列表为空,能够正确触发后续未运行驻留应用的移除逻辑。taskmanager.cpp 中的拦截逻辑正确返回了 false。
潜在问题:在 main.qml 中,右键点击逻辑被拆分为两个独立的 if 语句判断 Panel.contextMenuEnabled,虽然功能正确,但存在冗余判断。
建议:合并 main.qml 中的条件判断以简化逻辑;确保 loadDockedElements 在禁用开关时能正确清理已显示的非运行驻留项。

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

代码遵循了现有的架构设计,DConfig 配置项的添加完整包含了多语言支持。dockglobalelementmodel.cpp 中将 lambda 捕获从 [this, &id] 优化为 [&id],移除了不必要的 this 捕获。
潜在问题:desktopfileamparser.cpp 中在 InterfacesRemoved 回调里直接调用了 removeDockedElement,虽然不影响功能,但未与 setDocked 的拦截逻辑保持一致的风格。
建议:统一驻留状态变更的入口与拦截逻辑,保持代码一致性。

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

配置项变更通过信号槽机制触发,仅在开关状态改变时执行一次列表刷新,不会引入额外的性能开销。loadDockedElements 的复杂度未发生改变。
潜在问题:无
建议:无需特别优化。

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次代码修改主要涉及功能开关的添加与 UI 交互逻辑调整,未引入外部输入处理、文件操作或高危系统调用,不存在命令注入、内存溢出等安全风险。

  • 建议:继续保持对 DConfig 读写权限的严格控制。

■ 【改进建议代码示例】

--- a/panels/dock/package/main.qml
+++ b/panels/dock/package/main.qml
@@ -433,10 +433,9 @@ Window {
             onTapped: function(eventPoint, button) {
                 let lastActive = MenuHelper.activeMenu
                 MenuHelper.closeCurrent()
-                if (button === Qt.RightButton && Panel.contextMenuEnabled) {
+                if (button === Qt.RightButton && Panel.contextMenuEnabled && lastActive !== dockMenuLoader.item) {
                     dockMenuLoader.active = true
-                }
-                if (button === Qt.RightButton && Panel.contextMenuEnabled && lastActive !== dockMenuLoader.item) {
                     requestShowDockMenu()
                 }
                 if (button === Qt.LeftButton) {

@wjyrich
wjyrich merged commit 46492ed into linuxdeepin:master Jul 30, 2026
11 of 13 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