Skip to content

fix: Bluetooth item listView can display full items#362

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
yixinshark:fix-bluetoothListDisplay
Sep 8, 2025
Merged

fix: Bluetooth item listView can display full items#362
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
yixinshark:fix-bluetoothListDisplay

Conversation

@yixinshark

@yixinshark yixinshark commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

ensure content widget height adapts to scroll area size

Log: as title
Pms: BUG-300891

Summary by Sourcery

Fix height calculation for the Bluetooth item list view to ensure full items are displayed without clipping.

Bug Fixes:

  • Adjust the scroll area height calculation to account for all surrounding widgets.
  • Set the content widget’s minimum height to the maximum of the adapter height and the computed scroll area height to prevent item truncation.

@sourcery-ai

sourcery-ai Bot commented Sep 5, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refined how the Bluetooth list view’s scroll area and content widget heights are calculated by introducing a computed scrollAreaHeight and ensuring the content widget’s minimum height adapts to both the adapter content and available scroll space.

File-Level Changes

Change Details Files
Compute and apply dynamic scroll area height
  • Extracted scrollAreaHeight calculation into a named local variable
  • Set m_scrollArea fixed height using scrollAreaHeight
plugins/dde-dock/bluetooth/componments/bluetoothapplet.cpp
Ensure content widget height adapts to available space
  • Replaced static adapterHeight minimum with qMax(adapterHeight, scrollAreaHeight)
  • Set m_contentWidget minimum height to cover both adapter items and visible scroll area
plugins/dde-dock/bluetooth/componments/bluetoothapplet.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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

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:

  • Clamp scrollAreaHeight to a non-negative value before calling setFixedHeight to avoid passing a negative height when the container is too small.
  • Consider also setting a maximumHeight on m_contentWidget so its content won’t grow unbounded beyond the scroll area.
  • Extract the height calculation logic into a helper function or inline block to centralize the math and improve readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Clamp scrollAreaHeight to a non-negative value before calling setFixedHeight to avoid passing a negative height when the container is too small.
- Consider also setting a maximumHeight on m_contentWidget so its content won’t grow unbounded beyond the scroll area.
- Extract the height calculation logic into a helper function or inline block to centralize the math and improve readability.

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.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, yixinshark

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

ensure content widget height adapts to scroll area size

Log: as title
Pms: BUG-300891
@yixinshark yixinshark force-pushed the fix-bluetoothListDisplay branch from a27159c to d4745e8 Compare September 8, 2025 02:33
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我对这段代码进行了审查,发现了一些可以改进的地方:

  1. 代码逻辑和可读性:
  • 原代码中直接使用多个嵌套的height计算,可读性较差
  • 改进后的代码将滚动区域的高度提取为命名变量scrollAreaHeight,提高了代码可读性
  • 使用qMax函数确保内容控件高度合理,这是一个很好的改进
  1. 代码性能:
  • 这部分代码主要涉及UI尺寸计算和设置,性能方面没有明显问题
  • 建议如果此函数频繁调用,可以考虑添加缓存机制来避免重复计算
  1. 代码安全:
  • 代码中使用了多个widget的height()方法,需要确保这些widget都已经正确初始化
  • 建议在调用这些方法前添加空指针检查,以防止潜在的空指针异常
  1. 其他建议:
  • 可以考虑将这些高度计算提取为一个单独的函数,提高代码复用性
  • 建议添加注释说明这些高度计算的目的和依据
  • 可以考虑使用常量定义一些魔法数字,如settingHeightadapterHeight的来源

改进建议代码示例:

void BluetoothApplet::updateSize()
{
    // ... 其他代码 ...

    // 设置滚动区高度
    const int scrollAreaHeight = height - settingHeight - m_disableWidget->height() - m_airplaneModeWidget->height();
    if (m_scrollArea) {
        m_scrollArea->setFixedHeight(scrollAreaHeight);
    }
    
    // 确保内容控件高度至少等于适配器高度,并且不会超过滚动区域的高度太多
    if (m_contentWidget) {
        m_contentWidget->setMinimumHeight(qMax(adapterHeight, scrollAreaHeight));
    }

    // top and bottom margin
    height += hMargins;
    
    // ... 其他代码 ...
}

这些改进可以提高代码的健壮性和可维护性,同时保持原有功能不变。

@yixinshark

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Sep 8, 2025

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit 678112a into linuxdeepin:master Sep 8, 2025
7 of 9 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