@@ -16,154 +16,208 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19+import Ubuntu.Components.ListItems 0.1 as ListItems
19import "../../Components"
20import "../../Components"
20−import "../../Components/ListItems" as ListItems
21import ".."
21import ".."
23DashPreview {
24DashPreview {
24 id: genericPreview
25 id: genericPreview
26− previewWidthRatio: 0.6
28 property url url: previewData.image
26 property url url: previewData.image
28+ previewImages: previewImagesComponent
29+ header: headerComponent
30+ actions: actionsComponent
31+ description: descriptionComponent
32+ ratings: ratingsComponent
35+ id: previewImagesComponent
30− previewImages: UbuntuShape {
36+ UbuntuShape {
31− id: urlLoader
37+ id: urlLoader
32− anchors.left: parent.left
38+ anchors.left: parent.left
33− anchors.right: parent.right
39+ anchors.right: parent.right
34− height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
40+ height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
35− radius: "medium"
41+ radius: "medium"
36− image: Image {
43+ image: Image {
37− id: previewImage
44+ id: previewImage
38− asynchronous: true
45+ asynchronous: true
39− source: genericPreview.url
46+ source: genericPreview.url
40− fillMode: Image.PreserveAspectCrop
47+ fillMode: Image.PreserveAspectCrop
44− header: Column {
52+ Component {
45− height: childrenRect.height
53+ id: headerComponent
49− objectName: "titleLabel"
50− anchors { left: parent.left; right: parent.right }
52− elide: Text.ElideRight
54− font.weight: Font.Light
55− color: Theme.palette.selected.backgroundText
57− text: previewData.title
55+ title: previewData.title
58− style: Text.Raised
56+ rating: Math.round(root.previewData.rating * 10)
59− styleColor: "black"
57+ reviews: root.previewData.numRatings
60− maximumLineCount: 2
58+ rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
61− wrapMode: Text.WordWrap
65− anchors { left: parent.left; right: parent.right }
70− text: previewData.subtitle.replace(/[\r\n]+/g, "<br />")
73− wrapMode: Text.WordWrap
74− textFormat: Text.RichText
76− // FIXME: workaround for https://bugreports.qt-project.org/browse/QTBUG-33020
77− onWidthChanged: { wrapMode = Text.NoWrap; wrapMode = Text.WordWrap }
80− actions: GridView {
64+ GridView {
81− id: buttons
65+ id: buttons
82− model: genericPreview.previewData.actions
66+ model: genericPreview.previewData.actions
84− property int buttonMaxWidth: units.gu(34)
68+ property int buttonMaxWidth: units.gu(34)
85− property int numOfColumns: Math.ceil((width + spacing) / (buttonMaxWidth + spacing))
69+ property int numOfColumns: Math.ceil((width + spacing) / (buttonMaxWidth + spacing))
86− property int numOfRows: Math.ceil(count / numOfColumns)
70+ property int numOfRows: Math.ceil(count / numOfColumns)
87− property int spacing: units.gu(1)
71+ property int spacing: units.gu(1)
88− height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
72+ height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
90− cellWidth: width / numOfColumns
74+ cellWidth: width / numOfColumns
91− cellHeight: buttonHeight + spacing
75+ cellHeight: buttonHeight + spacing
92− property int buttonWidth: cellWidth - spacing / 2
76+ property int buttonWidth: cellWidth - spacing / 2
93− property int buttonHeight: units.gu(4)
77+ property int buttonHeight: units.gu(4)
95− delegate: Button {
79+ delegate: Button {
96− width: Math.max(units.gu(4), buttons.buttonWidth)
80+ width: Math.max(units.gu(4), buttons.buttonWidth)
97− height: buttons.buttonHeight
81+ height: buttons.buttonHeight
98− color: "#dd4814"
82+ color: "#dd4814"
99− text: modelData.displayName
83+ text: modelData.displayName
100− iconSource: modelData.iconHint
84+ iconSource: modelData.iconHint
101− iconPosition: "right"
85+ iconPosition: "right"
102− visible: true
86+ visible: true
103− onClicked: {
87+ onClicked: {
104− genericPreview.previewData.execute(modelData.id, { })
88+ genericPreview.previewData.execute(modelData.id, { })
96+ id: descriptionComponent
110− description: Column {
97+ Column {
111− spacing: units.gu(2)
98+ spacing: units.gu(2)
114− id: descriptionLabel
101+ id: descriptionLabel
115− anchors { left: parent.left; right: parent.right }
102+ anchors { left: parent.left; right: parent.right }
116− visible: text != ""
103+ visible: text != ""
117− fontSize: "small"
104+ fontSize: "small"
118− opacity: 0.6
105+ opacity: 0.6
119− color: "white"
106+ color: "white"
120− text: previewData.description.replace(/[\r\n]+/g, "<br />")
107+ text: previewData.description.replace(/[\r\n]+/g, "<br />")
121− style: Text.Raised
108+ style: Text.Raised
122− styleColor: "black"
109+ styleColor: "black"
123− wrapMode: Text.WordWrap
110+ wrapMode: Text.WordWrap
124− textFormat: Text.RichText
111+ textFormat: Text.RichText
125− // FIXME: workaround for https://bugreports.qt-project.org/browse/QTBUG-33020
112+ // FIXME: workaround for https://bugreports.qt-project.org/browse/QTBUG-33020
126− onWidthChanged: { wrapMode = Text.NoWrap; wrapMode = Text.WordWrap }
113+ onWidthChanged: { wrapMode = Text.NoWrap; wrapMode = Text.WordWrap }
123+ model: previewData.infoHints
130+ spacing: units.gu(1)
131+ property int columnWidth: (width - spacing) / 2
132+ anchors.verticalCenter: parent.verticalCenter
135+ visible: directedLabel.visible
139+ horizontalAlignment: Text.AlignLeft
140+ width: parent.columnWidth
141+ text: modelData.displayName
147+ visible: modelData.value != ""
151+ horizontalAlignment: Text.AlignRight
152+ width: parent.columnWidth
153+ text: modelData.value ? modelData.value : ""
156+ wrapMode: Text.WordWrap
159+ ListItems.ThinDivider {
162+ bottom: parent.bottom
173+ id: ratingsComponent
130− id: infoItem
175+ visible: root.previewData.rating >= 0
131− anchors {
176+ spacing: units.gu(1)
177+ height: childrenRect.height
179+ ListItems.ThinDivider { }
182+ anchors { left: parent.left; right: parent.right }
183+ height: rateLabel.height
192+ text: i18n.tr("Rate this")
132− left: parent.left
194+ anchors.left: parent.left
195+ anchors.verticalCenter: parent.verticalCenter
198+ // FIXME these need to be made interactive and connected to the scope
133− right: parent.right
200+ anchors.right: parent.right
201+ anchors.verticalCenter: parent.verticalCenter
136− model: previewData.infoHints
205+ ListItems.ThinDivider { }
138− delegate: Grid {
207+ Reviews {
139− columns: 2
208+ id: appReviews
140− width: parent.width
209+ objectName: "appReviews"
141− spacing: units.gu(1)
210+ // TODO: This should make this visible when the feature for reviews/comments is complete.
142−
211+ visible: false; height: 0
144− visible: directedLabel.visible
213+ anchors { left: parent.left; right: parent.right }
145− fontSize: "small"
214+
146− opacity: 0.9
215+ model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
148− horizontalAlignment: Text.AlignLeft
217+ onSendReview: root.sendUserReview(review);
149− width: infoItem.width / 2
218+
150− text: modelData.displayName
219+ onEditing: {
151− style: Text.Raised
220+ root.ensureVisible(appReviews.textArea);
156− visible: modelData.value != ""
160− horizontalAlignment: Text.AlignRight
161− width: infoItem.width / 2
162− text: modelData.value ? modelData.value : ""
165− wrapMode: Text.WordWrap