mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-17 19:37:09 +02:00
Buy / Download button styling on header & context view.
This commit is contained in:
@@ -237,6 +237,38 @@ Album::sortname() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
Album::purchaseUrl() const
|
||||||
|
{
|
||||||
|
Q_D( const Album );
|
||||||
|
if ( !d->purchaseUrlLoaded )
|
||||||
|
{
|
||||||
|
Tomahawk::InfoSystem::InfoStringHash albumInfo;
|
||||||
|
albumInfo["artist"] = d->artist->name();
|
||||||
|
albumInfo["album"] = d->name;
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||||
|
requestData.caller = infoid();
|
||||||
|
requestData.type = Tomahawk::InfoSystem::InfoAlbumPurchaseUrl;
|
||||||
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( albumInfo );
|
||||||
|
requestData.customData = QVariantMap();
|
||||||
|
requestData.allSources = true;
|
||||||
|
|
||||||
|
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||||
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
|
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||||
|
|
||||||
|
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||||
|
SIGNAL( finished( QString ) ),
|
||||||
|
SLOT( infoSystemFinished( QString ) ) );
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
|
}
|
||||||
|
|
||||||
|
return d->purchaseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap
|
QPixmap
|
||||||
Album::cover( const QSize& size, bool forceLoad ) const
|
Album::cover( const QSize& size, bool forceLoad ) const
|
||||||
{
|
{
|
||||||
@@ -318,8 +350,19 @@ void
|
|||||||
Album::infoSystemInfo( const Tomahawk::InfoSystem::InfoRequestData& requestData, const QVariant& output )
|
Album::infoSystemInfo( const Tomahawk::InfoSystem::InfoRequestData& requestData, const QVariant& output )
|
||||||
{
|
{
|
||||||
Q_D( Album );
|
Q_D( Album );
|
||||||
if ( requestData.caller != infoid() ||
|
if ( requestData.caller != infoid() )
|
||||||
requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
|
return;
|
||||||
|
|
||||||
|
if ( requestData.type == Tomahawk::InfoSystem::InfoAlbumPurchaseUrl && output.isValid() )
|
||||||
|
{
|
||||||
|
QVariantMap returnedData = output.value< QVariantMap >();
|
||||||
|
d->purchaseUrlLoaded = true;
|
||||||
|
d->purchaseUrl = returnedData["url"].toString();
|
||||||
|
emit updated();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -61,6 +61,7 @@ public:
|
|||||||
artist_ptr artist() const;
|
artist_ptr artist() const;
|
||||||
QPixmap cover( const QSize& size, bool forceLoad = true ) const;
|
QPixmap cover( const QSize& size, bool forceLoad = true ) const;
|
||||||
bool coverLoaded() const;
|
bool coverLoaded() const;
|
||||||
|
QString purchaseUrl() const;
|
||||||
|
|
||||||
QList<Tomahawk::query_ptr> tracks( ModelMode mode = Mixed, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
|
QList<Tomahawk::query_ptr> tracks( ModelMode mode = Mixed, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
|
||||||
Tomahawk::playlistinterface_ptr playlistInterface( ModelMode mode, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
|
Tomahawk::playlistinterface_ptr playlistInterface( ModelMode mode, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
|
||||||
|
@@ -67,6 +67,9 @@ private:
|
|||||||
|
|
||||||
artist_ptr artist;
|
artist_ptr artist;
|
||||||
|
|
||||||
|
mutable bool purchaseUrlLoaded;
|
||||||
|
mutable QString purchaseUrl;
|
||||||
|
|
||||||
mutable bool coverLoaded;
|
mutable bool coverLoaded;
|
||||||
mutable bool coverLoading;
|
mutable bool coverLoading;
|
||||||
mutable QString uuid;
|
mutable QString uuid;
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
#include "TrackDetailView.h"
|
#include "TrackDetailView.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QSizePolicy>
|
#include <QSizePolicy>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@@ -118,11 +120,21 @@ TrackDetailView::TrackDetailView( QWidget* parent )
|
|||||||
TomahawkStyle::styleScrollBar( m_resultsScrollArea->verticalScrollBar() );
|
TomahawkStyle::styleScrollBar( m_resultsScrollArea->verticalScrollBar() );
|
||||||
m_resultsScrollArea->hide();
|
m_resultsScrollArea->hide();
|
||||||
|
|
||||||
|
m_buyButton = new QPushButton;
|
||||||
|
m_buyButton->setStyleSheet( "QPushButton:hover { font-size: 12px; color: #2b2b2b; background: #f8f8f8; border-style: outset; border-width: 2px; border-color: #2b2b2b; }"
|
||||||
|
"QPushButton { font-size: 12px; color: #ffffff; background-color: #ed0677; border-width: 0px; }" );
|
||||||
|
m_buyButton->setMinimumHeight( 30 );
|
||||||
|
m_buyButton->setText( tr( "BUY ALBUM" ) );
|
||||||
|
m_buyButton->setVisible( false );
|
||||||
|
connect( m_buyButton, SIGNAL( clicked() ), SLOT( onBuyButtonClicked() ) );
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout;
|
QVBoxLayout* layout = new QVBoxLayout;
|
||||||
TomahawkUtils::unmarginLayout( layout );
|
TomahawkUtils::unmarginLayout( layout );
|
||||||
layout->addWidget( m_playableCover );
|
layout->addWidget( m_playableCover );
|
||||||
layout->addSpacerItem( new QSpacerItem( 0, 8, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
|
layout->addSpacerItem( new QSpacerItem( 0, 8, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
|
||||||
layout->addWidget( m_nameLabel );
|
layout->addWidget( m_nameLabel );
|
||||||
|
layout->addSpacerItem( new QSpacerItem( 0, 4, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
|
||||||
|
layout->addWidget( m_buyButton );
|
||||||
layout->addWidget( m_dateLabel );
|
layout->addWidget( m_dateLabel );
|
||||||
layout->addWidget( m_infoBox );
|
layout->addWidget( m_infoBox );
|
||||||
layout->addSpacerItem( new QSpacerItem( 0, 32, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
|
layout->addSpacerItem( new QSpacerItem( 0, 32, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
|
||||||
@@ -154,6 +166,10 @@ TrackDetailView::setQuery( const Tomahawk::query_ptr& query )
|
|||||||
{
|
{
|
||||||
if ( m_query )
|
if ( m_query )
|
||||||
{
|
{
|
||||||
|
if ( m_query->track()->albumPtr() && !m_query->track()->albumPtr()->name().isEmpty() )
|
||||||
|
{
|
||||||
|
disconnect( m_query->track()->albumPtr().data(), SIGNAL( updated() ), this, SLOT( onAlbumUpdated() ) );
|
||||||
|
}
|
||||||
disconnect( m_query->track().data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
|
disconnect( m_query->track().data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
|
||||||
disconnect( m_query->track().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( onSocialActionsLoaded() ) );
|
disconnect( m_query->track().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( onSocialActionsLoaded() ) );
|
||||||
disconnect( m_query.data(), SIGNAL( resultsChanged() ), this, SLOT( onResultsChanged() ) );
|
disconnect( m_query.data(), SIGNAL( resultsChanged() ), this, SLOT( onResultsChanged() ) );
|
||||||
@@ -176,6 +192,9 @@ TrackDetailView::setQuery( const Tomahawk::query_ptr& query )
|
|||||||
|
|
||||||
if ( m_query->track()->albumPtr() && !m_query->track()->albumPtr()->name().isEmpty() )
|
if ( m_query->track()->albumPtr() && !m_query->track()->albumPtr()->name().isEmpty() )
|
||||||
{
|
{
|
||||||
|
connect( m_query->track()->albumPtr().data(), SIGNAL( updated() ), SLOT( onAlbumUpdated() ) );
|
||||||
|
onAlbumUpdated();
|
||||||
|
|
||||||
m_nameLabel->setType( QueryLabel::Album );
|
m_nameLabel->setType( QueryLabel::Album );
|
||||||
m_nameLabel->setAlbum( m_query->track()->albumPtr() );
|
m_nameLabel->setAlbum( m_query->track()->albumPtr() );
|
||||||
}
|
}
|
||||||
@@ -191,6 +210,28 @@ TrackDetailView::setQuery( const Tomahawk::query_ptr& query )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TrackDetailView::onAlbumUpdated()
|
||||||
|
{
|
||||||
|
if ( m_query && m_query->track()->albumPtr() )
|
||||||
|
{
|
||||||
|
m_buyButton->setVisible( !m_query->track()->albumPtr()->purchaseUrl().isEmpty() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_buyButton->setVisible( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TrackDetailView::onBuyButtonClicked()
|
||||||
|
{
|
||||||
|
if ( m_query && m_query->track()->albumPtr() )
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl( QUrl( m_query->track()->albumPtr()->purchaseUrl() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackDetailView::onCoverUpdated()
|
TrackDetailView::onCoverUpdated()
|
||||||
{
|
{
|
||||||
|
@@ -30,6 +30,7 @@ class CaptionLabel;
|
|||||||
class PlayableCover;
|
class PlayableCover;
|
||||||
class QueryLabel;
|
class QueryLabel;
|
||||||
class QScrollArea;
|
class QScrollArea;
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
class DLLEXPORT TrackDetailView : public QWidget, private TomahawkUtils::DpiScaler
|
class DLLEXPORT TrackDetailView : public QWidget, private TomahawkUtils::DpiScaler
|
||||||
{
|
{
|
||||||
@@ -50,9 +51,11 @@ protected:
|
|||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void onAlbumUpdated();
|
||||||
void onCoverUpdated();
|
void onCoverUpdated();
|
||||||
void onSocialActionsLoaded();
|
void onSocialActionsLoaded();
|
||||||
void onResultsChanged();
|
void onResultsChanged();
|
||||||
|
void onBuyButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setSocialActions();
|
void setSocialActions();
|
||||||
@@ -65,6 +68,7 @@ private:
|
|||||||
QLabel* m_lovedIcon;
|
QLabel* m_lovedIcon;
|
||||||
QLabel* m_lovedLabel;
|
QLabel* m_lovedLabel;
|
||||||
CaptionLabel* m_resultsBoxLabel;
|
CaptionLabel* m_resultsBoxLabel;
|
||||||
|
QPushButton* m_buyButton;
|
||||||
|
|
||||||
QWidget* m_infoBox;
|
QWidget* m_infoBox;
|
||||||
QWidget* m_resultsBox;
|
QWidget* m_resultsBox;
|
||||||
|
@@ -156,7 +156,6 @@ ScriptAccount::reportScriptJobResult( const QVariantMap& result )
|
|||||||
if ( result[ "error"].isNull() )
|
if ( result[ "error"].isNull() )
|
||||||
{
|
{
|
||||||
const QVariantMap data = result[ "data" ].toMap();
|
const QVariantMap data = result[ "data" ].toMap();
|
||||||
|
|
||||||
job->reportResults( data );
|
job->reportResults( data );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -169,7 +169,7 @@ ScriptInfoPlugin::onNotInCacheRequestDone( const QVariantMap& result )
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
emit info( requestData, result[ "data" ].toMap() );
|
emit info( requestData, resultData );
|
||||||
emit updateCache( criteria, result[ "maxAge" ].toLongLong(), requestData.type, resultData );
|
emit updateCache( criteria, result[ "maxAge" ].toLongLong(), requestData.type, resultData );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -122,7 +122,7 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti
|
|||||||
|
|
||||||
if ( collection->backendType() == Collection::ScriptCollectionType )
|
if ( collection->backendType() == Collection::ScriptCollectionType )
|
||||||
{
|
{
|
||||||
QAbstractButton* downloadButton = m_header->addButton( tr( "Download All" ) );
|
QAbstractButton* downloadButton = m_header->addButton( tr( "DOWNLOAD ALL" ) );
|
||||||
connect( downloadButton, SIGNAL( clicked() ), SLOT( onDownloadAll() ) );
|
connect( downloadButton, SIGNAL( clicked() ), SLOT( onDownloadAll() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -124,6 +124,12 @@ QAbstractButton*
|
|||||||
BasicHeader::addButton( const QString& text )
|
BasicHeader::addButton( const QString& text )
|
||||||
{
|
{
|
||||||
QPushButton* button = new QPushButton( this );
|
QPushButton* button = new QPushButton( this );
|
||||||
|
|
||||||
|
button->setStyleSheet( "QPushButton:hover { font-size: 12px; color: #2b2b2b; background: #f8f8f8; border-style: outset; border-width: 2px; border-color: #2b2b2b; }"
|
||||||
|
"QPushButton { font-size: 12px; color: #ffffff; background-color: #ed0677; border-width: 0px; }" );
|
||||||
|
button->setMinimumHeight( 30 );
|
||||||
|
button->setMinimumWidth( 132 );
|
||||||
|
|
||||||
button->setText( text );
|
button->setText( text );
|
||||||
ui->horizontalLayout->addWidget( button );
|
ui->horizontalLayout->addWidget( button );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user