on xenial help sign in
Add attributes to Preview. Fixes: 1282460, 1356881
acb11d3Ying-Chun Liu
qml/Dash/Previews/PreviewHeader.qml+13
@@ -16,12 +16,14 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19+import Dash 0.1
19import "../"
20import "../"
20
21
21/*! This preview widget shows a header
22/*! This preview widget shows a header
22 * The title comes in widgetData["title"]
23 * The title comes in widgetData["title"]
23 * The mascot comes in widgetData["mascot"]
24 * The mascot comes in widgetData["mascot"]
24 * The subtitle comes in widgetData["subtitle"]
25 * The subtitle comes in widgetData["subtitle"]
26+ * The attributes comes in widgetData["attributes"]
25 */
27 */
26
28
27PreviewWidget {
29PreviewWidget {
@@ -35,6 +37,7 @@ PreviewWidget {
35 readonly property url mascot: root.widgetData["mascot"] || ""
37 readonly property url mascot: root.widgetData["mascot"] || ""
36 readonly property string title: root.widgetData["title"] || ""
38 readonly property string title: root.widgetData["title"] || ""
37 readonly property string subtitle: root.widgetData["subtitle"] || ""
39 readonly property string subtitle: root.widgetData["subtitle"] || ""
40+ readonly property var attributes: root.widgetData["attributes"] || null
38 readonly property color fontColor: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
41 readonly property color fontColor: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
39
42
40 implicitHeight: row.height + row.margins * 2
43 implicitHeight: row.height + row.margins * 2
@@ -114,6 +117,16 @@ PreviewWidget {
114 text: headerRoot.subtitle
117 text: headerRoot.subtitle
115 }
118 }
116 }
119 }
120+
121+ Loader {
122+ active: titleLabel.text && headerRoot.attributes
123+ anchors { left: parent.left; right: parent.right }
124+ sourceComponent: CardAttributes {
125+ id: previewAttributes
126+ objectName: "previewAttributes"
127+ model: headerRoot.attributes
128+ }
129+ }
117 }
130 }
118 }
131 }
119 }
132 }
tests/qmltests/Dash/Previews/tst_PreviewHeader.qml+4−2
@@ -27,13 +27,15 @@ Rectangle {
27 property var origHeaderjson: {
27 property var origHeaderjson: {
28 "title": "THE TITLE",
28 "title": "THE TITLE",
29 "subtitle": "Something catchy",
29 "subtitle": "Something catchy",
30− "mascot": "../graphics/play_button.png"
30+ "mascot": "../graphics/play_button.png",
31+ "attributes": [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}]
31 }
32 }
32
33
33 property var headerjson: {
34 property var headerjson: {
34 "title": "THE TITLE",
35 "title": "THE TITLE",
35 "subtitle": "Something catchy",
36 "subtitle": "Something catchy",
36− "mascot": "../graphics/play_button.png"
37+ "mascot": "../graphics/play_button.png",
38+ "attributes": [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}]
37 }
39 }
38
40
39 PreviewHeader {
41 PreviewHeader {