Skip to content

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Dec 1, 2025

pick develop/eagle to master

GongHeng2017 and others added 2 commits December 1, 2025 13:08
-- Add extra information display logic.

Log: add feature for GPU.
Task: https://pms.uniontech.com/task-view-378987.html
Fixed refresh rate errors and spelling mistakes in Device Manager →
Display → Supported Resolutions. Now accurately obtains resolutions from
xrandr output (keeping only integer values) instead of potentially
problematic hwinfo detection.

pick from: linuxdeepin@496262e

Log: Fix display resolution detection method
Bug: https://pms.uniontech.com/bug-view-325731.html
Change-Id: I377caf0def3455191a3189eac734a608443b47e6
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 @add-uos, 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

deepin pr auto review

我来对这个git diff进行代码审查:

  1. GPU信息处理改进:
// 添加了版本信息的处理
constexpr char kVersion[] { "Version" };

优点:

  • 增加了版本信息字段,使GPU信息更完整
  • 使用constexpr确保编译时计算

建议:

  • 考虑为所有GPU相关字段创建一个结构体,统一管理这些常量
  1. DeviceGpu类改进:
void DeviceGpu::setGpuInfoByCustom(const QMap<QString, QString> &mapInfo)
{
    QMap<QString, QString>::const_iterator it = mapInfo.constBegin();
    for (; it != mapInfo.constEnd(); ++it) {
        if (it.key() == "Name") {
            m_Name = it.value();
        } else if (it.key() == "Vendor") {
            m_Vendor = it.value();
        } // ... 其他字段处理
    }
}

优点:

  • 增加了对Version字段的支持
  • 添加了m_extraInfo来存储额外信息
  • 使用const_iterator确保不会意外修改数据

建议:

  • 可以使用switch语句或QMap来优化多重if-else结构
  • 考虑添加字段验证逻辑,确保数据有效性
  1. DeviceMonitor改进:
QMap<QString, QStringList> DeviceMonitor::getMonitorResolutionMap(QString rawText, QString key, bool round)

优点:

  • 新增了分辨率映射功能
  • 支持格式化输出
  • 处理了断开连接的显示器

建议:

  • 函数参数应该使用const引用
  • 考虑将大函数拆分成更小的函数
  • 添加错误处理和边界检查
  1. MainWindow中的异步处理:
QtConcurrent::run([=](){
    QThread::msleep(700);
    emit mp_DeviceWidget->itemClicked(mp_DeviceWidget->currentIndex());
});

优点:

  • 使用QtConcurrent处理异步操作
  • 解决了bug-325731

建议:

  • 固定的700ms延时可能不是最优解,建议根据实际情况动态调整
  • 考虑添加错误处理机制
  • 使用信号槽的连接类型应该明确指定
  1. DeviceInfo类改进:
bool DeviceBaseInfo::isValueValid(const QString &value)

优点:

  • 将参数改为const引用,提高安全性
  • 避免了不必要的拷贝

建议:

  • 考虑添加更详细的验证规则
  • 可以添加日志记录,便于调试
  1. ThreadExecXrandr改进:
void ThreadExecXrandr::loadXrandrVerboseInfo(QList<QMap<QString, QString>> &lstMap)

优点:

  • 增加了xrandr信息的获取
  • 改进了显示器信息的处理

建议:

  • 考虑添加错误处理
  • 可以使用更安全的字符串处理方式
  • 考虑添加性能监控

总体建议:

  1. 代码中添加了更多功能,但同时也增加了复杂性,建议:

    • 添加更多的单元测试
    • 完善错误处理机制
    • 添加更详细的代码注释
  2. 性能优化:

    • 考虑使用移动语义减少不必要的拷贝
    • 对于频繁调用的函数,考虑使用内联
    • 优化字符串操作,减少临时对象创建
  3. 安全性:

    • 添加输入验证
    • 使用更安全的字符串处理方式
    • 考虑添加边界检查
  4. 可维护性:

    • 考虑将一些常量提取到配置文件
    • 统一错误处理方式
    • 规范化日志输出格式

这些改进建议旨在提高代码的质量、性能和可维护性。建议在实施这些改进时,先进行小范围测试,确保不会引入新的问题。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

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

@add-uos
Copy link
Contributor Author

add-uos commented Dec 1, 2025

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 1, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit cffb3ac into linuxdeepin:master Dec 1, 2025
15 of 17 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.

4 participants