[vlc-devel] [PATCH 1/2] qt: avoid displaying mnemonic char and text elision
Pierre Lamot
pierre at videolabs.io
Thu Dec 7 16:16:27 CET 2017
'&' char might be added by accelerators like KAcceleratorManager
---
modules/gui/qt/components/playlist/playlist.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt/components/playlist/playlist.cpp b/modules/gui/qt/components/playlist/playlist.cpp
index d1f7d5543e..61bdc578c4 100644
--- a/modules/gui/qt/components/playlist/playlist.cpp
+++ b/modules/gui/qt/components/playlist/playlist.cpp
@@ -390,9 +390,9 @@ void LocationButton::paintEvent ( QPaintEvent * )
QString str( text() );
/* This check is absurd, but either it is not done properly inside elidedText(),
or boundingRect() is wrong */
- if( r.width() < fontMetrics().boundingRect( text() ).width() )
- str = fontMetrics().elidedText( text(), Qt::ElideRight, r.width() );
- p.drawText( r, Qt::AlignVCenter | Qt::AlignLeft, str );
+ if( r.width() < fontMetrics().size(Qt::TextHideMnemonic, text()).width() )
+ str = fontMetrics().elidedText( text(), Qt::ElideRight, r.width(), Qt::TextHideMnemonic );
+ p.drawText( r, Qt::AlignVCenter | Qt::AlignLeft | Qt::TextHideMnemonic , str );
if( b_arrow )
{
@@ -404,7 +404,7 @@ void LocationButton::paintEvent ( QPaintEvent * )
QSize LocationButton::sizeHint() const
{
- QSize s( fontMetrics().boundingRect( text() ).size() );
+ QSize s( fontMetrics().size( Qt::TextHideMnemonic, text() ) );
/* Add two pixels to width: font metrics are buggy, if you pass text through elidation
with exactly the width of its bounding rect, sometimes it still elides */
s.setWidth( s.width() + ( 2 * PADDING ) + ( b_arrow ? 10 : 0 ) + 2 );
--
2.14.1
More information about the vlc-devel
mailing list