1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 15:47:38 +02:00

open purchaseUrl on source icon click. Every result has its own url, its up to the resolver to provide urls for every song or a general one that is the same for every result.

This commit is contained in:
Kilian Lackhove
2012-09-14 19:50:03 +02:00
parent af9d4cc76b
commit 8169cf942a
5 changed files with 26 additions and 1 deletions

View File

@@ -23,6 +23,7 @@
#include <QtNetwork/QNetworkReply>
#include <QtGui/QDropEvent>
#include <QtGui/QMouseEvent>
#include <QtGui/QDesktopServices>
#include "audio/AudioEngine.h"
#include "playlist/PlaylistView.h"
@@ -124,6 +125,7 @@ AudioControls::AudioControls( QWidget* parent )
connect( ui->albumLabel, SIGNAL( clickedAlbum() ), SLOT( onAlbumClicked() ) );
connect( ui->socialButton, SIGNAL( clicked() ), SLOT( onSocialButtonClicked() ) );
connect( ui->loveButton, SIGNAL( clicked( bool ) ), SLOT( onLoveButtonClicked( bool ) ) );
connect( ui->ownerButton, SIGNAL( clicked() ), SLOT( onOwnerButtonClicked() ) );
// <From AudioEngine>
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) );
@@ -261,6 +263,10 @@ 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() )
ui->ownerButton->setCursor( Qt::PointingHandCursor );
else
ui->ownerButton->setCursor( Qt::ArrowCursor );
setCover();
setSocialActions();
@@ -361,7 +367,7 @@ AudioControls::onPlaybackStopped()
m_sliderTimeLine.setCurrentTime( 0 );
m_phononTickCheckTimer.stop();
ui->ownerButton->setPixmap( RESPATH "images/resolver-default.png" );
ui->stackedLayout->setCurrentWidget( ui->playPauseButton );
ui->loveButton->setEnabled( false );
ui->loveButton->setVisible( false );
@@ -663,3 +669,16 @@ AudioControls::onLoveButtonClicked( bool checked )
}
}
void
AudioControls::onOwnerButtonClicked()
{
if ( m_currentTrack->collection().isNull() )
{
QUrl url = QUrl( m_currentTrack->purchaseUrl() );
if ( url.isValid() )
QDesktopServices::openUrl( url );
}
else
ViewManager::instance()->show( m_currentTrack->collection() );
}

View File

@@ -81,6 +81,7 @@ private slots:
void onTrackClicked();
void onSocialButtonClicked();
void onLoveButtonClicked( bool );
void onOwnerButtonClicked();
void droppedTracks( QList<Tomahawk::query_ptr> );

View File

@@ -73,6 +73,7 @@ public:
QString mimetype() const { return m_mimetype; }
QString friendlySource() const;
QPixmap sourceIcon() const;
QString purchaseUrl() const { return m_purchaseUrl; }
unsigned int duration() const { return m_duration; }
unsigned int bitrate() const { return m_bitrate; }
@@ -89,6 +90,7 @@ public:
void setCollection( const Tomahawk::collection_ptr& collection );
void setFriendlySource( const QString& s ) { m_friendlySource = s; }
void setSourceIcon( const QPixmap& i ) { m_sourceIcon = i; }
void setPurchaseUrl( const QString& u ) { m_purchaseUrl = u; }
void setArtist( const Tomahawk::artist_ptr& artist );
void setAlbum( const Tomahawk::album_ptr& album );
void setComposer( const Tomahawk::artist_ptr& composer );
@@ -138,6 +140,7 @@ private:
Tomahawk::artist_ptr m_composer;
QString m_track;
QString m_url;
QString m_purchaseUrl;
QString m_mimetype;
QString m_friendlySource;
QPixmap m_sourceIcon;

View File

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

View File

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