on xenial help sign in
Fix CardHeader title alignment.
005391eMichał Karnicki
qml/Dash/Card.qml+2
@@ -23,6 +23,8 @@ AbstractButton {
23 property var components
23 property var components
24 property var cardData
24 property var cardData
25
25
26+ property alias titleHorizontalAlignment: header.titleHorizontalAlignment
27+
26 implicitWidth: childrenRect.width
28 implicitWidth: childrenRect.width
27 implicitHeight: childrenRect.height
29 implicitHeight: childrenRect.height
28
30
qml/Dash/CardFilterGrid.qml+2
@@ -45,6 +45,8 @@ DashFilterGrid {
45 template: genericFilterGrid.template
45 template: genericFilterGrid.template
46 components: genericFilterGrid.components
46 components: genericFilterGrid.components
47
47
48+ titleHorizontalAlignment: cardTool.titleHorizontalAlignment
49+
48 onClicked: genericFilterGrid.clicked(index, card.y)
50 onClicked: genericFilterGrid.clicked(index, card.y)
49 onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
51 onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
50 }
52 }
qml/Dash/CardHeader.qml+4
@@ -26,6 +26,8 @@ Item {
26 property alias oldPrice: oldPriceLabel.text
26 property alias oldPrice: oldPriceLabel.text
27 property alias altPrice: altPriceLabel.text
27 property alias altPrice: altPriceLabel.text
28
28
29+ property alias titleHorizontalAlignment: titleLabel.horizontalAlignment
30+
29 visible: mascotImage.status === Image.Ready || title || price
31 visible: mascotImage.status === Image.Ready || title || price
30 height: row.height > 0 ? row.height + row.margins * 2 : 0
32 height: row.height > 0 ? row.height + row.margins * 2 : 0
31
33
@@ -71,6 +73,7 @@ Item {
71 wrapMode: Text.Wrap
73 wrapMode: Text.Wrap
72 maximumLineCount: 2
74 maximumLineCount: 2
73 fontSize: "small"
75 fontSize: "small"
76+ verticalAlignment: Text.AlignVCenter
74 }
77 }
75
78
76 Label {
79 Label {
@@ -80,6 +83,7 @@ Item {
80 elide: Text.ElideRight
83 elide: Text.ElideRight
81 font.weight: Font.Light
84 font.weight: Font.Light
82 visible: titleLabel.text && text
85 visible: titleLabel.text && text
86+ height: visible ? implicitHeight : 0
83 fontSize: "x-small"
87 fontSize: "x-small"
84 }
88 }
85
89
qml/Dash/CardTool.qml+13
@@ -102,6 +102,8 @@ Item {
102
102
103 property QtObject priv: card
103 property QtObject priv: card
104
104
105+ property var titleHorizontalAlignment: card.titleHorizontalAlignment
106+
105 Card {
107 Card {
106 id: card
108 id: card
107 template: cardTool.template
109 template: cardTool.template
@@ -110,6 +112,17 @@ Item {
110 width: cardTool.cardWidth || implicitWidth
112 width: cardTool.cardWidth || implicitWidth
111 height: cardTool.cardHeight || implicitHeight
113 height: cardTool.cardHeight || implicitHeight
112
114
115+ property var titleHorizontalAlignment: {
116+ // TODO karni: attribute-1 instead of price?
117+ var subtitle = components["subtitle"];
118+ var price = components["price"];
119+ var isOnlyItem = (subtitle === undefined || subtitle === "") && (price === undefined || price === "");
120+ var hasImage = (components["art"]["image"] && components["art"]["image"] !== "") ||
121+ (components["mascot"] && components["mascot"] !== "");
122+ if (!isOnlyItem) return Text.AlignLeft;
123+ return hasImage ? Text.AlignLeft : Text.AlignHCenter;
124+ }
125+
113 property var fields: ["art", "mascot", "title", "subtitle", "summary"]
126 property var fields: ["art", "mascot", "title", "subtitle", "summary"]
114 property var maxData: {
127 property var maxData: {
115 "art": Qt.resolvedUrl("graphics/checkers.png"),
128 "art": Qt.resolvedUrl("graphics/checkers.png"),