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:
@@ -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
54
data/qml/GridView.qml
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user