-
Notifications
You must be signed in to change notification settings - Fork 40
fix(monitor): correct platform condition logic and regex pattern #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Fixed monitor resolution display logic (negated isHwPlatform condition) - Enhanced smartctl regex to better match device identifier patterns log: correct platform condition logic and regex pattern bug: https://pms.uniontech.com/bug-view-340917.html
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts monitor info handling to only process and display supported resolutions on non-HW platforms and refines the smartctl parsing regex to more accurately capture device identifiers and values. Sequence diagram for updated monitor resolution handling in setInfoFromHwinfosequenceDiagram
participant Caller
participant DeviceMonitor
participant Common
Caller->>DeviceMonitor: setInfoFromHwinfo(mapInfo)
activate DeviceMonitor
DeviceMonitor->>DeviceMonitor: setAttribute(mapInfo, "", m_DisplayInput)
DeviceMonitor->>DeviceMonitor: setAttribute(mapInfo, Size, m_ScreenSize)
DeviceMonitor->>DeviceMonitor: setAttribute(mapInfo, "", m_MainScreen)
DeviceMonitor->>Common: isHwPlatform()
Common-->>DeviceMonitor: bool
alt non_HW_platform (!isHwPlatform)
DeviceMonitor->>DeviceMonitor: setAttribute(mapInfo, Resolution, m_SupportResolution)
end
DeviceMonitor->>DeviceMonitor: parse m_ScreenSize into size(width, height)
DeviceMonitor->>Common: isHwPlatform()
Common-->>DeviceMonitor: bool
alt non_HW_platform (!isHwPlatform)
DeviceMonitor->>DeviceMonitor: split m_SupportResolution into listResolution
DeviceMonitor->>DeviceMonitor: rebuild m_SupportResolution from listResolution
end
DeviceMonitor->>DeviceMonitor: caculateScreenRatio()
DeviceMonitor->>Common: isHwPlatform()
Common-->>DeviceMonitor: bool
alt non_HW_platform (!isHwPlatform)
DeviceMonitor->>DeviceMonitor: m_SupportResolution.replace(QRegularExpression(", $"), "")
end
DeviceMonitor-->>Caller: return
deactivate DeviceMonitor
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- In
DeviceMonitor::setInfoFromHwinfo, the repeatedif (!Common::isHwPlatform())blocks around resolution handling suggest the condition may be inverted relative to the method name; consider renamingisHwPlatformor adding a clarifying comment to avoid future misuse. - In
CmdTool::getMapInfoFromSmartctl, theQRegularExpressionis constructed on every iteration andrx.match(line)is called three times; consider constructing the regex once (e.g., static or outside the loop) and storing the match result in a local variable before reusing it.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `DeviceMonitor::setInfoFromHwinfo`, the repeated `if (!Common::isHwPlatform())` blocks around resolution handling suggest the condition may be inverted relative to the method name; consider renaming `isHwPlatform` or adding a clarifying comment to avoid future misuse.
- In `CmdTool::getMapInfoFromSmartctl`, the `QRegularExpression` is constructed on every iteration and `rx.match(line)` is called three times; consider constructing the regex once (e.g., static or outside the loop) and storing the match result in a local variable before reusing it.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos 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 |
deepin pr auto review我来对这个diff进行详细的代码审查:
- if (Common::isHwPlatform()){
+ if (!Common::isHwPlatform()){这个修改在代码中出现了3次,都是相同的改动。 改进建议:
- QRegularExpression rx("^[ ]*[0-9]+[ ]+([\\w-_]+)[ ]+0x[0-9a-fA-F-]+[ ]+[0-9]+[ ]+[0-9]+[ ]+[0-9]+[ ]+[\\w-]+[ ]+[\\w-]+[ ]+[\\w-]+[ ]+([0-9\\/w-]+[ ]*[ 0-9\\/w-()]*)$");
+ QRegularExpression rx("^[ ]*[0-9]+[ ]+([\\w_-]+)[ ]+0x[0-9a-fA-F-]+[ ]+[0-9]+[ ]+[0-9]+[ ]+[0-9]+[ ]+[\\w-]+[ ]+[\\w-]+[ ]+[\\w-]+[ ]+([0-9\\w\\/-]+[ ]*[0-9\\w\\/\\-\\(\\)]*)$");改进建议:
总体建议:
|
log: correct platform condition logic and regex pattern
bug: https://pms.uniontech.com/bug-view-340917.html
Summary by Sourcery
Fix monitor platform-specific resolution handling and improve smartctl output parsing.
Bug Fixes: