[vlc-commits] qt: avoid displaying mnemonic char and text elision

Pierre Lamot git at videolan.org
Sun Dec 10 00:35:42 CET 2017


vlc/vlc-3.0 | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Dec  7 16:16:27 2017 +0100| [2c0388471155aa3d9aa25c83c26a9a9417b92f42] | committer: Jean-Baptiste Kempf

qt: avoid displaying mnemonic char and text elision

'&' char might be added by accelerators like KAcceleratorManager

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 4273ef6f07a771782fcc4b296e5ffa4caf2e8cc4)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=2c0388471155aa3d9aa25c83c26a9a9417b92f42
---

 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 );



More information about the vlc-commits mailing list