mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
add missing files
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#include "EchonestStation.h"
|
||||
|
||||
#include "PlayableItem.h"
|
||||
#include "audio/AudioEngine.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
EchonestStation::EchonestStation( PlayableProxyModel *model, geninterface_ptr generator, QObject *parent )
|
||||
: QObject(parent)
|
||||
, m_model(model)
|
||||
, m_generator(generator)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Tomahawk::DynamicControl* EchonestStation::mainControl() {
|
||||
foreach(dyncontrol_ptr control, m_generator->controls()) {
|
||||
qDebug() << "got control" << control->selectedType();
|
||||
if(control->selectedType() == "Artist" || control->selectedType() == "Style") {
|
||||
return control.data();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool EchonestStation::configured()
|
||||
{
|
||||
return mainControl() != 0;
|
||||
}
|
||||
|
||||
void EchonestStation::playItem(int row)
|
||||
{
|
||||
QModelIndex index( m_model->index( row, 0) );
|
||||
PlayableItem* item = m_model->itemFromIndex( index );
|
||||
if ( item && !item->query().isNull() )
|
||||
{
|
||||
m_model->setCurrentIndex( index );
|
||||
AudioEngine::instance()->playItem( m_model->playlistInterface(), item->query() );
|
||||
}
|
||||
}
|
||||
|
||||
void EchonestStation::setMainControl(const QString &type)
|
||||
{
|
||||
dyncontrol_ptr control = m_generator->createControl("echonest");
|
||||
control->setSelectedType("Style");
|
||||
control->setMatch("1");
|
||||
control->setInput(type);
|
||||
qDebug() << "created control" << control->type() << control->selectedType() << control->match();
|
||||
m_generator->generate(20);
|
||||
|
||||
emit configuredChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
35
src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h
Normal file
35
src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef ECHONESTSTATION_H
|
||||
#define ECHONESTSTATION_H
|
||||
|
||||
#include "PlayableProxyModel.h"
|
||||
#include "dynamic/GeneratorInterface.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
class EchonestStation: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool configured READ configured NOTIFY configuredChanged)
|
||||
Q_PROPERTY(Tomahawk::DynamicControl* mainControl READ mainControl)
|
||||
|
||||
public:
|
||||
EchonestStation( PlayableProxyModel *model, geninterface_ptr generator, QObject *parent = 0);
|
||||
|
||||
Tomahawk::DynamicControl* mainControl();
|
||||
bool configured();
|
||||
|
||||
public slots:
|
||||
void playItem( int row );
|
||||
|
||||
void setMainControl(const QString &type);
|
||||
|
||||
signals:
|
||||
void configuredChanged();
|
||||
|
||||
private:
|
||||
PlayableProxyModel *m_model;
|
||||
geninterface_ptr m_generator;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
49
src/libtomahawk/widgets/DeclarativeCoverArtProvider.cpp
Normal file
49
src/libtomahawk/widgets/DeclarativeCoverArtProvider.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "DeclarativeCoverArtProvider.h"
|
||||
#include "PlayableItem.h"
|
||||
#include "playlist/PlayableProxyModel.h"
|
||||
#include "Query.h"
|
||||
|
||||
#include <QDeclarativeImageProvider>
|
||||
#include <QModelIndex>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
DeclarativeCoverArtProvider::DeclarativeCoverArtProvider( PlayableProxyModel *model )
|
||||
: QDeclarativeImageProvider( QDeclarativeImageProvider::Pixmap )
|
||||
, m_model( model )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeclarativeCoverArtProvider::~DeclarativeCoverArtProvider()
|
||||
{
|
||||
}
|
||||
|
||||
QPixmap DeclarativeCoverArtProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
|
||||
{
|
||||
// We always can generate it in the requested size
|
||||
int width = requestedSize.width() > 0 ? requestedSize.width() : 230;
|
||||
int height = requestedSize.height() > 0 ? requestedSize.height() : 230;
|
||||
|
||||
if( size )
|
||||
*size = QSize( width, height );
|
||||
|
||||
PlayableItem *item = m_model->itemFromIndex( id.toInt() );
|
||||
if( item ) {
|
||||
qDebug() << "item:" << item;
|
||||
qDebug() << "item2:" << item->artistName() << item->name();
|
||||
if ( !item->query().isNull() ) {
|
||||
return item->query()->displayQuery()->cover( *size );
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: create default cover art image
|
||||
QPixmap pixmap( *size );
|
||||
pixmap.fill();
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
}
|
26
src/libtomahawk/widgets/DeclarativeCoverArtProvider.h
Normal file
26
src/libtomahawk/widgets/DeclarativeCoverArtProvider.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef DECLARATIVECOVERARTPROVIDER_H
|
||||
#define DECLARATIVECOVERARTPROVIDER_H
|
||||
|
||||
|
||||
#include "playlist/PlayableProxyModel.h"
|
||||
|
||||
#include <QDeclarativeImageProvider>
|
||||
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DeclarativeCoverArtProvider: public QDeclarativeImageProvider
|
||||
{
|
||||
public:
|
||||
DeclarativeCoverArtProvider( PlayableProxyModel *model );
|
||||
~DeclarativeCoverArtProvider();
|
||||
|
||||
QPixmap requestPixmap( const QString &id, QSize *size, const QSize &requestedSize );
|
||||
|
||||
private:
|
||||
PlayableProxyModel *m_model;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // DECLARATIVECOVERARTPROVIDER_H
|
Reference in New Issue
Block a user