Skip to content

fix: close applet popup after bluetooth adaptor was removed#309

Merged
yixinshark merged 2 commits into
linuxdeepin:masterfrom
yixinshark:fix-removeBluetooth
May 8, 2025
Merged

fix: close applet popup after bluetooth adaptor was removed#309
yixinshark merged 2 commits into
linuxdeepin:masterfrom
yixinshark:fix-removeBluetooth

Conversation

@yixinshark

@yixinshark yixinshark commented May 8, 2025

Copy link
Copy Markdown
Contributor

as title

Log: as title
Pms: BUG-285035

Summary by Sourcery

Bug Fixes:

  • Ensure the Bluetooth applet popup is hidden when no Bluetooth adapters are present

@sourcery-ai

sourcery-ai Bot commented May 8, 2025

Copy link
Copy Markdown

Reviewer's Guide

The pull request updates the BluetoothItem class to automatically hide the Bluetooth applet when the noAdapter signal is emitted and the applet is currently visible. This is achieved by modifying the existing signal connection to use a lambda function that incorporates this new visibility check and hiding logic before re-emitting the noAdapter signal.

File-Level Changes

Change Details Files
Enhanced noAdapter signal handling to hide the Bluetooth applet.
  • Modified the connection for the m_applet's noAdapter signal to execute a lambda function.
  • The lambda function now checks if m_applet is visible.
  • If m_applet is visible upon noAdapter signal emission, it is hidden by calling m_applet->setVisible(false).
plugins/dde-dock/bluetooth/bluetoothitem.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 @yixinshark - I've reviewed your changes - here's some feedback:

  • Consider refactoring the lambda into a private slot on BluetoothItem for improved clarity, as it handles multiple responsibilities (UI update and signal emission).
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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

deepin pr auto review

代码审查意见:

  1. BluetoothItem类的构造函数中,新增的lambda表达式用于处理noAdapter信号,但未对m_applet是否为空进行检查。如果m_applet为空,调用m_applet->isVisible()会导致空指针异常。

  2. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被禁用时,应该检查m_bluetoothItem是否为空,以避免潜在的空指针异常。

  3. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被禁用时,应该同时隐藏popupWidget,但代码中只检查了popupWidget是否存在,而没有检查m_bluetoothItem是否存在。如果m_bluetoothItem为空,调用m_bluetoothItem->popupApplet()会导致空指针异常。

  4. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被启用时,应该检查m_bluetoothItem是否为空,以避免潜在的空指针异常。

  5. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被启用时,应该同时显示popupWidget,但代码中只检查了popupWidget是否存在,而没有检查m_bluetoothItem是否存在。如果m_bluetoothItem为空,调用m_bluetoothItem->popupApplet()会导致空指针异常。

  6. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被禁用时,应该调用m_proxyInter->itemRemoved,而不是直接调用m_proxyInter->itemRemoved(this, BLUETOOTH_KEY)。这是因为itemRemoved函数可能需要更多的参数来正确地移除插件项。

  7. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被启用时,应该调用m_proxyInter->itemAdded,而不是直接调用m_proxyInter->itemAdded(this, BLUETOOTH_KEY)。这是因为itemAdded函数可能需要更多的参数来正确地添加插件项。

  8. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被禁用时,应该隐藏popupWidget,而不是直接调用popupWidget->setVisible(false)。这是因为popupWidget可能不是m_bluetoothItem的成员,而是通过其他方式获取的。

  9. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被启用时,应该显示popupWidget,而不是直接调用popupWidget->setVisible(true)。这是因为popupWidget可能不是m_bluetoothItem的成员,而是通过其他方式获取的。

  10. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被禁用时,应该调用m_bluetoothItem->requestHideApplet(),而不是直接调用m_bluetoothItem->requestHideApplet()。这是因为requestHideApplet函数可能需要更多的参数来正确地隐藏插件项。

  11. BluetoothPlugin类的refreshPluginItemsVisible函数中,当插件被启用时,应该调用m_bluetoothItem->requestShowApplet(),而不是直接调用m_bluetoothItem->requestShowApplet()。这是因为requestShowApplet函数可能需要更多的参数来正确地显示插件项。

@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

@yixinshark yixinshark merged commit 4755169 into linuxdeepin:master May 8, 2025
4 of 5 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