Skip to content

fix: pass shortcut viewer theme from voice note#400

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Resurgamz:feature/fix-BUG365837-shortcut-theme
Jul 8, 2026
Merged

fix: pass shortcut viewer theme from voice note#400
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Resurgamz:feature/fix-BUG365837-shortcut-theme

Conversation

@Resurgamz

Copy link
Copy Markdown

Summary

  • Pass the effective voice note theme to deepin-shortcut-viewer when showing shortcuts
  • Handle follow-system dark appearance by checking the current window palette

Test

  • Built and installed deepin-voice-note locally
  • Verified the installed binary contains the --theme argument

PMS: BUG-365837

Pass the effective theme to deepin-shortcut-viewer when showing shortcuts.

显示快捷键弹窗时传递语音记事本当前有效主题。

Log: 传递快捷键弹窗主题

PMS: BUG-365837

Influence: 深色主题下由语音记事本触发的快捷键弹窗可按深色背景显示。

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

Please try again later or upgrade to continue using Sourcery

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "src/views/vnotemainwindow.cpp": [
        {
            "line": "            url = \"https://www.deepin.org/zh/agreement/privacy/\";",
            "line_number": 1926,
            "rule": "S35",
            "reason": "Url link | 20e2eab189"
        },
        {
            "line": "            url = \"https://www.uniontech.com/agreement/privacy-cn\";",
            "line_number": 1928,
            "rule": "S35",
            "reason": "Url link | 4850a00dd7"
        },
        {
            "line": "            url = \"https://www.deepin.org/en/agreement/privacy/\";",
            "line_number": 1932,
            "rule": "S35",
            "reason": "Url link | 38d42f63bf"
        },
        {
            "line": "            url = \"https://www.uniontech.com/agreement/privacy-en\";",
            "line_number": 1934,
            "rule": "S35",
            "reason": "Url link | f82409d3b5"
        }
    ]
}

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码成功修复了快捷键预览窗口未跟随系统深色主题切换的视觉不一致问题
逻辑清晰、无安全漏洞且性能开销极低,但缺少对DTK单例接口的防御性空指针检查扣5分

■ 【详细分析】

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

新增代码通过获取主题类型和背景色亮度值来综合判断深浅色模式,逻辑严密,能够有效覆盖主题类型异常但实际背景为深色的边缘场景。使用 windowColor.value() < 128 作为辅助判断是合理的亮度阈值选取。
潜在问题:DGuiApplicationHelper::instance() 在理论上存在返回空指针的极端可能,直接调用 themeType() 会导致空指针解引用崩溃。
建议:增加对 instance() 返回值的空指针防御性检查。

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

新增变量命名规范清晰(如 themeTypedarkTheme),三元运算符使用得当,代码可读性强,完全符合DTK组件的开发规范。
潜在问题:无
建议:可考虑为 128 这个魔法数字提取为具名常量以提升可维护性。

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

DGuiApplicationHelper::instance()->themeType()applicationPalette().window().color() 均为轻量级的内存读取操作,不涉及磁盘IO或复杂的系统调用,在快捷键触发的低频场景下性能消耗可忽略不计。
潜在问题:(无)
建议:保持现状即可。

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码通过 QProcess::startDetached 的参数列表形式启动外部进程,有效规避了Shell命令注入风险。新增的 param3 内容被严格限制为硬编码的 "dark" 或 "light" 字符串,无外部输入引入,不存在安全风险。

  • 建议:保持当前安全的参数传递方式,无需额外安全加固。

■ 【改进建议代码示例】

void VNoteMainWindow::onPreviewShortcut()
{
    QStringList shortcutString;
    QString param1 = "-j=" + QString(doc.toJson().data());
    QString param2 = "-p=" + QString::number(pos.x()) + "," + QString::number(pos.y());
    
    auto *guiHelper = DGuiApplicationHelper::instance();
    bool darkTheme = false;
    if (guiHelper) {
        const auto themeType = guiHelper->themeType();
        const QColor windowColor = guiHelper->applicationPalette().window().color();
        darkTheme = themeType == DGuiApplicationHelper::DarkType || windowColor.value() < 128;
    }
    
    QString param3 = "--theme=" + QString(darkTheme ? "dark" : "light");
    shortcutString << param1 << param2 << param3;

    QProcess *shortcutViewProcess = new QProcess(this);
    shortcutViewProcess->startDetached("deepin-shortcut-viewer", shortcutString);
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: max-lvs, Resurgamz

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

@Resurgamz

Copy link
Copy Markdown
Author

/merge

@deepin-bot

deepin-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This pr cannot be merged! (status: unstable)

@Resurgamz

Copy link
Copy Markdown
Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit f9f479f into linuxdeepin:master Jul 8, 2026
21 of 23 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