Skip to content

pick develop/eagle to master #561

Merged
deepin-bot[bot] merged 4 commits into
linuxdeepin:masterfrom
add-uos:master
Nov 28, 2025
Merged

pick develop/eagle to master #561
deepin-bot[bot] merged 4 commits into
linuxdeepin:masterfrom
add-uos:master

Conversation

@add-uos
Copy link
Copy Markdown
Contributor

@add-uos add-uos commented Nov 28, 2025

pick develop/eagle to master

add-uos and others added 4 commits November 28, 2025 16:02
fix the get info from edit in order
read the edid info from system may not in order.

Log: fix the get info from edit in order
Bug: https://pms.uniontech.com/bug-view-305295.html
Change-Id: I5c124f5fd431b1e4a78eaeacd5c748b5fee0c6e7
fix the monitor info in single screen mode.

pick from: linuxdeepin@ed89899

Log: fix the monitor info in single screen mode.
Bug: https://pms.uniontech.com/bug-view-305295.html
fix get the storage size info from smartctl

pick from: linuxdeepin@899d8b4

Log: fix get the storage size info from smartctl.
Bug: https://pms.uniontech.com/bug-view-312479.html
Change-Id: I5ee5e270c0d5170d4c950d82bf028a0c6023693f
fix the monitor display info in special machine

pick-from: linuxdeepin@9a46594

Log: fix the monitor display info in special machine
Bug: https://pms.uniontech.com/bug-view-310413.html
Copy link
Copy Markdown

@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
Copy Markdown

deepin pr auto review

我来对这段代码进行审查,主要关注以下几个方面:

  1. 语法逻辑
  2. 代码质量
  3. 代码性能
  4. 代码安全

分析如下:

  1. 语法逻辑改进建议:
  • DeviceMonitor.cpp 中的 setInfoFromXradr 函数新增的 Display Input 检查逻辑位置不太合理,应该放在函数开始处进行参数验证
  • DeviceStorage.cpp 中的比较逻辑使用了浮点数比较,建议使用 qFuzzyCompare 替代手动实现的浮点数比较
  1. 代码质量改进建议:
  • 多处使用了魔法数字(如 specialComType 的 5 和 6),建议定义常量或枚举
  • 字符串替换操作(如 "x" 到 "×")重复出现,建议封装成工具函数
  • DeviceMonitor.cpp 中的 loadBaseDeviceInfo 函数的 if 条件判断可以优化结构
  1. 代码性能改进建议:
  • DeviceStorage.cpp 中的正则表达式可以预编译,避免重复创建
  • HWGenerator.cpp 中的文件遍历可以使用 QDirIterator 替代 entryInfoList,更节省内存
  1. 代码安全改进建议:
  • DeviceStorage.cpp 中的浮点数比较需要考虑精度问题
  • 字符串操作建议增加空值检查
  • 文件操作建议增加错误处理

具体修改建议:

  1. 将 Display Input 检查逻辑移到函数开始处:
bool DeviceMonitor::setInfoFromXradr(const QString &main, const QString &edid, const QString &name)
{
    // 参数验证
    if (main.isEmpty() || edid.isEmpty() || name.isEmpty()) {
        return false;
    }

    // Display Input 检查
    for(const auto& info : m_LstBaseInfo) {
        if (info.first.contains("Display Input")) {
            if (!main.contains(info.second, Qt::CaseInsensitive)) {
                return false;
            }
        }
    }

    // 其余逻辑...
}
  1. 优化字符串替换操作:
// 在工具类中添加
QString formatResolution(const QString& resolution) {
    return resolution.replace("x", "×", Qt::CaseInsensitive);
}

// 使用时
m_CurrentResolution = formatResolution(QString("%1@%2").arg(match.captured(1)).arg(curRate));
  1. 改进浮点数比较:
bool DeviceStorage::compareSize(const QString &size1, const QString &size2)
{
    double num1 = 0;
    double num2 = 0;
    QRegularExpression reg(".*\\[(\\d+\\.?\\d+).*\\]");
    
    if (reg.match(size1).hasMatch()) {
        num1 = reg.match(size1).captured(1).toDouble();
    }
    if (reg.match(size2).hasMatch()) {
        num2 = reg.match(size2).captured(1).toDouble();
    }

    return qFuzzyCompare(num1, num2) ? size2 : (num1 > num2 ? size1 : size2);
}
  1. 优化文件遍历:
void HWGenerator::generatorMonitorDevice()
{
    QDir toDir(toPath_);
    if (!toDir.exists()) {
        return;
    }

    QDirIterator it(toPath_, QDir::Files, QDirIterator::Subdirectories);
    while (it.hasNext()) {
        QFileInfo fileInfo = it.nextFileInfo();
        if (!fileInfo.fileName().startsWith("card")) {
            continue;
        }
        // 处理文件...
    }
}
  1. 添加常量定义:
namespace DeviceConstants {
    enum SpecialComputerType {
        NormalCom = 5,
        SpecialCom = 6
    };
}

这些改进可以提高代码的可维护性、性能和安全性。建议在实施这些更改时进行充分的测试,确保不会影响现有功能。

@deepin-ci-robot
Copy link
Copy Markdown

[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
Copy Markdown
Contributor Author

add-uos commented Nov 28, 2025

/merge

@deepin-bot deepin-bot Bot merged commit eac045a into linuxdeepin:master Nov 28, 2025
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.

3 participants