Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions qt6/src/qml/Popup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,30 @@ 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)

// Sticky-max ratchet for Popup.Window: the popup's implicit size is by
// default derived from background + contentItem, so keeping the largest
// size during an open session is done via the background's implicit size
// (windowBlurComponent) rather than overriding implicitWidth/Height here.
// Content shrinking (e.g. search filtering) then no longer jumps the
// popup window smaller. Reset on aboutToShow for each open session.
property real _maxImplicitWidth: 0
property real _maxImplicitHeight: 0

onAboutToShow: {
if (control.popupType === Popup.Window) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

implicitWidth和implicitHeight不应该有这么复杂的设置吧,跟DS.Style.control.contentImplicitWidth(control)是不是一样的,只是没有绑定而已,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

认可,并且这个数字忽大忽小的,而且很多时候并不严格按照选项宽度来。需要跟随一下这个数字的来由。
计算规则的别扭本身来源就在这里。

control._maxImplicitWidth = control.implicitContentWidth
+ control.leftPadding + control.rightPadding
control._maxImplicitHeight = control.implicitContentHeight
+ control.topPadding + control.bottomPadding
}
}
onImplicitContentWidthChanged: if (control.popupType === Popup.Window)
control._maxImplicitWidth = Math.max(control._maxImplicitWidth,
control.implicitContentWidth + control.leftPadding + control.rightPadding)
onImplicitContentHeightChanged: if (control.popupType === Popup.Window)
control._maxImplicitHeight = Math.max(control._maxImplicitHeight,
control.implicitContentHeight + control.topPadding + control.bottomPadding)

padding: DS.Style.popup.padding

Expand All @@ -28,7 +50,10 @@ T.Popup {

Component {
id: windowBlurComponent
D.StyledBehindWindowBlur { }
D.StyledBehindWindowBlur {
implicitWidth: control._maxImplicitWidth
implicitHeight: control._maxImplicitHeight
}
}

Component {
Expand Down
Loading