@@ -28,6 +28,22 @@ import QtQuick 2.0
30 id: cardTool
30 id: cardTool
33+ \brief Number of cards.
38+ \brief Width of the category view.
40+ property real viewWidth
43+ \brief Scaling factor of selected Carousel item.
45+ readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards
32 \brief Template supplied for the category.
48 \brief Template supplied for the category.
@@ -39,14 +55,15 @@ Item {
39 property var components
55 property var components
42− \brief Width of the view, based on which carousel width is calculated.
58+ \brief The category layout for this card tool.
44− property var viewWidth
60+ property string categoryLayout: {
61+ var layout = template["category-layout"];
46− /*!
63+ // carousel fallback mode to grid
47− \brief The category layout for this card tool
64+ if (layout === "carousel" && count <= Math.ceil(carouselTool.realPathItemCount)) layout = "grid";
49− property string categoryLayout: template ? template["category-layout"] : ""
66+ }
51 // FIXME: Saviq
68 // FIXME: Saviq
52 // Only way for the card below to actually be laid out completely.
69 // Only way for the card below to actually be laid out completely.
@@ -71,10 +88,7 @@ Item {
72 return units.gu(18.5);
89 return units.gu(18.5);
73 case "carousel":
90 case "carousel":
74− if (viewWidth === undefined) return undefined
91+ return carouselTool.minimumTileWidth;
75− if (viewWidth <= units.gu(40)) return units.gu(18)
76− if (viewWidth >= units.gu(128)) return units.gu(26)
77− return units.gu(18 + Math.round((viewWidth - units.gu(40))/ units.gu(11)))
78 case undefined:
92 case undefined:
79 case "organic-grid":
93 case "organic-grid":
80 case "journal":
94 case "journal":
@@ -128,6 +142,25 @@ Item {
128 return (template["card-layout"] === "horizontal") ? Text.AlignLeft : Text.AlignHCenter;
142 return (template["card-layout"] === "horizontal") ? Text.AlignLeft : Text.AlignHCenter;
148+ property real minimumTileWidth: {
149+ if (cardTool.viewWidth === undefined) return undefined;
150+ if (cardTool.viewWidth <= units.gu(40)) return units.gu(18);
151+ if (cardTool.viewWidth >= units.gu(128)) return units.gu(26);
152+ return units.gu(18 + Math.round((cardTool.viewWidth - units.gu(40)) / units.gu(11)));
155+ readonly property real pathItemCount: 4.8457 /// (848 / 175) reference values
157+ property real realPathItemCount: {
158+ var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor;
159+ var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth);
160+ return Math.min(cardTool.viewWidth / tileWidth, pathItemCount);
133 objectName: "cardToolCard"
166 objectName: "cardToolCard"