From 0d3e8e666ca686a5942e0a21d85f01ff9c06a6c4 Mon Sep 17 00:00:00 2001 From: wangjinrun Date: Tue, 25 Aug 2026 15:12:26 +0800 Subject: [PATCH] fix(popup): set fixed default implicit size for Window popupType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After commit cba9773 removed the background Item's implicitWidth binding to break a binding loop, Popup's implicitWidth started tracking contentImplicitWidth directly. When popupType is Popup.Window, QQuickPopupWindow::implicitWidthChanged() unconditionally adopts popup->implicitWidth(), so search filtering that shrinks the content causes the popup window to jump to a smaller width. Instead of overriding implicitWidth/Height directly or using a ratchet mechanism, give StyledBehindWindowBlur (the Window popupType background) a fixed default implicit size — DS.Style.popup.width/height — matching the approach already used by FloatingPanel for the non-Window popupType. This provides a size floor so content shrinking no longer jumps the popup window smaller, while still allowing growth when content is larger. No binding loop because the values are constants. 修复 Popup 在 Window popupType 下宽度跳变问题 commit cba9773 移除 background Item 的 implicitWidth 绑定以消除绑定环后, Popup 的 implicitWidth 直接随 contentImplicitWidth 变化。当 popupType 为 Popup.Window 时,QQuickPopupWindow::implicitWidthChanged() 无条件采用 popup->implicitWidth(),搜索过滤导致内容减少时窗口宽度跳变。 不再直接覆盖 implicitWidth/Height 或使用棘轮机制,而是给 StyledBehindWindowBlur(Window popupType 的 background)设置固定默认隐式尺寸 —— DS.Style.popup.width/height —— 与 FloatingPanel(非 Window popupType)的 做法一致。这提供了尺寸下限,内容缩减时 popup 不再跳变到极小,内容更大时仍可 增长。值为常量,无绑定环。 PMS: BUG-373823、BUG-373843 --- qt6/src/qml/Popup.qml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qt6/src/qml/Popup.qml b/qt6/src/qml/Popup.qml index 6b861333..51446322 100644 --- a/qt6/src/qml/Popup.qml +++ b/qt6/src/qml/Popup.qml @@ -17,8 +17,6 @@ T.Popup { property bool closeOnInactive: true readonly property bool active: parent && parent.Window.active - implicitWidth: DS.Style.control.implicitWidth(control) - implicitHeight: DS.Style.control.implicitHeight(control) padding: DS.Style.popup.padding @@ -28,7 +26,10 @@ T.Popup { Component { id: windowBlurComponent - D.StyledBehindWindowBlur { } + D.StyledBehindWindowBlur { + implicitWidth: DS.Style.popup.width + implicitHeight: DS.Style.popup.height + } } Component {