Skip to content

feat(dconfig-editor): add copy field name in context menu#153

Merged
18202781743 merged 1 commit into
linuxdeepin:masterfrom
mhduiy:feat/copy-field-name
Jul 9, 2026
Merged

feat(dconfig-editor): add copy field name in context menu#153
18202781743 merged 1 commit into
linuxdeepin:masterfrom
mhduiy:feat/copy-field-name

Conversation

@mhduiy

@mhduiy mhduiy commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Add "copy field name" right-click menu option to copy the field key to clipboard in dde-dconfig-editor.

Changes

  • Added copy field name action to the right-click context menu on the rightmost list
  • Copies the field key name to clipboard on trigger
  • Renamed copyAction to copyValueAction for clarity
  • Added Chinese translation for the new menu item

1. Added "copy field name" action to the right-click context menu on the rightmost list
2. Copies the field key name to clipboard on trigger
3. Renamed `copyAction` to `copyValueAction` for clarity
4. Added Chinese translation for the new menu item

Log: Add "copy field name" right-click menu option to copy the field key to clipboard

feat(dconfig-editor): 右键菜单新增复制字段名功能

1. 在最右侧列表的右键菜单中新增"复制字段名"选项
2. 点击后将该字段的 key 名称复制到剪贴板
3. 将原有的 `copyAction` 重命名为 `copyValueAction`,避免歧义
4. 添加中文翻译

Log: 在右键菜单中增加复制字段名功能,点击可复制当前字段的 key 到剪贴板

@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 @mhduiy, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码实现了右键菜单复制字段名功能,逻辑清晰且无安全风险
语法完全正确且符合规范,无扣分项

■ 【详细分析】

  • 1.语法逻辑 完全正确✓

新增的菜单项创建与信号槽连接逻辑正确,Lambda表达式按值捕获key和按指针捕获clip,避免了悬空指针风险,menu与action的生命周期由Qt对象树自动管理
建议:保持当前实现方式

  • 2.代码质量 良好✓

变量命名从copyAction重构为copyFieldAction和copyValueAction,语义更加明确,同时补充了对应的国际化翻译文件
建议:保持当前的命名规范和国际化处理习惯

  • 3.代码性能 高效✓

仅在用户触发右键菜单时创建轻量级对象,剪贴板写入操作仅在点击时执行,无额外性能损耗
建议:无需优化

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
将配置项字段名写入剪贴板属于常规UI交互,输入源为函数传入的合法key参数,不涉及任何外部不可信输入处理、命令执行或内存越界操作
建议:无需额外安全加固

■ 【改进建议代码示例】

void Content::onCustomContextMenuRequested(QWidget *widget, const QString &appid, const QString &resource, const QString &subpath, const QString &key)
{
    QString value = "示例值";
    QString setCmd = "示例命令";

    QMenu *menu = new QMenu(widget);

    QAction *exportAction = menu->addAction(tr("export"));
    QAction *copyFieldAction = menu->addAction(tr("copy field name"));
    QAction *copyValueAction = menu->addAction(tr("copy value"));
    QAction *copyCmdAction = menu->addAction(tr("convert to cmd"));
    QAction *resetCmdAction = menu->addAction(tr("reset value"));

    QClipboard *clip = QApplication::clipboard();
    connect(copyFieldAction, &QAction::triggered, this, [clip, key] {
        clip->setText(key);
    });
    connect(copyValueAction, &QAction::triggered, this, [clip, value] {
        clip->setText(value);
    });
    connect(copyCmdAction, &QAction::triggered, this, [clip, setCmd] {
        clip->setText(setCmd);
    });

    menu->exec(QCursor::pos());
    delete menu;
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, mhduiy

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

@18202781743 18202781743 merged commit 3ff5b93 into linuxdeepin:master Jul 9, 2026
23 of 24 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