Skip to content

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Jul 24, 2025

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.

Log: Fix display resolution detection method
Bug: https://pms.uniontech.com/bug-view-325731.html
Change-Id: I377caf0def3455191a3189eac734a608443b47e6

Summary by Sourcery

Replace the old hwinfo-based resolution detection with a new xrandr parsing approach to accurately gather supported resolutions and refresh rates, add a helper function for mapping resolutions, update the data flow to include raw xrandr output, and implement a UI refresh workaround for the Monitor page.

New Features:

  • Parse xrandr output to reliably detect supported display resolutions and refresh rates
  • Automatically refresh the Monitor view after loading to ensure updated display details

Bug Fixes:

  • Fix refresh rate errors by rounding and trimming Hz values to integers
  • Correct spelling mistakes in display interface comments

Enhancements:

  • Introduce getMonitorResolutionMap helper for extracting monitor‐specific resolutions from raw xrandr data
  • Extend DeviceMonitor and DeviceManager APIs to propagate raw xrandr output through the resolution detection pipeline
  • Extract and store the raw interface identifier from xrandr lines for accurate resolution mapping

Chores:

  • Comment out the deprecated hwinfo-based resolution parsing code

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.

Log: Fix display resolution detection method
Bug: https://pms.uniontech.com/bug-view-325731.html
Change-Id: I377caf0def3455191a3189eac734a608443b47e6
@sourcery-ai
Copy link

sourcery-ai bot commented Jul 24, 2025

Reviewer's Guide

This pull request replaces the unreliable hwinfo-based resolution detection with a new xrandr-output parser, integrates raw xrandr data throughout the monitor setup pipeline, and adds a UI auto-refresh to ensure supported resolutions are displayed correctly.

Sequence diagram for xrandr-based monitor resolution detection

sequenceDiagram
    participant ThreadExecXrandr
    participant DeviceManager
    participant DeviceMonitor

    ThreadExecXrandr->>ThreadExecXrandr: runCmd(xrandr)
    ThreadExecXrandr->>DeviceManager: setMonitorInfoFromXrandr(mainInfo, edid, rate, xrandr)
    DeviceManager->>DeviceMonitor: setInfoFromXradr(main, edid, rate, xrandr)
    DeviceMonitor->>DeviceMonitor: getMonitorResolutionMap(xrandr, m_RawInterface)
    DeviceMonitor->>DeviceMonitor: Update m_SupportResolution
Loading

File-Level Changes

Change Details Files
Implement xrandr-based resolution parsing and remove hwinfo logic
  • Introduce getMonitorResolutionMap to parse and format integer resolution@rate entries
  • Update setInfoFromXrandr to use xrandr data and comment out old hwinfo blocks
  • Capture interface identifier in setMainInfoFromXrandr for mapping
DeviceMonitor.cpp
DeviceMonitor.h
Propagate raw xrandr output through execution and manager layers
  • Run an additional “xrandr” command and store its full output in ThreadExecXrandr
  • Attach the raw xrandr string to each monitor info map entry
  • Extend DeviceManager and DeviceMonitor setMonitorInfoFromXrandr signature to accept xrandr data
ThreadExecXrandr.cpp
DeviceManager.cpp
DeviceManager.h
Add UI auto-refresh for the Monitor panel
  • Include QtConcurrent and launch a delayed task after loading to re-emit click on the Monitor tab
MainWindow.cpp
Apply minor include and spelling corrections
  • Add QProcess include in DeviceMonitor.cpp
  • Fix typo in interface comment in DeviceMonitor.h
  • Adjust whitespace around regex declaration in ThreadExecXrandr
DeviceMonitor.cpp
DeviceMonitor.h
ThreadExecXrandr.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. 函数命名一致性

    • setMonitorInfoFromXrandr 函数的参数列表中,xrandr 参数的命名与 setInfoFromXradr 函数中的 xrandr 参数不一致。建议统一命名,例如都使用 xrandrOutput
  2. 代码注释

    • DeviceMonitor::getMonitorResolutionMap 函数中,注释掉的代码应该使用 // TODO// FIXME 等标记,以便于后续维护者了解需要处理的逻辑。
  3. 正则表达式

    • ThreadExecXrandr::loadXrandrVerboseInfo 函数中,正则表达式 QRegExp regRate(".*([0-9]{1,5}\\.[0-9]{1,5}Hz).*"); 可以简化为 QRegExp regRate("\\b([0-9]{1,5}\\.[0-9]{1,5}Hz)\\b");,以避免不必要的匹配。
  4. 线程安全

    • MainWindow::slotLoadingFinish 函数中,使用 QtConcurrent::run 启动了一个新的线程来处理设备点击事件。需要确保在多线程环境下访问共享资源时,使用适当的同步机制,例如互斥锁。
  5. 代码风格

    • ThreadExecXrandr::loadXrandrVerboseInfo 函数中,newMap.insert("mainInfo", (*it).trimmed());newMap.insert("port", mainInfoList.at(0)); 之间缺少空行,建议添加空行以提高代码可读性。
  6. 错误处理

    • DeviceMonitor::setInfoFromXradr 函数中,当 monitorResolutionMap.size() == 1 时,如果 monitorResolutionMap.value(monitorResolutionMap.lastKey()).isEmpty(),应该有相应的错误处理或日志记录。
  7. 性能优化

    • DeviceMonitor::getMonitorResolutionMap 函数中,monitorResolutionMap.value(monitorResolutionMap.lastKey()).contains(realResolution) 可能会导致不必要的性能问题,建议使用 QSet 来优化查找操作。
  8. 代码重复

    • DeviceMonitor::getMonitorResolutionMap 函数中,monitorResolutionMap.insert(monitorInfoList.at(0).trimmed(), QStringList());monitorResolutionMap[monitorResolutionMap.lastKey()].append(realResolution); 代码重复,建议提取为单独的函数。
  9. 未使用的变量

    • ThreadExecXrandr::loadXrandrVerboseInfo 函数中,QString xrandInfo; 被声明但未使用,建议移除。
  10. 字符串处理

    • ThreadExecXrandr::loadXrandrVerboseInfo 函数中,newMap.insert("mainInfo", (*it).trimmed());newMap.insert("port", mainInfoList.at(0)); 可以使用 QString::trimmed() 方法直接在插入时处理,减少代码行数。

以上是针对代码提交的审查意见,希望能够帮助到开发者改进代码质量。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, 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

@add-uos
Copy link
Contributor Author

add-uos commented Jul 24, 2025

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jul 24, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 496262e into linuxdeepin:develop/eagle Jul 24, 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.

3 participants