on xenial help sign in
Use CardTool to configure CardFilter and CardCarousel.
af9535fMichał Sawicz
qml/Dash/CardCarousel.qml+45−12
@@ -17,22 +17,55 @@
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
29− template: cardCarousel.template
30+
30− components: cardCarousel.components
31+ currentItem: carousel.currentItem
32+ height: carousel.implicitHeight + units.gu(6)
33+ verticalSpacing: units.gu(3)
31
34
32− property bool explicitlyScaled
35+ CardTool {
33− property var model
36+ id: cardTool
37+
38+ template: genericFilterGrid.template
39+ components: genericFilterGrid.components
40+ viewWidth: cardCarousel.width
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+ width: cardTool.cardWidth / carousel.selectedItemScaleFactor
62+ height: cardTool.cardWidth / carousel.selectedItemScaleFactor
63+ cardData: model
64+ template: cardCarousel.template
65+ components: cardCarousel.components
66+
67+ property bool explicitlyScaled
68+ property var model
69+ }
70+ }
38}
71}
qml/Dash/CardFilterGrid.qml+20−9
@@ -21,19 +21,30 @@ 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+ anchors.horizontalCenter: parent.horizontalCenter
41+ objectName: "delegate" + index
42+ cardData: model
43+ template: genericFilterGrid.template
44+ components: genericFilterGrid.components
35
45
36− onClicked: genericFilterGrid.clicked(index, card.y)
46+ onClicked: genericFilterGrid.clicked(index, card.y)
37− onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
47+ onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
48+ }
38 }
49 }
39}
50}