mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-10-04 17:41:42 +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:
@@ -23,6 +23,7 @@
|
|||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
#include <QtGui/QDropEvent>
|
#include <QtGui/QDropEvent>
|
||||||
#include <QtGui/QMouseEvent>
|
#include <QtGui/QMouseEvent>
|
||||||
|
#include <QtGui/QDesktopServices>
|
||||||
|
|
||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
#include "playlist/PlaylistView.h"
|
#include "playlist/PlaylistView.h"
|
||||||
@@ -124,6 +125,7 @@ AudioControls::AudioControls( QWidget* parent )
|
|||||||
connect( ui->albumLabel, SIGNAL( clickedAlbum() ), SLOT( onAlbumClicked() ) );
|
connect( ui->albumLabel, SIGNAL( clickedAlbum() ), SLOT( onAlbumClicked() ) );
|
||||||
connect( ui->socialButton, SIGNAL( clicked() ), SLOT( onSocialButtonClicked() ) );
|
connect( ui->socialButton, SIGNAL( clicked() ), SLOT( onSocialButtonClicked() ) );
|
||||||
connect( ui->loveButton, SIGNAL( clicked( bool ) ), SLOT( onLoveButtonClicked( bool ) ) );
|
connect( ui->loveButton, SIGNAL( clicked( bool ) ), SLOT( onLoveButtonClicked( bool ) ) );
|
||||||
|
connect( ui->ownerButton, SIGNAL( clicked() ), SLOT( onOwnerButtonClicked() ) );
|
||||||
|
|
||||||
// <From AudioEngine>
|
// <From AudioEngine>
|
||||||
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) );
|
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() ) );
|
ui->ownerButton->setToolTip( QString( tr( "Playing from %1" ) ).arg( result->friendlySource() ) );
|
||||||
QPixmap sourceIcon = result->sourceIcon().scaled( ui->ownerButton->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
QPixmap sourceIcon = result->sourceIcon().scaled( ui->ownerButton->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
ui->ownerButton->setPixmap( sourceIcon );
|
ui->ownerButton->setPixmap( sourceIcon );
|
||||||
|
if ( QUrl( result->purchaseUrl() ).isValid() || !result->collection().isNull() )
|
||||||
|
ui->ownerButton->setCursor( Qt::PointingHandCursor );
|
||||||
|
else
|
||||||
|
ui->ownerButton->setCursor( Qt::ArrowCursor );
|
||||||
|
|
||||||
setCover();
|
setCover();
|
||||||
setSocialActions();
|
setSocialActions();
|
||||||
@@ -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() );
|
||||||
|
}
|
||||||
|
@@ -81,6 +81,7 @@ private slots:
|
|||||||
void onTrackClicked();
|
void onTrackClicked();
|
||||||
void onSocialButtonClicked();
|
void onSocialButtonClicked();
|
||||||
void onLoveButtonClicked( bool );
|
void onLoveButtonClicked( bool );
|
||||||
|
void onOwnerButtonClicked();
|
||||||
|
|
||||||
void droppedTracks( QList<Tomahawk::query_ptr> );
|
void droppedTracks( QList<Tomahawk::query_ptr> );
|
||||||
|
|
||||||
|
@@ -73,6 +73,7 @@ public:
|
|||||||
QString mimetype() const { return m_mimetype; }
|
QString mimetype() const { return m_mimetype; }
|
||||||
QString friendlySource() const;
|
QString friendlySource() const;
|
||||||
QPixmap sourceIcon() const;
|
QPixmap sourceIcon() const;
|
||||||
|
QString purchaseUrl() const { return m_purchaseUrl; }
|
||||||
|
|
||||||
unsigned int duration() const { return m_duration; }
|
unsigned int duration() const { return m_duration; }
|
||||||
unsigned int bitrate() const { return m_bitrate; }
|
unsigned int bitrate() const { return m_bitrate; }
|
||||||
@@ -89,6 +90,7 @@ public:
|
|||||||
void setCollection( const Tomahawk::collection_ptr& collection );
|
void setCollection( const Tomahawk::collection_ptr& collection );
|
||||||
void setFriendlySource( const QString& s ) { m_friendlySource = s; }
|
void setFriendlySource( const QString& s ) { m_friendlySource = s; }
|
||||||
void setSourceIcon( const QPixmap& i ) { m_sourceIcon = i; }
|
void setSourceIcon( const QPixmap& i ) { m_sourceIcon = i; }
|
||||||
|
void setPurchaseUrl( const QString& u ) { m_purchaseUrl = u; }
|
||||||
void setArtist( const Tomahawk::artist_ptr& artist );
|
void setArtist( const Tomahawk::artist_ptr& artist );
|
||||||
void setAlbum( const Tomahawk::album_ptr& album );
|
void setAlbum( const Tomahawk::album_ptr& album );
|
||||||
void setComposer( const Tomahawk::artist_ptr& composer );
|
void setComposer( const Tomahawk::artist_ptr& composer );
|
||||||
@@ -138,6 +140,7 @@ private:
|
|||||||
Tomahawk::artist_ptr m_composer;
|
Tomahawk::artist_ptr m_composer;
|
||||||
QString m_track;
|
QString m_track;
|
||||||
QString m_url;
|
QString m_url;
|
||||||
|
QString m_purchaseUrl;
|
||||||
QString m_mimetype;
|
QString m_mimetype;
|
||||||
QString m_friendlySource;
|
QString m_friendlySource;
|
||||||
QPixmap m_sourceIcon;
|
QPixmap m_sourceIcon;
|
||||||
|
@@ -433,6 +433,7 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
|
|||||||
rp->setRID( uuid() );
|
rp->setRID( uuid() );
|
||||||
rp->setFriendlySource( name() );
|
rp->setFriendlySource( name() );
|
||||||
rp->setSourceIcon( icon() );
|
rp->setSourceIcon( icon() );
|
||||||
|
rp->setPurchaseUrl( m.value( "purchaseUrl" ).toString() );
|
||||||
rp->setScore( m.value( "score" ).toFloat() );
|
rp->setScore( m.value( "score" ).toFloat() );
|
||||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||||
|
|
||||||
|
@@ -283,6 +283,7 @@ ScriptResolver::handleMsg( const QByteArray& msg )
|
|||||||
rp->setRID( uuid() );
|
rp->setRID( uuid() );
|
||||||
rp->setFriendlySource( m_name );
|
rp->setFriendlySource( m_name );
|
||||||
rp->setSourceIcon( m_icon );
|
rp->setSourceIcon( m_icon );
|
||||||
|
rp->setPurchaseUrl( m.value( "purchaseUrl" ).toString() );
|
||||||
rp->setYear( m.value( "year").toUInt() );
|
rp->setYear( m.value( "year").toUInt() );
|
||||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user