From 0b4c3cde67510260e5c1847ddfe2c2dd702e56e0 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 4 Aug 2013 18:13:52 +0200 Subject: [PATCH] Station is now a CoverFlow instead of a CoverFlip --- data/qml/stations/StationItem.qml | 41 +------------ data/qml/tomahawkimports/CoverFlow.qml | 84 ++++++++++++++++++++++++++ resources.qrc | 1 + 3 files changed, 87 insertions(+), 39 deletions(-) create mode 100644 data/qml/tomahawkimports/CoverFlow.qml diff --git a/data/qml/stations/StationItem.qml b/data/qml/stations/StationItem.qml index 77bec8c46..16021e37b 100644 --- a/data/qml/stations/StationItem.qml +++ b/data/qml/stations/StationItem.qml @@ -5,13 +5,10 @@ import "../tomahawkimports" Item { id: stationItem - CoverFlip { + CoverFlow { id: coverView - anchors.right: parent.right - anchors.top: parent.top - height: parent.height - width: parent.width interactive: false + anchors.fill: parent backgroundColor: scene.color @@ -25,40 +22,6 @@ Item { onItemClicked: { mainView.playItem(index) } - - states: [ - State { - name: "empty"; when: mainView.loading - PropertyChanges { - target: coverView - anchors.rightMargin: -coverView.width - anchors.topMargin: - coverView.height - scale: 0 - } - } - ] - transitions: [ - Transition { - from: "empty" - to: "*" - NumberAnimation { - properties: "anchors.topMargin,anchors.rightMargin,scale" - duration: 1000 - easing.type: Easing.OutQuad - } - } - - ] -// Behavior on anchors.topMargin { -// NumberAnimation { duration: 500 } -// } -// Behavior on anchors.rightMargin { -// NumberAnimation { duration: 500 } -// } -// Behavior on scale { -// NumberAnimation { duration: 500 } -// } - } BusyIndicator { id: busyIndicator diff --git a/data/qml/tomahawkimports/CoverFlow.qml b/data/qml/tomahawkimports/CoverFlow.qml new file mode 100644 index 000000000..7f9fa0046 --- /dev/null +++ b/data/qml/tomahawkimports/CoverFlow.qml @@ -0,0 +1,84 @@ +import QtQuick 1.1 +import tomahawk 1.0 + +ListView { + id: coverView + + property color backgroundColor: "black" + property int coverSize: height / 2 + + // emitted when a cover is clicked + signal itemClicked(int index) + + // emitted when a cover is clicked + signal itemPlayPauseClicked(int index) + + preferredHighlightBegin: (width / 2) - (coverSize / 4) + preferredHighlightEnd: preferredHighlightBegin + coverSize / 2 + snapMode: ListView.SnapToItem + highlightRangeMode: ListView.StrictlyEnforceRange + highlightMoveDuration: 200 + + property bool itemHovered: false + orientation: ListView.Horizontal + + delegate: Item { + id: delegateItem + height: parent.height + width: coverView.coverSize / 2 + anchors.verticalCenter: ListView.view.verticalCenter + + property real distanceFromLeftEdge: -coverView.contentX + index*width + property real distanceFromRightEdge: coverView.contentX + coverView.width - (index+1)*width + property real distanceFromEdge: Math.max(distanceFromLeftEdge, distanceFromRightEdge) + + scale: 2 - (distanceFromEdge / (coverView.width)) + + property double itemBrightness: (1.3 - (distanceFromEdge / (coverView.width))) - ((coverView.itemHovered && !coverDelegate.containsMouse) ? .4 : 0) + property double itemOpacity: coverView.itemHovered && !coverDelegate.containsMouse ? 0.4 : 1 + property int _origZ + + z: -Math.abs(currentIndex - index) + + CoverImage { + id: coverDelegate + height: coverView.coverSize / 2 + width: parent.width + anchors { + verticalCenter: parent.verticalCenter + right: parent.right + } + + showLabels: true + showMirror: false + artistName: model.artistName + trackName: model.trackName + artworkId: model.coverID + showPlayButton: true + currentlyPlaying: isPlaying + smooth: true + + itemBrightness: coverDelegate.containsMouse ? 1 : parent.itemBrightness * (coverView.itemHovered ? .5 : 1) + opacity: parent.itemOpacity + z: coverView.width - x + + onPlayClicked: { + console.log("***************") + coverView.itemPlayPauseClicked(index) + } + + onClicked: { + coverView.itemClicked(index) + } + + onContainsMouseChanged: { + if (containsMouse) { + delegateItem._origZ = delegateItem.z; + coverView.itemHovered = true + } else { + coverView.itemHovered = false + } + } + } + } +} diff --git a/resources.qrc b/resources.qrc index 5fd4cea3b..9c29f523a 100644 --- a/resources.qrc +++ b/resources.qrc @@ -101,6 +101,7 @@ data/qml/tomahawkimports/RoundedButton.qml data/qml/tomahawkimports/PushButton.qml data/qml/tomahawkimports/CoverFlip.qml + data/qml/tomahawkimports/CoverFlow.qml data/qml/tomahawkimports/BusyIndicator.qml data/qml/tomahawkimports/InputBubble.qml data/qml/StationView.qml