1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-02 10:24:01 +02:00

replaced GridView in WelcomeWidget with QML Gridview

* Items don't hold correct CoverIDRoled yet
* Items don't hold correct IsPlayingRole yet
This commit is contained in:
Michael Zanetti
2012-12-02 12:10:22 +01:00
parent 4fdc6610e5
commit 1938fdc727
9 changed files with 242 additions and 12 deletions

View File

@@ -137,7 +137,7 @@ Item {
id: itemShadow
color: backgroundColor
anchors.fill: parent
anchors.bottomMargin: - parent.height
//anchors.bottomMargin: - parent.height
// scaling might be off a pixel... make sure that the shadow is at least as large as the image
anchors.leftMargin: -2
@@ -158,6 +158,7 @@ Item {
width: parent.width + 4
anchors.centerIn: parent
anchors.verticalCenterOffset: parent.height
visible: showMirror
gradient: Gradient {
// TODO: no clue how to get the RGB component of the container rectangle color

54
data/qml/GridView.qml Normal file
View File

@@ -0,0 +1,54 @@
import QtQuick 1.1
//import tomahawk 1.0
//import "tomahawkimports"
Rectangle {
anchors.fill: parent
color: "black"
Text {
id: fontMetrics
text: "Here's some sample text"
opacity: 0
}
GridView {
id: gridView
anchors.fill: parent
cellHeight: cellWidth
cellWidth: calculateCoverSize(gridView.width - 3)
function calculateCoverSize(rectWidth) {
var itemWidth = fontMetrics.width;
var itemsPerRow = Math.max( 1, Math.floor( rectWidth / itemWidth ) );
var remSpace = rectWidth - ( itemsPerRow * itemWidth );
var extraSpace = remSpace / itemsPerRow;
return itemWidth + extraSpace;
}
model: mainModel
delegate: CoverImage {
height: gridView.cellHeight// * 0.95
width: gridView.cellWidth// * 0.95
showLabels: true
showMirror: false
artistName: model.artistName
trackName: model.trackName
artworkId: model.coverID
showPlayButton: true
currentlyPlaying: isPlaying
onClicked: {
rootView.onItemClicked(index)
}
onPlayClicked: {
rootView.onItemPlayClicked(index)
}
}
}
}