on xenial help sign in
Use CardTool in CardFilterGrid and CardCarousel.
commit9c3020bbf860e43b564c0f8b6a80003e57ef963a authorMichał Sawicz <michal.sawicz@canonical.com> dateTue 4 Feb 2014, 19:14 (13 years ago) parent6d35bebdb5e8b7
2 files changed+64−20
qml/Dash/CardCarousel.qml+42−11 qml/Dash/CardFilterGrid.qml+22−9
qml/Dash/CardCarousel.qml+42−11
@@ -17,22 +17,53 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import "../Components"
20−import ".."
2120
22−DashCarousel {
21+
22+DashRenderer {
2323 id: cardCarousel
2424
25− itemComponent: Card {
26− id: card
27− objectName: "delegate" + index
28− cardData: model
25+ property alias cacheBuffer: carousel.cacheBuffer
26+ property alias itemComponent: carousel.itemComponent
27+ property alias minimumTileWidth: carousel.minimumTileWidth
28+ property alias selectedItemScaleFactor: carousel.selectedItemScaleFactor
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+
2938 template: cardCarousel.template
3039 components: cardCarousel.components
31−
32− property bool explicitlyScaled
33− property var model
40+ viewWidth: cardCarousel.width
3441 }
3542
36− // onClicked: cardCarousel.clicked(index, itemY)
37− // onPressAndHold: cardCarousel.pressAndHold(index, itemY)
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+
55+ onClicked: cardCarousel.clicked(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+ }
3869}
qml/Dash/CardFilterGrid.qml+22−9
@@ -21,19 +21,32 @@ DashFilterGrid {
2121 id: genericFilterGrid
2222
2323 minimumHorizontalSpacing: units.gu(0.5)
24− // FIXME calculate the size correctly
25− delegateWidth: grid.currentItem.width
26− delegateHeight: grid.currentItem.height
24+ delegateWidth: cardTool.cardWidth
25+ delegateHeight: cardTool.cardHeight
2726 verticalSpacing: units.gu(2)
2827
29− delegate: Card {
30− id: card
31− objectName: "delegate" + index
32− cardData: model
28+ CardTool {
29+ id: cardTool
30+
3331 template: genericFilterGrid.template
3432 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
3547
36− onClicked: genericFilterGrid.clicked(index, card.y)
37− onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
48+ onClicked: genericFilterGrid.clicked(index, card.y)
49+ onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
50+ }
3851 }
3952}