Skip to content

feat: The prompt images for the FLM(support camera switch) have been optimized.#448

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:release/eaglefrom
lichaofan2008:release/eagle
Jan 31, 2026
Merged

feat: The prompt images for the FLM(support camera switch) have been optimized.#448
deepin-bot[bot] merged 1 commit intolinuxdeepin:release/eaglefrom
lichaofan2008:release/eagle

Conversation

@lichaofan2008
Copy link
Contributor

@lichaofan2008 lichaofan2008 commented Jan 31, 2026

The prompt images for the FLM(support camera switch) have been optimized, and secondary prompts have also been added.
FLM设备(带有摄像头开关)的提示图片进行了优化,同时增加了二级提示。

Task: https://pms.uniontech.com/task-view-386441.html

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @lichaofan2008, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

"serial": 0,
"flags": ["global"],
"name": "is flm machine or not",
"name[zh_CN]": "是否是华为FLM机器",
Copy link

Choose a reason for hiding this comment

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

这里有可能不仅是FLM机型,还可能是其他如联想机型都可能使用这个图片,建议修改成通用支持 侧边支持摄像机关闭之类的

@lichaofan2008 lichaofan2008 force-pushed the release/eagle branch 2 times, most recently from c14da3a to b7e843b Compare January 31, 2026 07:13
…optimized.

The prompt images for the FLM(support camera switch) have been optimized, and secondary prompts have also been added.
FLM设备(带有摄像头开关)的提示图片进行了优化,同时增加了二级提示。

Task: https://pms.uniontech.com/task-view-386441.html
@lichaofan2008 lichaofan2008 changed the title feat: The prompt images for the FLM machine have been optimized. feat: The prompt images for the FLM(support camera switch) have been optimized. Jan 31, 2026
@deepin-ci-robot
Copy link

deepin pr auto review

Git Diff 代码审查报告

总体评估

本次提交主要实现了摄像头开关检测功能,当检测到设备支持摄像头开关时,会显示特定的提示信息和图标。代码整体结构合理,但存在一些可以改进的地方。

详细审查

1. 资源文件变更 (assets.qrc)

优点:

  • 正确添加了深色和浅色主题下的新图标资源

建议:

  • 文件命名规范一致,使用了camera_switch_not_on.svgcamera_switch_not_on_dark.svg,符合项目命名约定

2. 配置文件变更 (org.deepin.camera.encode.json)

优点:

  • 正确添加了supportCameraSwitch配置项
  • 配置项包含了中英文描述和权限设置

建议:

  • 配置项的名称supportCameraSwitch可以更明确,建议改为hasPhysicalCameraSwitch以更准确地表示"是否带有物理摄像头开关"

3. DataManager 类变更 (datamanager.h)

优点:

  • 添加了setIsSupportCameraSwitchisSupportCameraSwitch方法
  • 成员变量初始化为false,符合默认行为

建议:

  • 方法注释可以更详细,例如说明这个开关状态是如何获取的
  • 考虑将m_isSupportCameraSwitch成员变量声明为volatile,因为它可能被多个线程访问

4. 主程序变更 (main.cpp)

优点:

  • 在程序启动时正确读取配置并设置摄像头开关状态

建议:

  • 添加错误处理逻辑,当配置读取失败时应有默认处理
  • 考虑添加日志记录,便于调试

5. 视频窗口类变更 (videowidget.cpp/h)

优点:

  • 正确添加了二级提示文本项m_pCamErrItemSub
  • 在多个位置正确处理了新文本项的显示和隐藏
  • 根据摄像头开关状态显示不同的提示信息和图标

建议:

  • 代码重复问题: 在showNocam()onThemeTypeChanged()中存在大量重复代码,建议提取为私有方法
  • 文本长度处理: 提示文本较长,建议考虑多行显示或自动换行
  • 内存管理: 在多处使用new QSvgRenderer,建议检查是否有内存泄漏风险
  • 代码可读性: 一些条件判断嵌套较深,建议重构以提高可读性

6. 翻译文件变更 (deepin-camera_zh_CN.ts)

优点:

  • 正确添加了新的翻译条目
  • 翻译准确,符合中文表达习惯

具体改进建议

1. 代码重构建议

// 在videowidget.h中添加私有方法
private:
    void updateCameraErrorDisplay(bool isDarkTheme, bool isNoCamStatus);
    void setCameraErrorText(const QString &mainText, const QString &subText);

2. 内存管理改进

// 在videowidget.h中添加成员变量
private:
    QSvgRenderer *m_normalRenderer;
    QSvgRenderer *m_darkRenderer;
    QSvgRenderer *m_switchOnRenderer;
    QSvgRenderer *m_switchOnDarkRenderer;
    
    // 在构造函数中初始化
    m_normalRenderer = new QSvgRenderer(QString(":/images/icons/light/Not connected.svg"), this);
    // ... 其他渲染器初始化

3. 文本显示改进

// 在showNocam()中
m_pCamErrItemSub->setWordWrap(true);  // 启用自动换行
m_pCamErrItemSub->setTextWidth(370);  // 设置文本宽度

4. 线程安全改进

// 在datamanager.h中
volatile bool m_isSupportCameraSwitch = false;  // 使用volatile修饰
QMutex m_switchMutex;  // 添加互斥锁

bool isSupportCameraSwitch() { 
    QMutexLocker locker(&m_switchMutex);
    return m_isSupportCameraSwitch; 
};

void setIsSupportCameraSwitch(bool isTrue) { 
    QMutexLocker locker(&m_switchMutex);
    m_isSupportCameraSwitch = isTrue; 
};

安全性评估

  1. 配置文件读取没有进行充分的错误处理,可能导致程序异常
  2. 多线程访问m_isSupportCameraSwitch变量时没有同步机制,可能导致数据不一致
  3. 新增的文本项没有进行长度限制,可能导致UI显示异常

性能评估

  1. 频繁创建和销毁QSvgRenderer对象可能影响性能
  2. 文本渲染在每次显示时都重新计算位置,可以优化

总结

本次提交实现了摄像头开关检测功能,整体实现正确,但存在一些代码重复、内存管理和线程安全问题。建议进行上述改进以提高代码质量和稳定性。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@lichaofan2008
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jan 31, 2026

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 9bd8e96 into linuxdeepin:release/eagle Jan 31, 2026
16 of 19 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