1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-02 18:33:16 +02:00

more qml work

This commit is contained in:
Michael Zanetti
2012-11-25 02:03:02 +01:00
parent d099bc0392
commit e7ffb77cad
9 changed files with 113 additions and 90 deletions

View File

@@ -7,26 +7,29 @@ PathView {
// The start coordinates for the covers
// Default is left, centered in height
property int pathStartX: coverSize
property int pathStartX: 0
property int pathStartY: height / 2
// The size of the covers in the path
property int coverSize: 100
property color backgroundColor: "black"
// emitted when a cover is clicked
signal itemClicked(int index)
// emitted when a cover is clicked
signal itemPlayPauseClicked(int index)
preferredHighlightBegin: 0.2 // scene.width / 11000
preferredHighlightEnd: preferredHighlightBegin
// preferredHighlightBegin: 0.2 // scene.width / 11000
// preferredHighlightEnd: preferredHighlightBegin
pathItemCount: 5
//highlightMoveDuration: 500
delegate: CoverImage {
height: root.coverSize
width: root.coverSize
backgroundColor: coverView.backgroundColor
showLabels: true
showMirror: true
@@ -34,7 +37,7 @@ PathView {
trackName: model.trackName
artworkId: model.coverID
showPlayButton: true
currentyPlayed: mode.itemFromIndex(index).isPlaying
currentlyPlaying: isPlaying
scale: PathView.itemScale
itemBrightness: PathView.itemBrightness
@@ -42,6 +45,7 @@ PathView {
z: -x
onPlayClicked: {
console.log("***************")
coverView.itemPlayPauseClicked(index)
}
@@ -72,7 +76,7 @@ PathView {
// // PathAttribute { name: "itemOpacity"; value: 1 }
// // PathAttribute { name: "itemBrightness"; value: .5 }
// // PathAttribute { name: "itemScale"; value: 0.4 }
PathLine { x: root.width; y: 0 }
PathLine { x: coverView.width; y: 0 }
PathPercent { value: 1 }
PathAttribute { name: "itemOpacity"; value: 1 }
PathAttribute { name: "itemBrightness"; value: 0 }

View File

@@ -10,7 +10,7 @@ Item {
property bool showPlayButton: false
// if this is true, the play button will be swapped by a pause button
property bool currentyPlayed: false
property bool currentlyPlaying: false
// Should the mirror be painted?
property bool showMirror: false
@@ -20,8 +20,6 @@ Item {
property string trackName
property string artworkId
onArtworkIdChanged: print("!*!*!*!*!* artworkId", artworkId)
// The border color for the cover image
property color borderColor: "black"
// The border width for the cover image
@@ -44,7 +42,10 @@ Item {
anchors.fill: parent
hoverEnabled: true
onClicked: root.clicked();
onClicked: {
print("Cover clicked");
root.clicked();
}
}
@@ -144,7 +145,7 @@ Item {
gradient: Gradient {
// 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 the backgroundColor
// For now the Qt.rgba needs to be manually updated to match the backgroundColor 454e59
GradientStop { position: 0.0; color: Qt.rgba(0, 0, 0, 1-mirrorBrightness) }
GradientStop { position: 0.5; color: backgroundColor }
}
@@ -152,12 +153,15 @@ Item {
Image {
id: playButton
visible: showPlayButton ? mouseArea.containsMouse : false
source: currentyPlayed ? "../images/pause-rest.png" : "../images/play-rest.png"
visible: showPlayButton ? (mouseArea.containsMouse || currentlyPlaying) : false
source: currentlyPlaying ? "../images/pause-rest.png" : "../images/play-rest.png"
anchors.centerIn: parent
MouseArea {
anchors.fill: parent
onClicked: root.playClicked();
onClicked: {
print("Play button clicked");
root.playClicked();
}
}
}

View File

@@ -48,79 +48,79 @@ Rectangle {
id: stationVisualModel
// Column {
// height: scene.height
// width: scene.width
Column {
height: scene.height
width: scene.width
// Row {
// height: scene.height / 2
// width: scene.width
// spacing: width * .1
Row {
height: scene.height / 2
width: scene.width
spacing: width * .1
// Item {
// height: parent.height
// width: (parent.width - orText.width - parent.spacing * 2 ) * 2 / 3
// GridView {
// id: gridView
// anchors.fill: parent
// anchors.margins: cellWidth / 2
// model: dummyArtistModel
Item {
height: parent.height
width: (parent.width - orText.width - parent.spacing * 2 ) * 2 / 3
GridView {
id: gridView
anchors.fill: parent
anchors.margins: cellWidth / 2
model: dummyArtistModel
// cellWidth: gridView.width / 4 - 1 // -1 to make sure there is space for 4 items even with rounding error
// cellHeight: cellWidth
cellWidth: gridView.width / 4 - 1 // -1 to make sure there is space for 4 items even with rounding error
cellHeight: cellWidth
// delegate: Item {
// height: gridView.cellHeight * .9
// width: height
delegate: Item {
height: gridView.cellHeight * .9
width: height
// CoverImage {
// artistName: modelData
// anchors.fill: parent
CoverImage {
artistName: modelData
anchors.fill: parent
// onClicked: {
// echonestStation.setMainControl( EchonestStation.StationTypeArtist, modelData );
// stationListView.incrementCurrentIndex();
// }
// }
// }
// }
// }
onClicked: {
rootView.startStationFromArtist(modelData);
stationListView.incrementCurrentIndex();
}
}
}
}
}
// }
}
// Row {
// height: scene.height / 2
// width: scene.width * .9
// anchors.horizontalCenter: parent.horizontalCenter
// spacing: width * .1
Row {
height: scene.height / 2
width: scene.width * .9
anchors.horizontalCenter: parent.horizontalCenter
spacing: width * .1
// TagCloud {
// height: parent.height
// width: (parent.width - orText.width - parent.spacing * 2 ) * 2 / 3
// model: styleModel//generator.styles()
// opacity: echonestStation.configured ? 0 : 1
TagCloud {
height: parent.height
width: (parent.width - orText.width - parent.spacing * 2 ) * 2 / 3
model: styleModel//generator.styles()
opacity: echonestStation.configured ? 0 : 1
// onTagClicked: {
// echonestStation.setMainControl( EchonestStation.StationTypeStyle, item );
// stationListView.incrementCurrentIndex();
// }
onTagClicked: {
echonestStation.setMainControl( EchonestStation.StationTypeStyle, item );
stationListView.incrementCurrentIndex();
}
// Behavior on opacity {
// NumberAnimation { duration: 300 }
// }
// }
// Text {
// id: orText
// text: "or"
// color: "white"
// anchors.verticalCenter: parent.verticalCenter
// }
// InputField {
// anchors.verticalCenter: parent.verticalCenter
// width: (parent.width - orText.width - parent.spacing * 2 ) * 1 / 3
// }
// }
// }
Behavior on opacity {
NumberAnimation { duration: 300 }
}
}
Text {
id: orText
text: "or"
color: "white"
anchors.verticalCenter: parent.verticalCenter
}
InputField {
anchors.verticalCenter: parent.verticalCenter
width: (parent.width - orText.width - parent.spacing * 2 ) * 1 / 3
}
}
}
StationView {
coverSize: Math.min(scene.height, scene.width) / 2
@@ -147,12 +147,7 @@ Rectangle {
orientation: ListView.Horizontal
model: stationVisualModel
interactive: false
//highlightMoveDuration: 400
highlightMoveDuration: 200
// currentIndex: 1
// Component.onCompleted: {
// currentIndex = 1
// }
}
}

View File

@@ -11,8 +11,14 @@ Item {
CoverFlip {
id: coverView
anchors.fill: parent
anchors.leftMargin: parent.width / 2
anchors {
top: parent.top
right: parent.right
bottom:parent.bottom
}
width: parent.width / 2
backgroundColor: scene.color
model: dynamicModel
@@ -42,7 +48,7 @@ Item {
font.bold: true
width: parent.width
elide: Text.ElideRight
text: echonestStation.name
text: rootView.title
}
}

View File

@@ -47,6 +47,7 @@ PlayableModel::PlayableModel( QObject* parent, bool loading )
roleNames.insert( ArtistRole, "artistName" );
roleNames.insert( TrackRole, "trackName" );
roleNames.insert( CoverIDRole, "coverID" );
roleNames.insert( IsPlayingRole, "isPlaying" );
setRoleNames( roleNames );
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ), Qt::DirectConnection );
@@ -282,6 +283,10 @@ PlayableModel::data( const QModelIndex& index, int role ) const
{
return QVariant( columnAlignment( index.column() ) );
}
else if ( role == IsPlayingRole )
{
return entry->isPlaying();
}
int column = index.column();
if ( role < CoverIDRole && role >= Qt::UserRole )

View File

@@ -70,7 +70,8 @@ public:
OriginRole,
ScoreRole,
NameRole,
CoverIDRole
CoverIDRole,
IsPlayingRole
};

View File

@@ -429,6 +429,7 @@ EchonestGenerator::dynamicFetched()
Q_ASSERT( qobject_cast< QNetworkReply* >( sender() ) );
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
tDebug() << "dynamicFetched";
try
{
Echonest::DynamicPlaylist::FetchPair fetched = m_dynPlaylist->parseNext( reply );

View File

@@ -66,8 +66,6 @@ DynamicQmlWidget::DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* pa
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), this, SLOT( trackStarted() ) );
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), this, SLOT( playlistChanged( Tomahawk::playlistinterface_ptr ) ) );
// Initially seed the playlist
m_playlist->generator()->startFromArtist( Artist::get( "Eminem" , false ) );
}
@@ -117,7 +115,7 @@ playlist_ptr DynamicQmlWidget::playlist() const
void DynamicQmlWidget::playItem(int index)
{
qDebug() << "playItem called for cover" << index;
tDebug() << "playItem called for cover" << index;
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), m_proxyModel->itemFromIndex( index )->result() );
}
@@ -126,6 +124,12 @@ void DynamicQmlWidget::pause()
AudioEngine::instance()->pause();
}
void DynamicQmlWidget::startStationFromArtist(const QString &artist)
{
tDebug() << "should start startion from artist" << artist;
m_playlist->generator()->startFromArtist(Artist::get(artist));
}
void DynamicQmlWidget::currentItemChanged( const QPersistentModelIndex &currentIndex )
{
rootContext()->setContextProperty( "currentlyPlayedIndex", m_proxyModel->mapFromSource( currentIndex ).row() );
@@ -134,7 +138,6 @@ void DynamicQmlWidget::currentItemChanged( const QPersistentModelIndex &currentI
void
DynamicQmlWidget::tracksGenerated( const QList< query_ptr >& queries )
{
qDebug() << queries.count() << "tracks generated";
m_model->tracksGenerated( queries, queries.count() );
m_playlist->resolve();
}

View File

@@ -35,6 +35,9 @@ class DynamicModel;
class DynamicQmlWidget : public QDeclarativeView, public Tomahawk::ViewPage
{
Q_OBJECT
Q_PROPERTY(QString title READ title)
public:
explicit DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0 );
virtual ~DynamicQmlWidget();
@@ -57,6 +60,7 @@ public:
public slots:
void playItem(int index);
void pause();
void startStationFromArtist(const QString &artist);
private slots:
void currentItemChanged( const QPersistentModelIndex &currentIndex );