https://bugs.kde.org/show_bug.cgi?id=477299

Ilya Bizyaev <bizy...@zoho.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Latest Commit|                            |https://invent.kde.org/plas
                   |                            |ma/breeze/-/commit/a4d892f6
                   |                            |8ce77198812fccbeabfb79f97ce
                   |                            |36688
         Resolution|---                         |FIXED

--- Comment #7 from Ilya Bizyaev <bizy...@zoho.com> ---
Git commit a4d892f68ce77198812fccbeabfb79f97ce36688 by Ilya Bizyaev.
Committed on 30/01/2024 at 11:19.
Pushed by ilyabizyaev into branch 'master'.

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:

* In Breeze, the code right below for `QStyleOptionMenuItem::Separator` also
gets text metrics.
* In Qt, the Fusion style also requests font metrics:
https://invent.kde.org/qt/qt/qtbase/-/blob/dev/src/widgets/styles/qfusionstyle.cpp#L3084-3088

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](/uploads/655175fb8ac21ac0b558a0898d7e61de/Screenshot_20240126_002332.png)

After:

![Screenshot_20240126_002406.png](/uploads/b1d791c82b40d46030a7aad83f3d83e3/Screenshot_20240126_002406.png)

With icons:

![Screenshot_20240126_005541](/uploads/fe3632884c8b4b4c78a3ace7d70d5340/Screenshot_20240126_005541.png)

In a very imaginary app:

![Screenshot_20240126_005700.png](/uploads/b7dda2780c8933d36117611e455cfcce/Screenshot_20240126_005700.png)

M  +10   -2    kstyle/breezestyle.cpp

https://invent.kde.org/plasma/breeze/-/commit/a4d892f68ce77198812fccbeabfb79f97ce36688

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to