1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-30 17:20:26 +02:00

Support linkUrl for results to allow clicking on source icon

This commit is contained in:
Leo Franchi
2012-09-18 11:36:12 -04:00
parent 2a2b918772
commit b65f414695
4 changed files with 11 additions and 6 deletions

View File

@@ -263,7 +263,7 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
ui->ownerButton->setToolTip( QString( tr( "Playing from %1" ) ).arg( result->friendlySource() ) );
QPixmap sourceIcon = result->sourceIcon().scaled( ui->ownerButton->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui->ownerButton->setPixmap( sourceIcon );
if ( QUrl( result->purchaseUrl() ).isValid() || !result->collection().isNull() )
if ( QUrl( result->linkUrl() ).isValid() || !result->collection().isNull() )
ui->ownerButton->setCursor( Qt::PointingHandCursor );
else
ui->ownerButton->setCursor( Qt::ArrowCursor );
@@ -390,15 +390,15 @@ void
AudioControls::onPlaybackTimer( qint64 msElapsed )
{
//tDebug() << Q_FUNC_INFO;
m_phononTickCheckTimer.stop();
if ( m_currentTrack.isNull() )
{
m_sliderTimeLine.stop();
return;
}
const int seconds = msElapsed / 1000;
if ( seconds != m_lastTextSecondShown )
{
@@ -414,7 +414,7 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
int currentTime = m_sliderTimeLine.currentTime();
//tDebug( LOGEXTRA ) << Q_FUNC_INFO << "msElapsed =" << msElapsed << "and timer current time =" << m_sliderTimeLine.currentTime();
// First condition checks for the common case where
// 1) the track has been started
// 2) we haven't seeked,
@@ -675,7 +675,7 @@ AudioControls::onOwnerButtonClicked()
{
if ( m_currentTrack->collection().isNull() )
{
QUrl url = QUrl( m_currentTrack->purchaseUrl() );
QUrl url = QUrl( m_currentTrack->linkUrl() );
if ( url.isValid() )
QDesktopServices::openUrl( url );
}

View File

@@ -74,6 +74,7 @@ public:
QString friendlySource() const;
QPixmap sourceIcon() const;
QString purchaseUrl() const { return m_purchaseUrl; }
QString linkUrl() const { return m_linkUrl; }
unsigned int duration() const { return m_duration; }
unsigned int bitrate() const { return m_bitrate; }
@@ -90,6 +91,7 @@ public:
void setCollection( const Tomahawk::collection_ptr& collection );
void setFriendlySource( const QString& s ) { m_friendlySource = s; }
void setPurchaseUrl( const QString& u ) { m_purchaseUrl = u; }
void setLinkUrl( const QString& u ) { m_linkUrl = u; }
void setArtist( const Tomahawk::artist_ptr& artist );
void setAlbum( const Tomahawk::album_ptr& album );
void setComposer( const Tomahawk::artist_ptr& composer );
@@ -143,6 +145,7 @@ private:
QString m_track;
QString m_url;
QString m_purchaseUrl;
QString m_linkUrl;
QString m_mimetype;
QString m_friendlySource;

View File

@@ -434,6 +434,7 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
rp->setFriendlySource( name() );
rp->setSourceIcon( new QPixmap( icon() ) );
rp->setPurchaseUrl( m.value( "purchaseUrl" ).toString() );
rp->setLinkUrl( m.value( "linkUrl" ).toString() );
rp->setScore( m.value( "score" ).toFloat() );
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );

View File

@@ -284,6 +284,7 @@ ScriptResolver::handleMsg( const QByteArray& msg )
rp->setFriendlySource( m_name );
rp->setSourceIcon( new QPixmap( m_icon ) );
rp->setPurchaseUrl( m.value( "purchaseUrl" ).toString() );
rp->setLinkUrl( m.value( "linkUrl" ).toString() );
rp->setYear( m.value( "year").toUInt() );
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );