mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Encode spaces as + and unify encoding logic in GlobalActionManager
This commit is contained in:
parent
0f6b903139
commit
1e0a00dbe2
@ -103,8 +103,7 @@ GlobalActionManager::copyOpenLink( const artist_ptr& artist ) const
|
||||
const QUrl link( QString( "%1/artist/%2" ).arg( hostname() ).arg( artist->name() ) );
|
||||
|
||||
QClipboard* cb = QApplication::clipboard();
|
||||
QByteArray data = link.toEncoded();
|
||||
data.replace( "'", "%27" ); // QUrl doesn't encode ', which it doesn't have to. Some apps don't like ' though, and want %27. Both are valid.
|
||||
QByteArray data = percentEncode( link );
|
||||
cb->setText( data );
|
||||
|
||||
return link;
|
||||
@ -114,11 +113,11 @@ GlobalActionManager::copyOpenLink( const artist_ptr& artist ) const
|
||||
QUrl
|
||||
GlobalActionManager::copyOpenLink( const album_ptr& album ) const
|
||||
{
|
||||
const QUrl link( QString( "%1/album/%2/%3" ).arg( hostname() ).arg( album->artist().isNull() ? QString() : album->artist()->name() ).arg( album->name()) );
|
||||
const QUrl link = QUrl::fromUserInput( QString( "%1/album/%2/%3" ).arg( hostname() ).arg( album->artist().isNull() ? QString() : album->artist()->name() ).arg( album->name() ) );
|
||||
|
||||
QClipboard* cb = QApplication::clipboard();
|
||||
QByteArray data = link.toEncoded();
|
||||
data.replace( "'", "%27" ); // QUrl doesn't encode ', which it doesn't have to. Some apps don't like ' though, and want %27. Both are valid.
|
||||
QByteArray data = percentEncode( link );
|
||||
|
||||
cb->setText( data );
|
||||
|
||||
return link;
|
||||
@ -255,8 +254,7 @@ GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
|
||||
}
|
||||
|
||||
QClipboard* cb = QApplication::clipboard();
|
||||
QByteArray data = link.toEncoded();
|
||||
data.replace( "'", "%27" ); // QUrl doesn't encode ', which it doesn't have to. Some apps don't like ' though, and want %27. Both are valid.
|
||||
QByteArray data = percentEncode( link );
|
||||
cb->setText( data );
|
||||
|
||||
return link.toString();
|
||||
@ -1217,8 +1215,7 @@ GlobalActionManager::shortenLinkRequestFinished()
|
||||
{
|
||||
QClipboard* cb = QApplication::clipboard();
|
||||
|
||||
QByteArray data = error ? longUrl.toEncoded() : shortUrl.toEncoded();
|
||||
data.replace( "'", "%27" ); // QUrl doesn't encode ', which it doesn't have to. Some apps don't like ' though, and want %27. Both are valid.
|
||||
QByteArray data = percentEncode( error ? longUrl : shortUrl );
|
||||
cb->setText( data );
|
||||
|
||||
m_clipboardLongUrl.clear();
|
||||
@ -1250,8 +1247,7 @@ GlobalActionManager::postShortenFinished()
|
||||
qDebug() << "GOT POSTED SHORT URL:" << url.toString();
|
||||
QClipboard* cb = QApplication::clipboard();
|
||||
|
||||
QByteArray data = url.toEncoded();
|
||||
data.replace( "'", "%27" ); // QUrl doesn't encode ', which it doesn't have to. Some apps don't like ' though, and want %27. Both are valid.
|
||||
const QByteArray data = percentEncode( url );
|
||||
cb->setText( data );
|
||||
|
||||
reply->deleteLater();
|
||||
@ -1387,5 +1383,18 @@ GlobalActionManager::openRdioLink( const QString& link )
|
||||
QString
|
||||
GlobalActionManager::hostname() const
|
||||
{
|
||||
return QString( "http://toma.hk" );
|
||||
return QString( "http://stage.toma.hk" );
|
||||
}
|
||||
|
||||
|
||||
QByteArray
|
||||
GlobalActionManager::percentEncode (const QUrl &url ) const
|
||||
{
|
||||
QByteArray data = url.toEncoded();
|
||||
|
||||
data.replace( "'", "%27" ); // QUrl doesn't encode ', which it doesn't have to. Some apps don't like ' though, and want %27. Both are valid.
|
||||
data.replace( "%20", "+" );
|
||||
data.replace( "&", "%26" );
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -131,6 +131,8 @@ private:
|
||||
|
||||
QString hostname() const;
|
||||
|
||||
inline QByteArray percentEncode( const QUrl& url ) const;
|
||||
|
||||
Tomahawk::playlist_ptr m_toShow;
|
||||
Tomahawk::query_ptr m_waitingToBookmark;
|
||||
Tomahawk::query_ptr m_waitingToPlay;
|
||||
|
Loading…
x
Reference in New Issue
Block a user