From 6c08a27b3ae8389210b24b9aa23c659e74609509 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sun, 24 Mar 2013 03:23:28 +0100 Subject: [PATCH] Add ampersand escaping for Albums and Artists --- src/libtomahawk/ContextMenu.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libtomahawk/ContextMenu.cpp b/src/libtomahawk/ContextMenu.cpp index 7716b8af5..2425fa329 100644 --- a/src/libtomahawk/ContextMenu.cpp +++ b/src/libtomahawk/ContextMenu.cpp @@ -110,15 +110,15 @@ 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( "&&" ) ); + const 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( track ) ), ActionTrackPage ); if ( !m_queries.first()->album().isEmpty() ) { - QString album = m_queries.first()->album().replace( QString( "&" ), QString( "&&" ) ); + const 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( album ) ), ActionAlbumPage ); } - QString artist = m_queries.first()->artist().replace( QString( "&" ), QString( "&&" ) ); + const 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( artist ) ), ActionArtistPage ); } @@ -172,10 +172,12 @@ ContextMenu::setAlbums( const QList& albums ) if ( m_supportedActions & ActionPage && itemCount() == 1 ) { + const QString album = m_albums.first()->name().replace( QString( "&" ), QString( "&&" ) ); m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/album-icon.svg" ), - tr( "&Go to \"%1\"" ).arg( m_albums.first()->name() ) ), ActionAlbumPage ); + tr( "&Go to \"%1\"" ).arg( album ) ), ActionAlbumPage ); + const QString artist = m_albums.first()->artist()->name().replace( QString( "&" ), QString( "&&" ) ); m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/artist-icon.svg" ), - tr( "Go to \"%1\"" ).arg( m_albums.first()->artist()->name() ) ), ActionArtistPage ); + tr( "Go to \"%1\"" ).arg( artist ) ), ActionArtistPage ); } //m_sigmap->setMapping( addAction( tr( "&Add to Playlist" ) ), ActionAddToPlaylist ); @@ -219,9 +221,11 @@ ContextMenu::setArtists( const QList& artists ) addSeparator(); - if ( m_supportedActions & ActionPage && itemCount() == 1 ) + if ( m_supportedActions & ActionPage && itemCount() == 1 ) { + const QString artist = m_artists.first()->name().replace( QString( "&" ), QString( "&&" ) ); m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/artist-icon.svg" ), - tr( "&Go to \"%1\"" ).arg( m_artists.first()->name() ) ), ActionArtistPage ); + tr( "&Go to \"%1\"" ).arg( artist ) ), ActionArtistPage ); + } //m_sigmap->setMapping( addAction( tr( "&Add to Playlist" ) ), ActionAddToPlaylist );