Skip to content

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Jul 28, 2025

  1. Modified position calculation for plugin popups to use EmbedPlugin's position
  2. Added null check for transient parent window
  3. Uses pluginPos() from EmbedPlugin instead of direct window coordinates
  4. Ensures popups appear in correct relative position to their parent plugin

The previous implementation directly used the transient parent window's coordinates which could lead to incorrect positioning when the plugin was embedded in a complex layout. The new approach gets the accurate position from the EmbedPlugin itself.

fix: 修正小部件插件中弹出窗口位置计算

  1. 修改插件弹出窗口的位置计算以使用 EmbedPlugin 的位置
  2. 为 transient 父窗口添加空值检查
  3. 使用 EmbedPlugin 的 pluginPos() 而非直接窗口坐标
  4. 确保弹出窗口相对于父插件显示在正确位置

之前的实现直接使用 transient 父窗口的坐标,当插件嵌入复杂布局时可能导致
位置计算错误。新方法从 EmbedPlugin 自身获取准确位置。
Pms: BUG-321795

Summary by Sourcery

Fix widget plugin popup positioning by using EmbedPlugin’s accurate coordinates and adding a transient parent null check

Bug Fixes:

  • Use EmbedPlugin::pluginPos() instead of transientParent window coordinates for popup placement
  • Add null check for transient parent window before calculating popup position

1. Modified position calculation for plugin popups to use EmbedPlugin's
position
2. Added null check for transient parent window
3. Uses pluginPos() from EmbedPlugin instead of direct window
coordinates
4. Ensures popups appear in correct relative position to their parent
plugin

The previous implementation directly used the transient parent window's
coordinates which could lead to incorrect positioning when the plugin
was embedded in a complex layout. The new approach gets the accurate
position from the EmbedPlugin itself.

fix: 修正小部件插件中弹出窗口位置计算

1. 修改插件弹出窗口的位置计算以使用 EmbedPlugin 的位置
2. 为 transient 父窗口添加空值检查
3. 使用 EmbedPlugin 的 pluginPos() 而非直接窗口坐标
4. 确保弹出窗口相对于父插件显示在正确位置

之前的实现直接使用 transient 父窗口的坐标,当插件嵌入复杂布局时可能导致
位置计算错误。新方法从 EmbedPlugin 自身获取准确位置。
Pms: BUG-321795
@sourcery-ai
Copy link

sourcery-ai bot commented Jul 28, 2025

Reviewer's Guide

Replaces direct transientParent coordinate usage with EmbedPlugin's position API and adds null checks to ensure popups align correctly with the embedded plugin.

Sequence diagram for popup position calculation in widget plugin

sequenceDiagram
    participant EventFilter
    participant toolTipWindow
    participant PluginPopup
    participant parentWindow
    participant EmbedPlugin

    EventFilter->>toolTipWindow: Get transientParent()
    toolTipWindow->>parentWindow: transientParent()
    alt parentWindow is not null
        EventFilter->>EmbedPlugin: getWithoutCreating(parentWindow)
        alt EmbedPlugin exists
            EmbedPlugin->>EmbedPlugin: pluginPos()
            EmbedPlugin-->>EventFilter: pluginPos
            EventFilter->>PluginPopup: setX(pluginPos.x + pos.x)
            EventFilter->>PluginPopup: setY(pluginPos.y + pos.y)
        end
    end
Loading

Class diagram for updated popup position logic

classDiagram
    class EventFilter {
        +QObject
        ...
    }
    class PluginPopup {
        +setX(int)
        +setY(int)
        +getWithoutCreating(QWidget*)
    }
    class EmbedPlugin {
        +pluginPos() : QPoint
        +getWithoutCreating(QWidget*)
    }
    class QWidget {
        +transientParent() : QWidget*
        +x() : int
        +y() : int
    }
    EventFilter --> PluginPopup : uses
    EventFilter --> EmbedPlugin : uses
    PluginPopup ..> QWidget : window
    EmbedPlugin ..> QWidget : parentWindow
    QWidget <|-- toolTipWindow
    QWidget <|-- parentWindow
Loading

File-Level Changes

Change Details Files
Refactored popup position calculation to use EmbedPlugin
  • Added null check for transient parent window
  • Fetched EmbedPlugin instance instead of using raw window coordinates
  • Replaced setX/Y calls to use pluginPos() values
src/loader/widgetplugin.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

关键摘要:

  • if (parentWindow)条件判断中,应该检查plugin对象是否为空,以避免潜在的空指针解引用。
  • Plugin::EmbedPlugin::getWithoutCreating函数调用可能会抛出异常,应该考虑异常处理机制。
  • pluginPos变量名不够直观,建议使用更具描述性的变量名,如parentPluginPosition

是否建议立即修改:

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

@wjyrich
Copy link
Contributor Author

wjyrich commented Jul 28, 2025

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@wjyrich
Copy link
Contributor Author

wjyrich commented Jul 29, 2025

/forcemerge

1 similar comment
@wjyrich
Copy link
Contributor Author

wjyrich commented Jul 29, 2025

/forcemerge

@deepin-bot deepin-bot bot merged commit 67b257a into linuxdeepin:master Jul 29, 2025
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