on xenial help sign in
Use CardTool in CardFilterGrid and CardCarousel.
9c3020bMichał Sawicz
qml/Dash/CardCarousel.qml+42−11
@@ -17,22 +17,53 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19import "../Components"
19import "../Components"
20−import ".."
21
20
22−DashCarousel {
21+
22+DashRenderer {
23 id: cardCarousel
23 id: cardCarousel
24
24
25+ property alias cacheBuffer: carousel.cacheBuffer
25− itemComponent: Card {
26+ property alias itemComponent: carousel.itemComponent
26− id: card
27+ property alias minimumTileWidth: carousel.minimumTileWidth
27− objectName: "delegate" + index
28+ property alias selectedItemScaleFactor: carousel.selectedItemScaleFactor
28− cardData: model
29+ property alias tileAspectRatio: carousel.tileAspectRatio
30+
31+ currentItem: carousel.currentItem
32+ height: carousel.implicitHeight + units.gu(6)
33+ verticalSpacing: units.gu(3)
34+
35+ CardTool {
36+ id: cardTool
37+
29 template: cardCarousel.template
38 template: cardCarousel.template
30 components: cardCarousel.components
39 components: cardCarousel.components
31−
40+ viewWidth: cardCarousel.width
32− property bool explicitlyScaled
33− property var model
34 }
41 }
35
42
43+ Carousel {
44+ id: carousel
45+ anchors.fill: parent
46+ tileAspectRatio: cardCarousel.components && cardCarousel.components["art"]["aspect-ratio"] || 1.0
47+ // FIXME we need to "reverse" the carousel to make the selected item the size
48+ // and push others back.
49+ minimumTileWidth: cardTool.cardWidth / selectedItemScaleFactor
50+ selectedItemScaleFactor: 1.38
51+ cacheBuffer: 1404 // 18px * 13gu * 6
52+ model: cardCarousel.model
53+ highlightIndex: cardCarousel.highlightIndex
54+
36− // onClicked: cardCarousel.clicked(index, itemY)
55+ onClicked: cardCarousel.clicked(index, itemY)
37− // onPressAndHold: cardCarousel.pressAndHold(index, itemY)
56+ onPressAndHold: cardCarousel.pressAndHold(index, itemY)
57+
58+ itemComponent: Card {
59+ id: card
60+ objectName: "delegate" + index
61+ cardData: model
62+ template: cardCarousel.template
63+ components: cardCarousel.components
64+
65+ property bool explicitlyScaled
66+ property var model
67+ }
68+ }
38}
69}
qml/Dash/CardFilterGrid.qml+22−9
@@ -21,19 +21,32 @@ DashFilterGrid {
21 id: genericFilterGrid
21 id: genericFilterGrid
22
22
23 minimumHorizontalSpacing: units.gu(0.5)
23 minimumHorizontalSpacing: units.gu(0.5)
24− // FIXME calculate the size correctly
25− delegateWidth: grid.currentItem.width
24+ delegateWidth: cardTool.cardWidth
26− delegateHeight: grid.currentItem.height
25+ delegateHeight: cardTool.cardHeight
27 verticalSpacing: units.gu(2)
26 verticalSpacing: units.gu(2)
28
27
29− delegate: Card {
28+ CardTool {
30− id: card
29+ id: cardTool
31− objectName: "delegate" + index
30+
32− cardData: model
33 template: genericFilterGrid.template
31 template: genericFilterGrid.template
34 components: genericFilterGrid.components
32 components: genericFilterGrid.components
33+ }
34+
35+ delegate: Item {
36+ width: genericFilterGrid.cellWidth
37+ height: genericFilterGrid.cellHeight
38+ Card {
39+ id: card
40+ width: cardTool.cardWidth
41+ height: cardTool.cardHeight
42+ anchors.horizontalCenter: parent.horizontalCenter
43+ objectName: "delegate" + index
44+ cardData: model
45+ template: genericFilterGrid.template
46+ components: genericFilterGrid.components
35
47
36− onClicked: genericFilterGrid.clicked(index, card.y)
48+ onClicked: genericFilterGrid.clicked(index, card.y)
37− onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
49+ onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
50+ }
38 }
51 }
39}
52}