on xenial help sign in
Fix CardHeader title alignment.
commit005391e5bd45ed96320edae2f9257268a750916a authorMichał Karnicki <michal.karnicki@canonical.com> dateTue 4 Feb 2014, 14:25 (13 years ago) parentdb5e8b7
4 files changed+21
qml/Dash/Card.qml+2 qml/Dash/CardFilterGrid.qml+2 qml/Dash/CardHeader.qml+4 qml/Dash/CardTool.qml+13
qml/Dash/Card.qml+2
@@ -23,6 +23,8 @@ AbstractButton {
2323 property var components
2424 property var cardData
2525
26+ property alias titleHorizontalAlignment: header.titleHorizontalAlignment
27+
2628 implicitWidth: childrenRect.width
2729 implicitHeight: childrenRect.height
2830
qml/Dash/CardFilterGrid.qml+2
@@ -45,6 +45,8 @@ DashFilterGrid {
4545 template: genericFilterGrid.template
4646 components: genericFilterGrid.components
4747
48+ titleHorizontalAlignment: cardTool.titleHorizontalAlignment
49+
4850 onClicked: genericFilterGrid.clicked(index, card.y)
4951 onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
5052 }
qml/Dash/CardHeader.qml+4
@@ -26,6 +26,8 @@ Item {
2626 property alias oldPrice: oldPriceLabel.text
2727 property alias altPrice: altPriceLabel.text
2828
29+ property alias titleHorizontalAlignment: titleLabel.horizontalAlignment
30+
2931 visible: mascotImage.status === Image.Ready || title || price
3032 height: row.height > 0 ? row.height + row.margins * 2 : 0
3133
@@ -71,6 +73,7 @@ Item {
7173 wrapMode: Text.Wrap
7274 maximumLineCount: 2
7375 fontSize: "small"
76+ verticalAlignment: Text.AlignVCenter
7477 }
7578
7679 Label {
@@ -80,6 +83,7 @@ Item {
8083 elide: Text.ElideRight
8184 font.weight: Font.Light
8285 visible: titleLabel.text && text
86+ height: visible ? implicitHeight : 0
8387 fontSize: "x-small"
8488 }
8589
qml/Dash/CardTool.qml+13
@@ -102,6 +102,8 @@ Item {
102102
103103 property QtObject priv: card
104104
105+ property var titleHorizontalAlignment: card.titleHorizontalAlignment
106+
105107 Card {
106108 id: card
107109 template: cardTool.template
@@ -110,6 +112,17 @@ Item {
110112 width: cardTool.cardWidth || implicitWidth
111113 height: cardTool.cardHeight || implicitHeight
112114
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+
113126 property var fields: ["art", "mascot", "title", "subtitle", "summary"]
114127 property var maxData: {
115128 "art": Qt.resolvedUrl("graphics/checkers.png"),