fix: the flmx device of monitor display#558
fix: the flmx device of monitor display#558deepin-bot[bot] merged 5 commits intolinuxdeepin:masterfrom
Conversation
fix the flmx device of monitor display pick form: linuxdeepin@4d4e3f7 Log: fix the flmx device of monitor display Task: https://pms.uniontech.com/task-view-368603.html
Reviewer's guide (collapsed on small PRs)Reviewer's GuideGate TOML-based monitor info initialization on a specific communication type so that m_IsTomlSet is only marked true for specialComType == 2, preventing unintended TOML overrides for other monitor devices. Sequence diagram for TOML-based monitor info initialization gatingsequenceDiagram
participant System as System
participant DeviceMonitor as DeviceMonitor
participant Common as Common
System->>DeviceMonitor: setInfoFromTomlOneByOne(mapInfo)
DeviceMonitor->>Common: read specialComType
alt specialComType == 2
DeviceMonitor->>DeviceMonitor: m_IsTomlSet = true
DeviceMonitor->>DeviceMonitor: setTomlAttribute(Type, m_Model)
DeviceMonitor->>DeviceMonitor: setTomlAttribute(Brand, m_Brand)
DeviceMonitor-->>System: TomlFixMethod (TOML_* based on processing)
else specialComType != 2
DeviceMonitor->>DeviceMonitor: m_IsTomlSet remains false
DeviceMonitor->>DeviceMonitor: setTomlAttribute(Type, m_Model)
DeviceMonitor->>DeviceMonitor: setTomlAttribute(Brand, m_Brand)
DeviceMonitor-->>System: TomlFixMethod (TOML_* based on processing)
end
Updated class diagram for DeviceMonitor TOML handlingclassDiagram
class Common {
<<namespace>>
+int specialComType
}
class DeviceMonitor {
-bool m_IsTomlSet
-QString m_Model
-QString m_Brand
+void setInfoFromHwinfo(QMap<QString, QString> mapInfo)
+TomlFixMethod setInfoFromTomlOneByOne(QMap<QString, QString> mapInfo)
}
class TomlFixMethod {
<<enum>>
TOML_None
TOML_Success
TOML_Error
TOML_Partial
}
DeviceMonitor ..> Common : reads_specialComType
DeviceMonitor ..> TomlFixMethod : returns
%% Highlighted logic change in setInfoFromTomlOneByOne
class DeviceMonitor {
+void setInfoFromTomlOneByOne(QMap<QString, QString> mapInfo)
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Consider replacing the magic value
Common::specialComType == 2with a named enum or constant (or at least a brief comment) so it's clear under what condition TOML-based monitor info should be applied. - If
m_IsTomlSetwas previously relied on unconditionally elsewhere, it may be worth verifying whether non-specialComType == 2cases need a different flag or handling path rather than silently leavingm_IsTomlSetfalse.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider replacing the magic value `Common::specialComType == 2` with a named enum or constant (or at least a brief comment) so it's clear under what condition TOML-based monitor info should be applied.
- If `m_IsTomlSet` was previously relied on unconditionally elsewhere, it may be worth verifying whether non-`specialComType == 2` cases need a different flag or handling path rather than silently leaving `m_IsTomlSet` false.
## Individual Comments
### Comment 1
<location> `deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp:178` </location>
<code_context>
{
qCDebug(appLog) << "Setting monitor info from TOML configuration";
- m_IsTomlSet = true;
+ if (Common::specialComType == 2)
+ m_IsTomlSet = true;
TomlFixMethod ret = TOML_None;
</code_context>
<issue_to_address>
**nitpick:** Consider avoiding the magic number `2` for `specialComType` and use a named constant or enum instead.
Using the raw value makes this condition harder to understand and more brittle if `specialComType` values change. Prefer comparing against a named enum value or constant to make the intent explicit and reduce maintenance risk.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| { | ||
| qCDebug(appLog) << "Setting monitor info from TOML configuration"; | ||
| m_IsTomlSet = true; | ||
| if (Common::specialComType == 2) |
There was a problem hiding this comment.
nitpick: Consider avoiding the magic number 2 for specialComType and use a named constant or enum instead.
Using the raw value makes this condition harder to understand and more brittle if specialComType values change. Prefer comparing against a named enum value or constant to make the intent explicit and reduce maintenance risk.
fix the pgux device of monitor display pick from: linuxdeepin@958f62c Log: fix the pgux device of monitor display Task: https://pms.uniontech.com/task-view-368603.html
get the network of usb vender info pick from: linuxdeepin@ed96373#diff-8ba3fd1d07a76dcb2459fa1da1130f8418497c40c3eca23c297f84e9e1426521 Log: get the network of usb vender info Task: https://pms.uniontech.com/task-view-368603.html
add communication network support pick from: linuxdeepin@da8e009 Log: add communication network support Bug: https://pms.uniontech.com/task-view-360593.html
add communication network support pick from: linuxdeepin@093ad2a Log: add communication network support Bug: https://pms.uniontech.com/task-view-360593.html
deepin pr auto review我来分析一下这些代码变更:
建议改进: void DeviceBaseInfo::setVendorNameByLsusbLspci(const QString &vidpid, const QString &modalias)
{
if (vidpid.isEmpty() || !modalias.contains("usb")) {
return;
}
QProcess process;
QString vendorId = vidpid.toLower().remove("0x").trimmed().left(4);
QString deviceId = vidpid.toLower().remove("0x").trimmed().right(4);
// 使用参数列表避免命令注入
QStringList args;
args << "-v" << "-d" << QString("%1:%2").arg(vendorId).arg(deviceId);
process.start("lsusb", args);
if (!process.waitForFinished(3000)) { // 设置超时
qCWarning(appLog) << "lsusb command timeout";
return;
}
QString output = process.readAllStandardOutput();
const QStringList lines = output.split('\n');
for (const QString &line : lines) {
if (line.contains("idVendor")) {
int index = line.indexOf(vendorId);
if (index != -1) {
m_Vendor = line.mid(index + 4).trimmed();
}
} else if (line.contains("idProduct")) {
int index = line.indexOf(deviceId);
if (index != -1) {
m_Name = line.mid(index + 4).trimmed();
}
}
// 如果已经获取到所有信息就退出
if (!m_Vendor.isEmpty() && !m_Name.isEmpty()) {
break;
}
}
}
建议改进: enum SpecialComputerType {
NORMAL = 0,
TYPE_2 = 2, // 需要添加实际含义的注释
TYPE_5 = 5 // 需要添加实际含义的注释
};
// 在使用时
if (Common::specialComType == SpecialComputerType::TYPE_2) {
m_IsTomlSet = true;
}
if (Common::specialComType == SpecialComputerType::TYPE_5) {
m_CurrentResolution = QString("%1").arg(QT_REGEXP_CAPTURE(reScreenSize, 1, info));
} else {
m_CurrentResolution = QString("%1@%2").arg(QT_REGEXP_CAPTURE(reScreenSize, 1, info)).arg(curRate);
}
总体建议:
|
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Merge: pick some commits to master