Bug 441827 - Popup with multi-line text is sized as if it were single line
Summary: Popup with multi-line text is sized as if it were single line
Status: REOPENED
Alias: None
Product: frameworks-qqc2-desktop-style
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.85.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-31 18:54 UTC by ratijas
Modified: 2022-01-06 18:21 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
KDE QQC2 Desktop style popup is too wide (26.60 KB, image/png)
2021-08-31 18:54 UTC, ratijas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ratijas 2021-08-31 18:54:03 UTC
Created attachment 141196 [details]
KDE QQC2 Desktop style popup is too wide

SUMMARY
Popup is wrongly sized when its text contains line breaks. I suppose it is because under the hood a TextMetrics QML Type[1] is used to calculate width of the popup's platform window, but TextMetrics doesn't support line breaks / multi-line text.

[1]: https://doc.qt.io/qt-5/qml-qtquick-textmetrics.html

STEPS TO REPRODUCE
1. Hover over any item that has a hint popup with multiline text, e.g.:
2. Go to system settings -> Shortcuts -> select any group/category -> select one with existing shortcut or create a new custom one; hover over the shortcut input component.

OBSERVED RESULT
Two lines of hint text in a popup which is sized like if it were one line joined with a white space instead of \n.


EXPECTED RESULT
Popup hint should be sized according to its content.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2
Kernel Version: 5.13.12-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-6700HQ CPU @ 2.60GHz
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 970M/PCIe/SSE2

ADDITIONAL INFORMATION
Comment 1 ratijas 2021-08-31 18:58:08 UTC
There is a signal-based API to get natural width of each line as soon as they are being laid out by text renderer. Might use that as a workaround; maybe in conjunction with off-screen rendering first, to prevent glitching and shuttering from fast consecutive resizes.

https://bugreports.qt.io/browse/QTBUG-78277
https://doc.qt.io/qt-5/qml-qtquick-text.html#lineLaidOut-signal
Comment 2 ratijas 2021-09-02 07:59:36 UTC
Seems like a known bug in Qt: https://bugreports.qt.io/browse/QTBUG-83630


Fix Version/s:
6.1.1, 6.2.0 Alpha
Comment 3 Nate Graham 2022-01-06 17:25:21 UTC
Yep, and it looks like that's already fixed in later versions of Qt.
Comment 4 ratijas 2022-01-06 18:11:32 UTC
> Yep, and it looks like that's already fixed in later versions of Qt.

Does not seem so. Both commits were reverted due to regressions.

We might need to roll out our own font metrics component with proper line breaks / wraps handling.

See also: https://t.me/vdgmainroom/296739
Comment 5 Nate Graham 2022-01-06 18:21:57 UTC
Oh, that sucks.