From 467cb26006611d4a07fb21edaea19d832565539e Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 3 Aug 2012 21:53:56 +0200 Subject: [PATCH] add artist mode for stations --- data/qml/CoverImage.qml | 4 ++- data/qml/StationScene.qml | 32 +++++++++++++------ data/qml/StationView.qml | 1 + .../dynamic/echonest/EchonestStation.cpp | 23 +++++++++---- .../dynamic/echonest/EchonestStation.h | 11 ++++++- 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/data/qml/CoverImage.qml b/data/qml/CoverImage.qml index 45c044812..ecc764ab3 100644 --- a/data/qml/CoverImage.qml +++ b/data/qml/CoverImage.qml @@ -7,6 +7,8 @@ Item { property bool showLabels: true // Should the play button be painted on mouse hover? property bool showPlayButton: false + // Should the mirror be painted? + property bool showMirror: false // Labels & Cover property string artistName @@ -95,7 +97,7 @@ Item { Loader { id: mirroredCover - sourceComponent: coverImage + sourceComponent: parent.showMirror ? coverImage : undefined anchors.fill: parent transform : [ Rotation { diff --git a/data/qml/StationScene.qml b/data/qml/StationScene.qml index d82997ee0..046c7d557 100644 --- a/data/qml/StationScene.qml +++ b/data/qml/StationScene.qml @@ -57,19 +57,31 @@ Rectangle { width: scene.width spacing: width * .1 - GridView { - id: gridView + Item { height: parent.height width: (parent.width - orText.width - parent.spacing * 2 ) * 2 / 3 - model: dummyArtistModel + GridView { + id: gridView + anchors.fill: parent + anchors.margins: cellWidth / 2 + model: dummyArtistModel - delegate: Item { - height: gridView.height / 3; - width: height + cellWidth: gridView.width / 4 - 1 // -1 to make sure there is space for 4 items even with rounding error + cellHeight: cellWidth - CoverImage { - artistName: modelData - anchors.fill: parent + delegate: Item { + height: gridView.cellHeight * .9 + width: height + + CoverImage { + artistName: modelData + anchors.fill: parent + + onClicked: { + echonestStation.setMainControl( EchonestStation.StationTypeArtist, modelData ); + stationListView.incrementCurrentIndex(); + } + } } } } @@ -89,7 +101,7 @@ Rectangle { opacity: echonestStation.configured ? 0 : 1 onTagClicked: { - echonestStation.setMainControl( item ); + echonestStation.setMainControl( EchonestStation.StationTypeStyle, item ); stationListView.incrementCurrentIndex(); } diff --git a/data/qml/StationView.qml b/data/qml/StationView.qml index ee413fc0d..e4c8318ac 100644 --- a/data/qml/StationView.qml +++ b/data/qml/StationView.qml @@ -29,6 +29,7 @@ Item { width: root.coverSize showLabels: false + showMirror: true //artistName: model.artistName //trackName: model.trackName artworkId: model.coverID diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp index 627727b57..9188cc83b 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp @@ -15,7 +15,7 @@ EchonestStation::EchonestStation( PlayableProxyModel *model, dynplaylist_ptr pla , m_model( model ) , m_playlist( playlist ) { - + connect(m_playlist->generator().data(), SIGNAL(controlAdded(const dyncontrol_ptr&)), SLOT(controlsChanged())); } QString EchonestStation::name() const @@ -69,14 +69,18 @@ void EchonestStation::playItem(int row) } } -void EchonestStation::setMainControl(const QString &type) +void EchonestStation::setMainControl( StationType type, const QString &value ) { - dyncontrol_ptr control = m_playlist->generator()->createControl("echonest"); - control->setSelectedType("Style"); - control->setMatch("1"); - control->setInput(type); + dyncontrol_ptr control = m_playlist->generator()->createControl( "echonest" ); + if ( type == StationTypeStyle ) { + control->setSelectedType( "Style" ); + } else if ( type == StationTypeArtist ) { + control->setSelectedType( "Artist" ); + } + control->setMatch( "1" ); + control->setInput( value ); qDebug() << "created control" << control->type() << control->selectedType() << control->match(); - m_playlist->generator()->generate(20); + m_playlist->generator()->generate( 20 ); emit configurationChanged(); } @@ -116,5 +120,10 @@ dyncontrol_ptr EchonestStation::findControl(const QString &selectedType, const Q return dyncontrol_ptr(); } +void EchonestStation::controlsChanged() +{ + Q_ASSERT(false); +} + } diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h index a5ab900df..70033962e 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h @@ -9,6 +9,7 @@ namespace Tomahawk class EchonestStation: public QObject { Q_OBJECT + Q_ENUMS(StationType) Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged ) Q_PROPERTY( bool configured READ configured NOTIFY configurationChanged ) Q_PROPERTY( Tomahawk::DynamicControl* mainControl READ mainControl ) @@ -16,6 +17,11 @@ class EchonestStation: public QObject Q_PROPERTY( int maxTempo READ maxTempo NOTIFY configurationChanged ) public: + enum StationType { + StationTypeStyle, + StationTypeArtist + }; + EchonestStation( PlayableProxyModel *model, dynplaylist_ptr playlist, QObject *parent = 0); QString name() const; @@ -30,7 +36,7 @@ public: public slots: void playItem( int row ); - void setMainControl(const QString &type); + void setMainControl(StationType type, const QString &value); void setTempo( int min, int max ); signals: @@ -40,6 +46,9 @@ signals: private: dyncontrol_ptr findControl( const QString &selectedType, const QString &match ) const; +private slots: + void controlsChanged(); + private: QString m_name; PlayableProxyModel *m_model;