on xenial help sign in
Move titleAlignment from within card to CardTool.
46599adMichał Karnicki
qml/Dash/CardTool.qml+16−15
@@ -100,9 +100,23 @@ Item {
100 }
100 }
101 }
101 }
102
102
103− property QtObject priv: card
103+ property var titleAlignment: {
104+ var subtitle = components["subtitle"];
105+ var price = components["price"];
106+ var summary = components["summary"];
107+
108+ var hasSubtitle = subtitle && (typeof subtitle === "string" || subtitle["field"])
109+ var hasPrice = price && (typeof price === "string" || subtitle["field"]);
110+ var hasSummary = summary && (typeof summary === "string" || summary["field"])
111+
112+ var isOnlyTextComponent = !hasSubtitle && !hasPrice && !hasSummary;
113+ if (!isOnlyTextComponent) return Text.AlignLeft;
114+
115+ return (template["card-layout"] === "horizontal") ? Text.AlignHCenter : Text.AlignLeft;
116+ }
117+
104
118
105− property var titleAlignment: card.titleAlignment
119+ property QtObject priv: card
106
120
107 Card {
121 Card {
108 id: card
122 id: card
@@ -112,19 +126,6 @@ Item {
112 width: cardTool.cardWidth || implicitWidth
126 width: cardTool.cardWidth || implicitWidth
113 height: cardTool.cardHeight || implicitHeight
127 height: cardTool.cardHeight || implicitHeight
114
128
115− property var titleAlignment: {
116− var subtitle = components["subtitle"];
117− var price = components["price"];
118−
119− var hasSubtitle = subtitle && (typeof subtitle === "string" || subtitle["field"])
120− var hasPrice = price && (typeof price === "string" || subtitle["field"]);
121−
122− var isOnlyTextComponent = !hasSubtitle && !hasPrice;
123− if (!isOnlyTextComponent) return Text.AlignLeft;
124−
125− return (template["card-layout"] === "horizontal") ? Text.AlignHCenter : Text.AlignLeft;
126− }
127−
128 property var fields: ["art", "mascot", "title", "subtitle", "summary"]
129 property var fields: ["art", "mascot", "title", "subtitle", "summary"]
129 property var maxData: {
130 property var maxData: {
130 "art": Qt.resolvedUrl("graphics/checkers.png"),
131 "art": Qt.resolvedUrl("graphics/checkers.png"),