40 property real viewWidth
45 readonly
property real carouselSelectedItemScaleFactor: 1.38
55 property var components
60 property
string categoryLayout: {
61 var layout =
template[
"category-layout"];
64 if (layout ===
"carousel" && count <= Math.ceil(carouselTool.realPathItemCount)) layout =
"grid";
80 readonly property var cardWidth: {
81 switch (categoryLayout) {
83 case "vertical-journal":
84 if (
template[
"card-layout"] ===
"horizontal")
return units.gu(38);
85 switch (
template[
"card-size"]) {
86 case "small":
return units.gu(12);
87 case "large":
return units.gu(38);
89 return units.gu(18.5);
91 return carouselTool.minimumTileWidth;
105 readonly property var cardHeight: {
106 switch (categoryLayout) {
108 if (
template[
"card-size"] >= 12 &&
template[
"card-size"] <= 38)
return units.gu(
template[
"card-size"]);
109 return units.gu(18.5);
111 return card.implicitHeight
113 return cardWidth / (components ? components[
"art"][
"aspect-ratio"] : 1)
116 case "vertical-journal":
125 readonly property alias headerHeight: card.headerHeight
130 readonly property
int headerAlignment: {
131 var subtitle = components[
"subtitle"];
132 var price = components[
"price"];
133 var summary = components[
"summary"];
135 var hasSubtitle = subtitle && (typeof subtitle ===
"string" || subtitle[
"field"])
136 var hasPrice = price && (typeof price ===
"string" || subtitle[
"field"]);
137 var hasSummary = summary && (typeof summary ===
"string" || summary[
"field"])
139 var isOnlyTextComponent = !hasSubtitle && !hasPrice && !hasSummary;
140 if (!isOnlyTextComponent)
return Text.AlignLeft;
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
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);
166 objectName:
"cardToolCard"
167 template: cardTool.template
168 components: cardTool.components
170 width: cardTool.cardWidth || implicitWidth
171 height: cardTool.cardHeight || implicitHeight
173 property var fields: [
"art",
"mascot",
"title",
"subtitle",
"summary"]
174 property var maxData: {
175 "art": Qt.resolvedUrl(
"graphics/checkers.png"),
176 "mascot": Qt.resolvedUrl(
"graphics/checkers.png"),
179 "summary":
"—\n—\n—\n—\n—"
182 onComponentsChanged: {
184 for (var k in fields) {
185 var component = components[fields[k]];
187 if ((typeof component ===
"string" && component.length > 0) ||
188 (typeof component ===
"object" && component !== null
189 && typeof component[
"field"] ===
"string" && component[
"field"].length > 0)) {
190 data[key] = maxData[key];