Skip to content

Conversation

@add-uos
Copy link
Contributor

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

Maintain the monitor info of supported resolutions in special machine.

Log: Maintain the monitor info in special machine.
Bug: https://pms.uniontech.com/bug-view-325731.html
Change-Id: Iddfadc1ab05f3b81df5469240fde4346ac35e378

Summary by Sourcery

Ensure monitor resolution information is correctly maintained for special machines and restrict certain operations to normal machines.

Bug Fixes:

  • Restore support resolution extraction and formatting for special machines by enabling it only when specialComType > 0.
  • Prevent xrandr-based resolution parsing and automated Monitor tab refresh for special machines by wrapping these operations behind specialComType <= 0 checks.

Enhancements:

  • Remove unused commented debug code from ThreadExecXrandr.

Maintain the monitor info of supported resolutions in special machine.

Log: Maintain the monitor info in special machine.
Bug: https://pms.uniontech.com/bug-view-325731.html
Change-Id: Iddfadc1ab05f3b81df5469240fde4346ac35e378
@sourcery-ai
Copy link

sourcery-ai bot commented Jul 24, 2025

Reviewer's Guide

Introduce conditional logic around Common::specialComType to manage monitor resolution info maintenance and UI updates on special machines, and remove unused debug code.

Sequence diagram for monitor info update with special machine condition

sequenceDiagram
    participant MainWindow
    participant DeviceWidget
    participant Common
    participant QtConcurrent
    MainWindow->>DeviceWidget: updateDevice(currentIndex, lst)
    MainWindow->>Common: check specialComType
    alt specialComType <= 0
        MainWindow->>DeviceWidget: currentIndex() == "Monitor"
        MainWindow->>QtConcurrent: run (emit itemClicked after delay)
    else specialComType > 0
        Note right of MainWindow: Skip UI update for monitor
    end
Loading

Sequence diagram for DeviceMonitor setting monitor resolution info

sequenceDiagram
    participant DeviceMonitor
    participant Common
    DeviceMonitor->>Common: check specialComType
    alt specialComType > 0
        DeviceMonitor->>DeviceMonitor: setAttribute("Resolution", m_SupportResolution)
        DeviceMonitor->>DeviceMonitor: Parse and format m_SupportResolution
    else specialComType <= 0
        DeviceMonitor->>DeviceMonitor: Skip setting m_SupportResolution
    end
Loading

Class diagram for DeviceMonitor and conditional monitor info maintenance

classDiagram
    class DeviceMonitor {
        +void setInfoFromHwinfo(const QMap<QString, QString> &mapInfo)
        +bool setInfoFromXradr(const QString &main, const QString &edid, const QString &xrandr)
        -QString m_SupportResolution
    }
    class Common {
        +static int specialComType
    }
    DeviceMonitor ..> Common : uses
Loading

Class diagram for MainWindow and conditional UI update

classDiagram
    class MainWindow {
        +void slotLoadingFinish(const QString &message)
        -mp_DeviceWidget
    }
    class DeviceWidget {
        +void updateDevice(int index, QList<QMap<QString, QString>> lst)
        +QString currentIndex()
        +void itemClicked(QString index)
    }
    class Common {
        +static int specialComType
    }
    MainWindow ..> DeviceWidget : uses
    MainWindow ..> Common : uses
Loading

File-Level Changes

Change Details Files
Conditional resolution info maintenance for special machines
  • Gate setAttribute for Resolution when specialComType>0
  • Wrap support‐resolution parsing and trailing comma trimming in specialComType>0
  • Guard xrandr‐based resolution list parsing for non‐special machines
deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
Prevent redundant UI update on special machines
  • Wrap Monitor tab delayed click logic in specialComType<=0 check
deepin-devicemanager/src/Page/MainWindow.cpp
Remove unused debug/commented code
  • Deleted redundant QString ss assignment commented out
deepin-devicemanager/src/Tool/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. DeviceMonitor.cpp文件中,setAttribute函数被多次调用,但参数为空字符串的情况没有注释说明其用途。建议添加注释说明这些空字符串参数的用途。

  2. DeviceMonitor.cpp文件中,m_SupportResolution的拼接和替换操作被包裹在if (Common::specialComType > 0)条件判断中。如果Common::specialComType的值可能为0,建议检查这个条件是否正确,因为如果specialComType为0,这些操作将不会执行。

  3. DeviceMonitor.cpp文件中,foreach循环被替换为for循环,这可能是为了提高代码的可读性。但是,如果foreach循环在所有情况下都是正确的,建议保持使用foreach

  4. DeviceMonitor.cpp文件中,m_SupportResolution.replace(QRegExp(", $"), "");操作被包裹在if (Common::specialComType > 0)条件判断中。如果Common::specialComType的值可能为0,建议检查这个条件是否正确,因为如果specialComType为0,这个操作将不会执行。

  5. MainWindow.cpp文件中,slotLoadingFinish函数中的QtConcurrent::run被包裹在if (Common::specialComType <= 0)条件判断中。如果Common::specialComType的值可能大于0,建议检查这个条件是否正确,因为如果specialComType大于0,这个操作将不会执行。

  6. ThreadExecXrandr.cpp文件中,loadXrandrVerboseInfo函数中的QRegExp对象被创建为局部变量,这可能会导致不必要的内存分配。建议将QRegExp对象定义为类的成员变量,以避免每次调用函数时都创建新的对象。

  7. 在所有修改的文件中,建议添加单元测试来验证修改后的代码是否按预期工作,特别是涉及到条件判断和字符串操作的部分。

  8. 在所有修改的文件中,建议检查是否有其他地方也使用了Common::specialComType,并确保这些地方的条件判断逻辑是一致的。

  9. 在所有修改的文件中,建议检查是否有其他地方也使用了setAttribute函数,并确保这些地方的参数处理逻辑是一致的。

  10. 在所有修改的文件中,建议检查是否有其他地方也使用了m_SupportResolution,并确保这些地方的字符串操作逻辑是一致的。

@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 b71dbea 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