on xenial help sign in
Use CardTool to configure CardFilter and CardCarousel.
commitaf9535f9d611e89725ec1e682034bf9d5cd17c6e authorMichał Sawicz <michal.sawicz@canonical.com> dateFri 31 Jan 2014, 17:48 (13 years ago) parent0bf39e2
2 files changed+65−21
qml/Dash/CardCarousel.qml+45−12 qml/Dash/CardFilterGrid.qml+20−9
qml/Dash/CardCarousel.qml+45−12
@@ -17,22 +17,55 @@
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
29− template: cardCarousel.template
30− components: cardCarousel.components
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)
3134
32− property bool explicitlyScaled
33− property var model
35+ CardTool {
36+ id: cardTool
37+
38+ template: genericFilterGrid.template
39+ components: genericFilterGrid.components
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+ 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+ }
3871}
qml/Dash/CardFilterGrid.qml+20−9
@@ -21,19 +21,30 @@ 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+ anchors.horizontalCenter: parent.horizontalCenter
41+ objectName: "delegate" + index
42+ cardData: model
43+ template: genericFilterGrid.template
44+ components: genericFilterGrid.components
3545
36− onClicked: genericFilterGrid.clicked(index, card.y)
37− onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
46+ onClicked: genericFilterGrid.clicked(index, card.y)
47+ onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
48+ }
3849 }
3950}