Skip to content

fix: sound tooltip might look incorrectly when gets hovered twice#419

Merged
BLumia merged 1 commit intolinuxdeepin:masterfrom
BLumia:pms-bug-348963
Jan 28, 2026
Merged

fix: sound tooltip might look incorrectly when gets hovered twice#419
BLumia merged 1 commit intolinuxdeepin:masterfrom
BLumia:pms-bug-348963

Conversation

@BLumia
Copy link
Member

@BLumia BLumia commented Jan 28, 2026

之前的修复已经在 TipsWidget 中确保了其控件本身的尺寸一定正确,不再需要重新 resize 一次.

PMS: BUG-348963

Summary by Sourcery

Bug Fixes:

  • Prevent sound tooltip from rendering with incorrect dimensions when hovered multiple times by relying on TipsWidget sizing.

之前的修复已经在 TipsWidget 中确保了其控件本身的尺寸一定正确,不再需
要重新 resize 一次.

PMS: BUG-348963
Log:
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 28, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes redundant manual resizing of the sound tooltip label in SoundView::tipsWidget(), relying instead on the existing TipsWidget behavior to ensure correct sizing and avoid visual glitches when the tooltip is hovered multiple times.

Class diagram for updated SoundView tooltip sizing behavior

classDiagram
    class SoundView {
        +SoundView(parent: QWidget)
        +QWidget tipsWidget()
        -QLabel m_tipsLabel
    }

    class TipsWidget {
        +void ensureCorrectSize()
    }

    SoundView --> TipsWidget : uses
Loading

File-Level Changes

Change Details Files
Stop manually resizing the tooltip label in SoundView to prevent incorrect tooltip appearance on repeated hover.
  • Remove the explicit resize() call on the tooltip label in tipsWidget()
  • Rely on refreshTips(true) and TipsWidget's internal sizing to determine the correct tooltip size
plugins/dde-dock/sound/soundview.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

这段代码是关于 DDE 深度桌面环境任务栏中声音插件的一个修改。主要是移除了在 tipsWidget() 函数中对提示标签(m_tipsLabel)进行显式尺寸调整的代码。

以下是对该修改的详细审查意见:

1. 语法逻辑

  • 审查结果:通过。
  • 分析:代码移除了两行对 m_tipsLabel->resize() 的调用。这不会导致语法错误,且不会破坏程序的编译流程。逻辑上,tipsWidget() 函数现在直接调用 refreshTips(true) 更新内容后返回指针,不再干预其几何尺寸。

2. 代码质量

  • 审查结果:改进(提升)。
  • 分析
    • 职责分离:原本的代码在获取 Widget 指针的 getter 函数中硬编码了布局逻辑(+10 的宽度增加)。移除这些代码后,尺寸控制交由 Qt 的布局系统或 m_tipsLabel 自身的 sizePolicysizeHint 机制来管理,符合 Qt 的最佳实践。
    • 可维护性:移除魔法数字(+10)使得代码更清晰。如果未来需要调整边距,应该在样式表(QSS)或 Label 的样式属性中统一设置,而不是在获取指针的函数中临时修改。

3. 代码性能

  • 审查结果:影响极小/正面。
  • 分析
    • 移除了 sizeHint() 的调用和 resize() 操作,减少了函数调用栈的开销。
    • resize() 操作通常会触发重绘事件,虽然开销不大,但在高频调用的场景下(如鼠标快速滑过),减少不必要的重绘是有益的。

4. 代码安全

  • 审查结果:安全。
  • 分析:此修改仅涉及 UI 布局逻辑,不涉及内存管理、指针操作或用户输入处理,因此不会引入内存泄漏、崩溃或安全漏洞。

总结与改进建议

结论:这是一个合理的修改。它移除了硬编码的布局逻辑,让控件的尺寸管理回归到 Qt 的布局系统中,有助于保持 UI 的一致性和可维护性。

额外建议
虽然移除了这里的 resize 是正确的,但需要确保以下一点,以防止出现 UI 显示问题:

  • 检查样式表(QSS)或内容边距:原来的 +10 宽度可能是为了给文字留出左右边距。移除此代码后,请确认 m_tipsLabel 是否在 CSS 中设置了 padding 属性,或者在初始化时设置了 setContentsMargins
    • 如果没有设置,文字可能会紧贴 Label 的边缘,视觉上可能会显得拥挤。
    • 建议在 SoundView 的构造函数或样式表中为 m_tipsLabel 添加适当的 padding,例如:
      // 在构造函数中
      m_tipsLabel->setContentsMargins(5, 0, 5, 0); // 左右各留5像素
      或者使用 QSS:
      QLabel { padding: 0 5px; }

最终评分:该 diff 是一个良性的代码清理,建议合并,但需附带上述关于边距设置的检查。

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 - I've reviewed your changes and they look great!


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

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@BLumia BLumia merged commit b92f43d into linuxdeepin:master Jan 28, 2026
9 of 10 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