fix(qt): measure the compact album title outside the Text to end a width binding loop
The compact heading sized its title with the Text's own implicitWidth while eliding it; an elided Text recomputes its implicit size after laying out at the bound width, so Qt reported a binding loop on `width` on every album open (measured in a 30-minute session log). A TextMetrics with the same font gives the natural width without feeding the loop. cc
This commit is contained in:
1 file changed
+12
-1
@@ -1001,11 +1001,22 @@ Rectangle {
|
||||
anchors.rightMargin: 10
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 0
|
||||
// The title's natural width, measured OUTSIDE the
|
||||
// Text: an elided Text recomputes its implicit size
|
||||
// after laying out at the bound width, so a `width`
|
||||
// that reads its own `implicitWidth` is a binding
|
||||
// loop (Qt reported it on every album open).
|
||||
TextMetrics {
|
||||
id: compactTitleMetrics
|
||||
font.pixelSize: theme.fontSection
|
||||
font.weight: theme.weightBold
|
||||
text: albumHeader.title || ""
|
||||
}
|
||||
Text {
|
||||
id: compactAlbumTitle
|
||||
width: (albumHeader.artist || "") === ""
|
||||
? compactHeading.width
|
||||
: Math.min(implicitWidth,
|
||||
: Math.min(Math.ceil(compactTitleMetrics.advanceWidth),
|
||||
Math.max(80, compactHeading.width * 0.62))
|
||||
text: albumHeader.title || ""
|
||||
color: root.hdrStrong
|
||||
|
||||
Reference in new issue
Block a user