mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
added artwork to the stations view
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import QtQuick 1.1
|
import QtQuick 1.1
|
||||||
|
import tomahawk 1.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: scene
|
id: scene
|
||||||
@@ -25,7 +26,6 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: parent.border.width
|
anchors.margins: parent.border.width
|
||||||
source: "image://albumart/" + parent.artworkId
|
source: "image://albumart/" + parent.artworkId
|
||||||
onSourceChanged: print("!*!*!*!*!*!*!*!*!", source)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -67,7 +67,7 @@ Rectangle {
|
|||||||
id: mirroredDelegate
|
id: mirroredDelegate
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: mirrorItem
|
id: mirroredItem
|
||||||
height: scene.coverSize
|
height: scene.coverSize
|
||||||
width: scene.coverSize
|
width: scene.coverSize
|
||||||
|
|
||||||
@@ -77,6 +77,18 @@ Rectangle {
|
|||||||
property double itemOpacity: PathView.itemOpacity
|
property double itemOpacity: PathView.itemOpacity
|
||||||
property double shadowOp: PathView.shadowOpacity
|
property double shadowOp: PathView.shadowOpacity
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: dynamicModel.itemFromIndex( index )
|
||||||
|
onCoverChanged: {
|
||||||
|
// We need to unset and re-set it because QML wouldn't re-query the image if it still has the same url
|
||||||
|
normalCover.item.artworkId = ""
|
||||||
|
mirroredCover.item.artworkId = ""
|
||||||
|
normalCover.item.artworkId = index
|
||||||
|
mirroredCover.item.artworkId = index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Component.onCompleted: print("created delegate for", dynamicModel.itemFromIndex( index ) )
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: normalCover
|
id: normalCover
|
||||||
sourceComponent: coverImage
|
sourceComponent: coverImage
|
||||||
@@ -107,7 +119,7 @@ Rectangle {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
color: scene.color
|
color: scene.color
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
opacity: mirrorItem.shadowOp
|
opacity: mirroredItem.shadowOp
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: scene.color
|
color: scene.color
|
||||||
@@ -118,7 +130,7 @@ Rectangle {
|
|||||||
gradient: Gradient {
|
gradient: Gradient {
|
||||||
// TODO: no clue how to get the RGB component of the container rectangle color
|
// TODO: no clue how to get the RGB component of the container rectangle color
|
||||||
// For now the Qt.rgba needs to be manually updated to match scene.color
|
// For now the Qt.rgba needs to be manually updated to match scene.color
|
||||||
GradientStop { position: 0.0; color: Qt.rgba(0, 0, 0, mirrorItem.shadowOp + ( (1 - mirrorItem.shadowOp) * .4)) }
|
GradientStop { position: 0.0; color: Qt.rgba(0, 0, 0, mirroredItem.shadowOp + ( (1 - mirroredItem.shadowOp) * .4)) }
|
||||||
GradientStop { position: 0.5; color: scene.color }
|
GradientStop { position: 0.5; color: scene.color }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,9 +152,6 @@ Rectangle {
|
|||||||
|
|
||||||
delegate: mirroredDelegate
|
delegate: mirroredDelegate
|
||||||
|
|
||||||
|
|
||||||
onCurrentIndexChanged: print("***************************************** current index:", currentIndex)
|
|
||||||
|
|
||||||
path: Path {
|
path: Path {
|
||||||
startX: scene.width / 2 + 20
|
startX: scene.width / 2 + 20
|
||||||
startY: 155
|
startY: 155
|
||||||
|
@@ -56,6 +56,7 @@ PlayableItem::PlayableItem( const Tomahawk::album_ptr& album, PlayableItem* pare
|
|||||||
init( parent, row );
|
init( parent, row );
|
||||||
|
|
||||||
connect( album.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
|
connect( album.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
|
||||||
|
connect( album.data(), SIGNAL( coverChanged() ), SIGNAL( coverChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ PlayableItem::PlayableItem( const Tomahawk::artist_ptr& artist, PlayableItem* pa
|
|||||||
init( parent, row );
|
init( parent, row );
|
||||||
|
|
||||||
connect( artist.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
|
connect( artist.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
|
||||||
|
connect( artist.data(), SIGNAL( coverChanged() ), SIGNAL( coverChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -97,6 +99,9 @@ PlayableItem::PlayableItem( const Tomahawk::query_ptr& query, PlayableItem* pare
|
|||||||
|
|
||||||
connect( query.data(), SIGNAL( resultsChanged() ),
|
connect( query.data(), SIGNAL( resultsChanged() ),
|
||||||
SLOT( onResultsChanged() ) );
|
SLOT( onResultsChanged() ) );
|
||||||
|
|
||||||
|
connect( query.data(), SIGNAL( coverChanged() ),
|
||||||
|
SIGNAL( coverChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,6 +126,9 @@ PlayableItem::PlayableItem( const Tomahawk::plentry_ptr& entry, PlayableItem* pa
|
|||||||
|
|
||||||
connect( m_query.data(), SIGNAL( resultsChanged() ),
|
connect( m_query.data(), SIGNAL( resultsChanged() ),
|
||||||
SLOT( onResultsChanged() ) );
|
SLOT( onResultsChanged() ) );
|
||||||
|
|
||||||
|
connect( m_query.data(), SIGNAL( coverChanged() ),
|
||||||
|
SIGNAL( coverChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -164,6 +172,11 @@ PlayableItem::onResultsChanged()
|
|||||||
emit dataChanged();
|
emit dataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayableItem::slotCoverChanged()
|
||||||
|
{
|
||||||
|
qDebug() << "emitted coverChanged";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
PlayableItem::name() const
|
PlayableItem::name() const
|
||||||
|
@@ -65,9 +65,11 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataChanged();
|
void dataChanged();
|
||||||
|
void coverChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onResultsChanged();
|
void onResultsChanged();
|
||||||
|
void slotCoverChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init( PlayableItem* parent, int row = -1 );
|
void init( PlayableItem* parent, int row = -1 );
|
||||||
|
@@ -732,6 +732,18 @@ PlayableModel::itemFromIndex( const QModelIndex& index ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayableItem *PlayableModel::itemFromIndex(int itemIndex) const
|
||||||
|
{
|
||||||
|
QModelIndex modelIndex = index( itemIndex, 0, QModelIndex() );
|
||||||
|
if ( modelIndex.isValid() )
|
||||||
|
{
|
||||||
|
return static_cast<PlayableItem*>( modelIndex.internalPointer() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return m_rootItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlayableModel::appendArtist( const Tomahawk::artist_ptr& artist )
|
PlayableModel::appendArtist( const Tomahawk::artist_ptr& artist )
|
||||||
|
@@ -118,6 +118,8 @@ public:
|
|||||||
virtual void ensureResolved();
|
virtual void ensureResolved();
|
||||||
|
|
||||||
PlayableItem* itemFromIndex( const QModelIndex& index ) const;
|
PlayableItem* itemFromIndex( const QModelIndex& index ) const;
|
||||||
|
Q_INVOKABLE PlayableItem* itemFromIndex( int itemIndex ) const;
|
||||||
|
|
||||||
/// Returns a flat list of all tracks in this model
|
/// Returns a flat list of all tracks in this model
|
||||||
QList< Tomahawk::query_ptr > queries() const;
|
QList< Tomahawk::query_ptr > queries() const;
|
||||||
|
|
||||||
|
@@ -36,6 +36,9 @@ DynamicQmlWidget::DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* pa
|
|||||||
rootContext()->setContextProperty( "dynamicModel", m_model );
|
rootContext()->setContextProperty( "dynamicModel", m_model );
|
||||||
currentItemChanged( m_model->currentItem() );
|
currentItemChanged( m_model->currentItem() );
|
||||||
|
|
||||||
|
// TODO: In case QML is used in more places, this should probably be moved to some generic place
|
||||||
|
qmlRegisterType<PlayableItem>("tomahawk", 1, 0, "PlayableItem");
|
||||||
|
|
||||||
setSource( QUrl( "qrc" RESPATH "qml/StationScene.qml" ) );
|
setSource( QUrl( "qrc" RESPATH "qml/StationScene.qml" ) );
|
||||||
|
|
||||||
connect( m_model, SIGNAL( currentItemChanged( QPersistentModelIndex ) ), SLOT( currentItemChanged( QPersistentModelIndex ) ) );
|
connect( m_model, SIGNAL( currentItemChanged( QPersistentModelIndex ) ), SLOT( currentItemChanged( QPersistentModelIndex ) ) );
|
||||||
@@ -83,8 +86,6 @@ DynamicQmlWidget::jumpToCurrentTrack()
|
|||||||
|
|
||||||
QPixmap DynamicQmlWidget::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
|
QPixmap DynamicQmlWidget::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
|
||||||
{
|
{
|
||||||
qDebug() << "*!*!*!*!*!*!*!*!*!* image requested:" << id;
|
|
||||||
|
|
||||||
// We always can generate it in the requested size
|
// We always can generate it in the requested size
|
||||||
int width = requestedSize.width() > 0 ? requestedSize.width() : 230;
|
int width = requestedSize.width() > 0 ? requestedSize.width() : 230;
|
||||||
int height = requestedSize.height() > 0 ? requestedSize.height() : 230;
|
int height = requestedSize.height() > 0 ? requestedSize.height() : 230;
|
||||||
@@ -96,13 +97,11 @@ QPixmap DynamicQmlWidget::requestPixmap(const QString &id, QSize *size, const QS
|
|||||||
qDebug() << "got index" << index;
|
qDebug() << "got index" << index;
|
||||||
if( index.isValid() ) {
|
if( index.isValid() ) {
|
||||||
PlayableItem *item = m_model->itemFromIndex( index );
|
PlayableItem *item = m_model->itemFromIndex( index );
|
||||||
qDebug() << "got item" << item << item->query();
|
if ( !item->album().isNull() ) {
|
||||||
qDebug() << "got item" << item << item->query()->coverLoaded();
|
|
||||||
if ( !item->album().isNull() && item->album()->coverLoaded() ) {
|
|
||||||
return item->album()->cover( *size );
|
return item->album()->cover( *size );
|
||||||
} else if ( !item->artist().isNull() && item->artist()->coverLoaded() ) {
|
} else if ( !item->artist().isNull() ) {
|
||||||
return item->artist()->cover( *size );
|
return item->artist()->cover( *size );
|
||||||
} else if ( !item->query().isNull() && item->query()->coverLoaded() ) {
|
} else if ( !item->query().isNull() ) {
|
||||||
return item->query()->cover( *size );
|
return item->query()->cover( *size );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user