41 property real viewWidth
46 readonly
property real carouselSelectedItemScaleFactor: 1.38
56 property var components
61 property
string categoryLayout: {
62 var layout =
template[
"category-layout"];
65 if (layout ===
"carousel" && count <= Math.ceil(carouselTool.realPathItemCount)) layout =
"grid";
69 property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components);
83 readonly property var cardWidth: {
84 switch (categoryLayout) {
86 case "vertical-journal":
87 if (
template[
"card-layout"] ===
"horizontal")
return units.gu(38);
88 switch (
template[
"card-size"]) {
89 case "small":
return units.gu(12);
90 case "large":
return units.gu(38);
92 return units.gu(18.5);
94 return carouselTool.minimumTileWidth;
108 readonly property var cardHeight: {
109 switch (categoryLayout) {
111 if (
template[
"card-size"] >= 12 &&
template[
"card-size"] <= 38)
return units.gu(
template[
"card-size"]);
112 return units.gu(18.5);
114 return cardLoader.item ? cardLoader.item.implicitHeight : 0
116 return cardWidth / (components ? components[
"art"][
"aspect-ratio"] : 1)
119 case "vertical-journal":
128 readonly property
int headerHeight: cardLoader.item ? cardLoader.item.headerHeight : 0
129 readonly property size artShapeSize: cardLoader.item ? cardLoader.item.artShapeSize : 0
134 readonly property
int headerAlignment: {
135 var subtitle = components[
"subtitle"];
136 var price = components[
"price"];
137 var summary = components[
"summary"];
139 var hasSubtitle = subtitle && (typeof subtitle ===
"string" || subtitle[
"field"])
140 var hasPrice = price && (typeof price ===
"string" || subtitle[
"field"]);
141 var hasSummary = summary && (typeof summary ===
"string" || summary[
"field"])
143 var isOnlyTextComponent = !hasSubtitle && !hasPrice && !hasSummary;
144 if (!isOnlyTextComponent)
return Text.AlignLeft;
146 return (
template[
"card-layout"] ===
"horizontal") ? Text.AlignLeft : Text.AlignHCenter;
152 property real minimumTileWidth: {
153 if (cardTool.viewWidth === undefined)
return undefined;
154 if (cardTool.viewWidth <= units.gu(40))
return units.gu(18);
155 if (cardTool.viewWidth >= units.gu(128))
return units.gu(26);
156 return units.gu(18 + Math.round((cardTool.viewWidth - units.gu(40)) / units.gu(11)));
159 readonly property real pathItemCount: 4.8457
161 property real realPathItemCount: {
162 var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor;
163 var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth);
164 return Math.min(cardTool.viewWidth / tileWidth, pathItemCount);
170 property var fields: [
"art",
"mascot",
"title",
"subtitle",
"summary"]
171 property var maxData: {
172 "art": Qt.resolvedUrl(
"graphics/checkers.png"),
173 "mascot": Qt.resolvedUrl(
"graphics/checkers.png"),
176 "summary":
"—\n—\n—\n—\n—"
178 sourceComponent: cardTool.cardComponent
180 item.objectName =
"cardToolCard";
181 item.asynchronous =
false;
182 item.template = Qt.binding(
function() {
return cardTool.template; });
183 item.components = Qt.binding(
function() {
return cardTool.components; });
184 item.width = Qt.binding(
function() {
return cardTool.cardWidth || item.implicitWidth; });
185 item.height = Qt.binding(
function() {
return cardTool.cardHeight || item.implicitHeight; });
188 target: cardLoader.item
189 onComponentsChanged: {
191 for (var k in cardLoader.fields) {
192 var component = cardLoader.item.components[cardLoader.fields[k]];
193 var key = cardLoader.fields[k];
194 if ((typeof component ===
"string" && component.length > 0) ||
195 (typeof component ===
"object" && component !== null
196 && typeof component[
"field"] ===
"string" && component[
"field"].length > 0)) {
197 data[key] = cardLoader.maxData[key];
200 cardLoader.item.cardData = data;