Skip to content

fix(SearchBar): use Popup.Window to allow popup beyond window boundary - #3462

Open
18202781743 wants to merge 1 commit into
masterfrom
fix/popup-window-type
Open

18202781743 wants to merge 1 commit into
masterfrom
fix/popup-window-type

Conversation

@18202781743

@18202781743 18202781743 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

问题

控制中心搜索栏的 Popup 默认使用 Popup.Item 类型,弹窗在父窗口场景内渲染,被主窗口边界裁剪,无法超出窗口显示。

修复方案

将搜索结果 Popup 改为 popupType: Popup.Window 独立平台窗口模式,使其可超出主窗口边界渲染。

改动内容

  1. 新增 import QtQuick.Window 2.15,提供 Window.window 附加属性用于全局坐标映射。
  2. popupType: Popup.Window — 独立平台窗口渲染,解决裁剪问题。
  3. PopupHandle.enableBlurWindow: true — 与 datetime 插件一致的模糊/圆角外观。
  4. closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent — Window 模式下点击外部和 Esc 可关闭。
  5. 新增 positionWindow() 函数,通过 searchEdit.mapToGlobal(0, 0) + Window.window.mapFromGlobal() 映射坐标定位,在 onOpened 中调用。参考 datetime 插件 SearchableListViewPopup.positionWindow() 实现。
  6. 移除 enter/exitscale 动画,仅保留 opacity 过渡。

参考

  • datetime 插件 commit f4845fcc0SearchableListViewPopup.qmlRegionsChooserWindow.qml
  • Qt 文档: popupType

焦点说明

SearchBar 的 searchEdit 位于主窗口中(不在 Popup 内部),Up/Down/Enter/Escape 键盘导航由 searchEdit.Keys.onPressed 处理。Popup.Window(Qt::Tool 类型)不会抢占主窗口键盘焦点,searchEdit 保持焦点,现有键盘导航继续可用。

Log: fix popup clipping issue
Bug: https://github.com/linuxdeepin/dde-control-center

Summary by Sourcery

Render SearchBar results in a separately positioned window so the popup can extend beyond the main window boundary.

Bug Fixes:

  • Allow the SearchBar results popup to render beyond the main window boundary without being clipped.

Enhancements:

  • Position the popup relative to the search field using global coordinates, preserve keyboard and outside-click dismissal behavior, and align its appearance with other window-based popups.
  • Simplify popup transitions by retaining opacity animation without scale animation.

Set popupType to Popup.Window so the search result popup renders as an
independent platform window, fixing the issue where it was clipped by
the main window boundary.

- Add popupType: Popup.Window
- Add PopupHandle.enableBlurWindow for consistent blur/rounded corners
- Add closePolicy for proper close behavior in Window mode
- Add positionWindow() using mapToGlobal/mapFromGlobal for correct
  positioning with DWindow titlebar offset
- Remove scale animation, keep only opacity for Window mode compatibility

Log: fix popup clipping issue
Bug: https://github.com/linuxdeepin/dde-control-center
@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743

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

@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates the SearchBar results popup to use an independently rendered window, allowing it to extend beyond the main window while retaining expected positioning, dismissal behavior, styling, and keyboard usability.

Sequence diagram for positioning and dismissing the SearchBar popup

sequenceDiagram
    participant SearchBar
    participant PopupWindow
    participant Window

    SearchBar->>PopupWindow: onOpened
    PopupWindow->>PopupWindow: positionWindow()
    PopupWindow->>SearchBar: searchEdit.mapToGlobal(0, 0)
    PopupWindow->>Window: Window.window.mapFromGlobal(globalPos.x, globalPos.y)
    PopupWindow-->>PopupWindow: set x and y below searchEdit

    alt Escape pressed
        SearchBar->>PopupWindow: close
    else Press outside parent
        SearchBar->>PopupWindow: close
    end
Loading

File-Level Changes

Change Details Files
Render the search results popup as an independent window and position it relative to the search field using global coordinate mapping.
  • Import window APIs and set popupType to Popup.Window to avoid parent-window clipping.
  • Map the search field’s position through global coordinates and position the popup below it when opened.
  • Configure outside-parent and Escape dismissal for window mode.
src/dde-control-center/plugin/SearchBar.qml
Preserve the popup’s visual styling while adapting transitions for independent-window rendering.
  • Enable blur-window styling for the popup.
  • Remove scale animations and retain opacity-only enter and exit transitions.
src/dde-control-center/plugin/SearchBar.qml

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

@18202781743
18202781743 marked this pull request as ready for review September 4, 2026 09:58

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

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

## Individual Comments

### Comment 1
<location path="src/dde-control-center/plugin/SearchBar.qml" line_range="114-125" />
<code_context>
         height: (view.count > 7 ? 7 : view.count) * 32 + 15
         padding: 5
+
+        function positionWindow() {
+            var globalPos = searchEdit.mapToGlobal(0, 0)
+            var w = Window.window
+            if (w) {
+                var localPos = w.mapFromGlobal(globalPos.x, globalPos.y)
+                x = localPos.x
+                y = localPos.y + searchEdit.height
+            }
+        }
+
+        onOpened: {
+            positionWindow()
+        }
         ListView {
</code_context>
<issue_to_address>
**issue (broader_impact):** The independent popup window is positioned only once in `onOpened`; when the main control-center window moves or the SearchBar is repositioned while the results popup remains open, the popup stays at its old screen coordinates instead of following `searchEdit`.

**Triggers:** When the user moves or reflows the main window while search results are open.

**Suggested fix:** Reposition the popup when the parent window or SearchBar position changes, or close and reopen it when the anchor moves.
</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.

Comment on lines +114 to +125
function positionWindow() {
var globalPos = searchEdit.mapToGlobal(0, 0)
var w = Window.window
if (w) {
var localPos = w.mapFromGlobal(globalPos.x, globalPos.y)
x = localPos.x
y = localPos.y + searchEdit.height
}
}

onOpened: {
positionWindow()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (broader_impact): The independent popup window is positioned only once in onOpened; when the main control-center window moves or the SearchBar is repositioned while the results popup remains open, the popup stays at its old screen coordinates instead of following searchEdit.

Triggers: When the user moves or reflows the main window while search results are open.

Suggested fix: Reposition the popup when the parent window or SearchBar position changes, or close and reopen it when the anchor moves.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 98 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 未发现安全漏洞,代码变更质量高。修改聚焦于修复 Popup 窗口裁剪问题,实现方案与参考实现一致,逻辑清晰,代码结构合理。仅存在少量代码质量改进建议。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['建议在 positionWindow() 函数前添加简要注释,说明该函数通过全局坐标映射定位 Popup 窗口位置,参考 datetime 插件实现']


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 修复安全漏洞,加强输入验证


💡 改进建议代码示例

// 暂无代码示例

本报告由 AI 代码审查工具自动生成

@deepin-bot

deepin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.106
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3497

@deepin-bot

deepin-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.107
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3503

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.

2 participants