From 06bfa1633569c18d7b58c4f7493ce5f12127fd5d Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sun, 24 Mar 2013 03:13:17 +0100 Subject: [PATCH] Escape ampersands in menu entry strings * Fixes TWK-1172 --- src/libtomahawk/ContextMenu.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libtomahawk/ContextMenu.cpp b/src/libtomahawk/ContextMenu.cpp index 2cf7bef16..db2a14e48 100644 --- a/src/libtomahawk/ContextMenu.cpp +++ b/src/libtomahawk/ContextMenu.cpp @@ -109,13 +109,18 @@ ContextMenu::setQueries( const QList& queries ) if ( m_supportedActions & ActionPage && itemCount() == 1 ) { + // Ampersands need to be escaped as they indicate a keyboard shortcut + QString track = m_queries.first()->track().replace( QString( "&" ), QString( "&&" ) ); m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/track-icon.svg" ), - tr( "&Go to \"%1\"" ).arg( m_queries.first()->track() ) ), ActionTrackPage ); - if ( !m_queries.first()->album().isEmpty() ) + tr( "&Go to \"%1\"" ).arg( track ) ), ActionTrackPage ); + if ( !m_queries.first()->album().isEmpty() ) { + QString album = m_queries.first()->album().replace( QString( "&" ), QString( "&&" ) ); m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/album-icon.svg" ), - tr( "Go to \"%1\"" ).arg( m_queries.first()->album() ) ), ActionAlbumPage ); + tr( "Go to \"%1\"" ).arg( album ) ), ActionAlbumPage ); + } + QString artist = m_queries.first()->artist().replace( QString( "&" ), QString( "&&" ) ); m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/artist-icon.svg" ), - tr( "Go to \"%1\"" ).arg( m_queries.first()->artist() ) ), ActionArtistPage ); + tr( "Go to \"%1\"" ).arg( artist ) ), ActionArtistPage ); } addSeparator();