Skip to content

Conversation

@GongHeng2017
Copy link
Contributor

@GongHeng2017 GongHeng2017 commented Oct 21, 2025

-- Change resolution by task.

Summary by Sourcery

Apply custom resolution mapping to convert 1920×1080 to 1920×1200 across device monitoring and GPU resolution routines

Enhancements:

  • Replace 1920×1080 entries with 1920×1200 in supported and current resolution lists for DeviceMonitor
  • Apply the same 1080→1200 replacement logic to minimum, current, and maximum resolutions in DeviceGpu::setXrandrInfo

-- Change resolution by task.
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 21, 2025

Reviewer's Guide

This PR ensures that any detected 1920x1080 resolution string is programmatically converted to 1920x1200 within both DeviceMonitor and DeviceGpu classes by inserting conditional checks and string replacements in relevant methods.

Sequence diagram for resolution string conversion in DeviceMonitor and DeviceGpu

sequenceDiagram
participant DeviceMonitor
participant DeviceGpu
participant "Resolution String"
DeviceMonitor->>"Resolution String": Detects "1920x1080"
DeviceMonitor->>"Resolution String": Replaces "1080" with "1200"
DeviceGpu->>"Resolution String": Detects "1920x1080" in min, cur, max
DeviceGpu->>"Resolution String": Replaces "1080" with "1200"
Loading

Class diagram for updated DeviceMonitor and DeviceGpu resolution handling

classDiagram
class DeviceMonitor {
  - m_SupportResolution : QString
  - m_CurrentResolution : QString
  setInfoFromHwinfo(mapInfo: QMap<QString, QString>)
  setInfoFromXradr(main: QString, edid: QString, xrandr: QString) : bool
  setMainInfoFromXrandr(info: QString, raw: QString) : bool
}
class DeviceGpu {
  - m_MinimumResolution : QString
  - m_CurrentResolution : QString
  - m_MaximumResolution : QString
  setXrandrInfo(mapInfo: QMap<QString, QString>)
}
DeviceMonitor <|-- DeviceGpu
Loading

File-Level Changes

Change Details Files
Add resolution conversion in DeviceMonitor methods
  • Wrap resolution append logic in setInfoFromHwinfo with condition to replace 1080 with 1200 for 1920 width
  • Insert replacement of current resolution in setInfoFromXradr when containing 1920×1080
  • Extend xrandr support loop in setInfoFromXradr to convert 1080 to 1200 before appending
  • Apply resolution replacement in setMainInfoFromXrandr for current resolution
deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
Add resolution conversion in DeviceGpu setXrandrInfo
  • Replace 1080 with 1200 in m_MinimumResolution when detecting 1920×1080
  • Replace 1080 with 1200 in m_CurrentResolution when detecting 1920×1080
  • Replace 1080 with 1200 in m_MaximumResolution when detecting 1920×1080
deepin-devicemanager/src/DeviceManager/DeviceGpu.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

Copy link

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

Hey there - I've reviewed your changes - here's some feedback:

  • There's a lot of duplicated logic for detecting and replacing “1080” with “1200” across multiple methods—consider extracting this into a single helper function to keep the code DRY and easier to maintain.
  • When appending resolutions to m_SupportResolution you’re always adding a trailing comma and space—trim or conditionally add separators to avoid having an extra ", " at the end of the string.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There's a lot of duplicated logic for detecting and replacing “1080” with “1200” across multiple methods—consider extracting this into a single helper function to keep the code DRY and easier to maintain.
- When appending resolutions to m_SupportResolution you’re always adding a trailing comma and space—trim or conditionally add separators to avoid having an extra ", " at the end of the string.

## Individual Comments

### Comment 1
<location> `deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp:225-226` </location>
<code_context>
     m_CurrentResolution = mapInfo["curResolution"];
     m_MaximumResolution = mapInfo["maxResolution"];

+    if (m_MinimumResolution.contains("1920") && m_MinimumResolution.contains("1080")) {
+        m_MinimumResolution.replace("1080", "1200");
+    }
+    if (m_CurrentResolution.contains("1920") && m_CurrentResolution.contains("1080")) {
</code_context>

<issue_to_address>
**suggestion:** Resolution replacement logic is duplicated for multiple member variables.

Consider extracting the repeated replacement logic into a utility function to improve maintainability and reduce code duplication.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +225 to +226
if (m_MinimumResolution.contains("1920") && m_MinimumResolution.contains("1080")) {
m_MinimumResolution.replace("1080", "1200");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Resolution replacement logic is duplicated for multiple member variables.

Consider extracting the repeated replacement logic into a utility function to improve maintainability and reduce code duplication.

@GongHeng2017
Copy link
Contributor Author

/forcemerge

@deepin-bot deepin-bot bot merged commit 4a88453 into linuxdeepin:develop/tmp-eagle Oct 21, 2025
14 checks passed
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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