Skip to content

fix(ui): calculate scroll offset only for visible widgets#636

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
add-uos:fix-BUG-345913
Apr 8, 2026
Merged

fix(ui): calculate scroll offset only for visible widgets#636
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
add-uos:fix-BUG-345913

Conversation

@add-uos
Copy link
Copy Markdown
Contributor

@add-uos add-uos commented Apr 7, 2026

calculate scroll offset only for visible widgets

log: calculate scroll offset only for visible widgets
pms: https://pms.uniontech.com/bug-view-345913.html

Summary by Sourcery

Adjust the device detail page scrolling to account only for visible widgets when calculating the vertical offset.

Bug Fixes:

  • Prevent incorrect scroll positioning by skipping hidden text, button, and separator widgets when computing the scroll offset for a selected item.

Enhancements:

  • Update the SPDX copyright year range for the device manager page detail source file.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 7, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts scroll offset calculation in PageDetail so that only visible widgets contribute to the vertical scroll value, and updates the SPDX copyright years.

Sequence diagram for updated scroll offset calculation in PageDetail

sequenceDiagram
    actor User
    participant PageDetail
    participant TextBrowserList
    participant DetailButtonList
    participant DetailSeparatorList
    participant ScrollArea
    participant VerticalScrollBar

    User->>PageDetail: showInfoOfNum(index)
    activate PageDetail
    PageDetail->>PageDetail: value = 0
    loop for i = 0 to index - 1
        PageDetail->>TextBrowserList: m_ListTextBrowser[i].isVisible()
        alt text browser visible
            PageDetail->>PageDetail: value += m_ListTextBrowser[i].height()
        end
        PageDetail->>DetailButtonList: m_ListDetailButton[i].isVisible()
        alt detail button visible
            PageDetail->>PageDetail: value += m_ListDetailButton[i].height()
        end
        PageDetail->>DetailSeparatorList: m_ListDetailSeperator[i].isVisible()
        alt separator visible
            PageDetail->>PageDetail: value += m_ListDetailSeperator[i].height()
        end
        PageDetail->>PageDetail: value += SPACE_HEIGHT
    end
    PageDetail->>ScrollArea: mp_ScrollArea
    ScrollArea->>VerticalScrollBar: verticalScrollBar()
    VerticalScrollBar-->>ScrollArea: QScrollBar
    PageDetail->>VerticalScrollBar: setValue(value)
    deactivate PageDetail
Loading

Class diagram for PageDetail scroll offset logic update

classDiagram
    class PageDetail {
        +showInfoOfNum(index int) void
        -m_ListTextBrowser QList~QTextBrowser*~
        -m_ListDetailButton QList~QPushButton*~
        -m_ListDetailSeperator QList~QWidget*~
        -mp_ScrollArea QScrollArea*
    }

    class QTextBrowser {
        +isVisible() bool
        +height() int
    }

    class QPushButton {
        +isVisible() bool
        +height() int
    }

    class QWidget {
        +isVisible() bool
        +height() int
    }

    class QScrollArea {
        +verticalScrollBar() QScrollBar*
    }

    class QScrollBar {
        +setValue(value int) void
    }

    PageDetail --> QTextBrowser : uses m_ListTextBrowser
    PageDetail --> QPushButton : uses m_ListDetailButton
    PageDetail --> QWidget : uses m_ListDetailSeperator
    PageDetail --> QScrollArea : uses mp_ScrollArea
    QScrollArea --> QScrollBar : returns
Loading

File-Level Changes

Change Details Files
Update scroll offset computation in PageDetail to account only for visible child widgets before scrolling.
  • Wrap each height accumulation for text browser, detail button, and separator widgets in a visibility check using isVisible()
  • Preserve spacing constant addition while iterating up to the requested index to compute the scroll position
deepin-devicemanager/src/Page/PageDetail.cpp
Refresh SPDX copyright notice years.
  • Expand copyright year range from 2022 to 2022 - 2026 in the file header
deepin-devicemanager/src/Page/PageDetail.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
Copy Markdown

@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 - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="deepin-devicemanager/src/Page/PageDetail.cpp" line_range="224-226" />
<code_context>
-        value += m_ListTextBrowser[i]->height();
-        value += m_ListDetailButton[i]->height();
-        value += m_ListDetailSeperator[i]->height();
+        if (m_ListTextBrowser[i]->isVisible()) value += m_ListTextBrowser[i]->height();
+        if (m_ListDetailButton[i]->isVisible()) value += m_ListDetailButton[i]->height();
+        if (m_ListDetailSeperator[i]->isVisible()) value += m_ListDetailSeperator[i]->height();
         value += SPACE_HEIGHT;
     }
</code_context>
<issue_to_address>
**issue (bug_risk):** Consider whether SPACE_HEIGHT should be added only when at least one of the widgets is visible.

As a result, fully hidden items still add spacing, which can produce incorrect scroll offsets when many items are invisible. If hidden items should be completely skipped, gate the `SPACE_HEIGHT` addition on at least one of the three widgets being visible for that index.
</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.

calculate scroll offset only for visible widgets

log: calculate scroll offset only for visible widgets
pms: https://pms.uniontech.com/bug-view-345913.html
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@add-uos
Copy link
Copy Markdown
Contributor Author

add-uos commented Apr 8, 2026

/forcemerge

@deepin-bot
Copy link
Copy Markdown
Contributor

deepin-bot bot commented Apr 8, 2026

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit fb2fa52 into linuxdeepin:develop/eagle Apr 8, 2026
20 of 22 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.

4 participants