Skip to content

Fix display of multiline menu items

Currently, multiline text in menu items is displayed incorrectly: the bounding rectangle is calculated ignoring newlines, while the newline is displayed in the resulting menu, and the text is cropped.

This commit makes it so the newline is considered in the calculation as well. To do so, we get text metrics ourselves instead of delegating it to the ancient QMenu code that forces Qt::TextSingleLine.

Note that this approach is not new:

Note that this commit does not imply that it is a good idea to use multiline menu item text in KDE apps from now on; it merely fixes an existing rendering defect that caused multiline actions to look wrong in StatusNotifierItems.

Before:

Screenshot_20240126_002332.png

After:

Screenshot_20240126_002406.png

With icons:

Screenshot_20240126_005541

In a very imaginary app:

Screenshot_20240126_005700.png

BUG: 477299

Edited by Ilya Bizyaev

Merge request reports