on xenial help sign in
some more cleanup and tweaks to match design
commit13e6008f16e7c602acc25f1fad86570306513685 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 30 Sep 2013, 23:03 (13 years ago) parent4564d3d
4 files changed+146−109
Dash/Apps/AppPreview.qml+57−2 Dash/Generic/GenericPreview.qml+2−55 Dash/Movie/MoviePreview.qml+73−51 Dash/Previews/PreviewHeader.qml → Dash/Previews/Header.qml+14−1
Dash/Apps/AppPreview.qml+57−2
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19−import Ubuntu.Components.ListItems 0.1 as ListItem
19+import Ubuntu.Components.ListItems 0.1 as ListItems
2020import Ubuntu.DownloadDaemonListener 0.1
2121import ".."
2222import "../Generic"
@@ -32,6 +32,7 @@ GenericPreview {
3232 actions: root.previewData.infoMap["show_progressbar"] ? progressComponent : buttonsComponent
3333 description: descriptionComponent
3434 header: headerComponent
35+ ratings: ratingsComponent
3536
3637 Component {
3738 id: previewImagesComponent
@@ -62,7 +63,7 @@ GenericPreview {
6263
6364 Component {
6465 id: headerComponent
65− PreviewHeader {
66+ Header {
6667 title: previewData.title
6768 icon: previewData.appIcon
6869 rating: Math.round(root.previewData.rating * 10)
@@ -152,4 +153,58 @@ GenericPreview {
152153 }
153154 }
154155 }
156+
157+ Component {
158+ id: ratingsComponent
159+ Column {
160+ visible: root.previewData.rating >= 0
161+ spacing: units.gu(1)
162+ height: childrenRect.height
163+
164+ ListItems.ThinDivider { }
165+
166+ Item {
167+ anchors { left: parent.left; right: parent.right }
168+ height: rateLabel.height
169+
170+ Label {
171+ id: rateLabel
172+ fontSize: "medium"
173+ color: "white"
174+ style: Text.Raised
175+ styleColor: "black"
176+ opacity: .9
177+ text: i18n.tr("Rate this")
178+
179+ anchors.left: parent.left
180+ anchors.verticalCenter: parent.verticalCenter
181+ }
182+
183+ // FIXME these need to be made interactive and connected to the scope
184+ RatingStars {
185+ anchors.right: parent.right
186+ anchors.verticalCenter: parent.verticalCenter
187+ }
188+ }
189+
190+ ListItems.ThinDivider { }
191+
192+ Reviews {
193+ id: appReviews
194+ objectName: "appReviews"
195+ // TODO: This should make this visible when the feature for reviews/comments is complete.
196+ visible: false; height: 0
197+
198+ anchors { left: parent.left; right: parent.right }
199+
200+ model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
201+
202+ onSendReview: root.sendUserReview(review);
203+
204+ onEditing: {
205+ root.ensureVisible(appReviews.textArea);
206+ }
207+ }
208+ }
209+ }
155210}
Dash/Generic/GenericPreview.qml+2−55
@@ -51,9 +51,10 @@ DashPreview {
5151
5252 Component {
5353 id: headerComponent
54− PreviewHeader {
54+ Header {
5555 title: previewData.title
5656 rating: Math.round(root.previewData.rating * 10)
57+ subtitle: previewData.subtitle.replace(/[\r\n]+/g, "<br />")
5758 reviews: root.previewData.numRatings
5859 rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
5960 }
@@ -168,58 +169,4 @@ DashPreview {
168169 }
169170 }
170171 }
171−
172− Component {
173− id: ratingsComponent
174− Column {
175− visible: root.previewData.rating >= 0
176− spacing: units.gu(1)
177− height: childrenRect.height
178−
179− ListItems.ThinDivider { }
180−
181− Item {
182− anchors { left: parent.left; right: parent.right }
183− height: rateLabel.height
184−
185− Label {
186− id: rateLabel
187− fontSize: "medium"
188− color: "white"
189− style: Text.Raised
190− styleColor: "black"
191− opacity: .9
192− text: i18n.tr("Rate this")
193−
194− anchors.left: parent.left
195− anchors.verticalCenter: parent.verticalCenter
196− }
197−
198− // FIXME these need to be made interactive and connected to the scope
199− RatingStars {
200− anchors.right: parent.right
201− anchors.verticalCenter: parent.verticalCenter
202− }
203− }
204−
205− ListItems.ThinDivider { }
206−
207− Reviews {
208− id: appReviews
209− objectName: "appReviews"
210− // TODO: This should make this visible when the feature for reviews/comments is complete.
211− visible: false; height: 0
212−
213− anchors { left: parent.left; right: parent.right }
214−
215− model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
216−
217− onSendReview: root.sendUserReview(review);
218−
219− onEditing: {
220− root.ensureVisible(appReviews.textArea);
221− }
222− }
223− }
224− }
225172}
Dash/Movie/MoviePreview.qml+73−51
@@ -19,6 +19,7 @@ import Ubuntu.Components 0.1
1919import ".."
2020import "../Generic"
2121import "../../Components"
22+import "../Previews"
2223
2324GenericPreview {
2425 id: root
@@ -27,68 +28,89 @@ GenericPreview {
2728 property bool playable: previewData.imageSourceUri != null
2829 property url url: ready ? previewData.image : ""
2930
30− previewImages: UbuntuShape {
31− id: urlLoader
32− anchors.left: parent.left
33− anchors.right: parent.right
34− height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
35− radius: "medium"
36− visible: height > 0
37− image: Image {
38− id: previewImage
39− asynchronous: true
40− source: root.url
41− fillMode: Image.PreserveAspectCrop
42− }
31+ previewImages: previewImageComponent
32+ header: headerComponent
33+ actions: actionsComponent
34+ ratings: ratingsComponent
35+
36+ Component {
37+ id: previewImageComponent
38+ UbuntuShape {
39+ id: urlLoader
40+ anchors.left: parent.left
41+ anchors.right: parent.right
42+ height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
43+ radius: "medium"
44+ visible: height > 0
45+ image: Image {
46+ id: previewImage
47+ asynchronous: true
48+ source: root.url
49+ fillMode: Image.PreserveAspectCrop
50+ }
4351
44− Image {
45− objectName: "playButton"
46− anchors.centerIn: parent
47− visible: root.playable
48− readonly property bool bigButton: parent.width > units.gu(40)
49− width: bigButton ? units.gu(8) : units.gu(4.5)
50− height: width
51− source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
52+ Image {
53+ objectName: "playButton"
54+ anchors.centerIn: parent
55+ visible: root.playable
56+ readonly property bool bigButton: parent.width > units.gu(40)
57+ width: bigButton ? units.gu(8) : units.gu(4.5)
58+ height: width
59+ source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
60+ }
61+
62+ MouseArea {
63+ id: previewImageMouseArea
64+ anchors.fill: parent
65+ onClicked: shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', previewData.imageSourceUri);
66+ }
5267 }
68+ }
5369
54− MouseArea {
55− id: previewImageMouseArea
56− anchors.fill: parent
57− onClicked: shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', previewData.imageSourceUri);
70+ Component {
71+ id: headerComponent
72+ Header {
73+ title: previewData.title
74+ rating: Math.round(root.previewData.rating * 10)
75+ reviews: root.previewData.numRatings
76+ rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
5877 }
5978 }
6079
61− actions: GridView {
62− id: buttons
63− objectName: "gridButtons"
64− model: root.previewData.actions
65− interactive: false
80+ Component {
81+ id: actionsComponent
82+ GridView {
83+ id: buttons
84+ objectName: "gridButtons"
85+ model: root.previewData.actions
86+ interactive: false
6687
67− anchors.left: parent.left
68− anchors.right: parent.right
88+ anchors.left: parent.left
89+ anchors.right: parent.right
6990
70− property int numOfRows: (count + numOfColumns - 1) / numOfColumns
71− property int numOfColumns: Math.max(1, Math.floor(width / (buttonWidth + spacing)))
72− property int spacing: units.gu(1)
73− height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
91+ property int numOfRows: (count + numOfColumns - 1) / numOfColumns
92+ property int numOfColumns: Math.max(1, Math.floor(width / (buttonWidth + spacing)))
93+ property int spacing: units.gu(1)
94+ height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
7495
75− cellWidth: width / buttons.numOfColumns
76− cellHeight: buttonHeight + buttons.spacing
77− property int buttonWidth: units.gu(17) - spacing
78− property int buttonHeight: units.gu(4)
96+ cellWidth: width / buttons.numOfColumns
97+ cellHeight: buttonHeight + buttons.spacing
98+ property int buttonWidth: units.gu(17) - spacing
99+ property int buttonHeight: units.gu(4)
79100
80− delegate: Button {
81− width: Math.max(units.gu(4), buttons.buttonWidth)
82− height: buttons.buttonHeight
83− color: "#dd4814"
84− text: modelData.displayName
85− iconSource: modelData.iconHint
86− iconPosition: "right"
87− visible: true
88− onClicked: {
89− root.previewData.execute(modelData.id, { })
101+ delegate: Button {
102+ width: Math.max(units.gu(4), buttons.buttonWidth)
103+ height: buttons.buttonHeight
104+ color: "#dd4814"
105+ text: modelData.displayName
106+ iconSource: modelData.iconHint
107+ iconPosition: "right"
108+ visible: true
109+ onClicked: {
110+ root.previewData.execute(modelData.id, { })
111+ }
90112 }
113+ focus: false
91114 }
92− focus: false
93115 }
94116}
Dash/Previews/PreviewHeader.qml → Dash/Previews/Header.qmlrenamed+14−1
@@ -22,6 +22,7 @@ Row {
2222 id: root
2323 property alias icon: image.source
2424 property alias title: titleLabel.text
25+ property alias subtitle: subtitleLabel.text
2526 property alias rating: ratingStars.rating
2627 property int rated: 0
2728 property int reviews: 0
@@ -51,10 +52,22 @@ Row {
5152 style: Text.Raised
5253 styleColor: "black"
5354 opacity: .9
55+ width: parent.width
56+ elide: Text.ElideRight
57+ }
58+
59+ Label {
60+ id: subtitleLabel
61+ objectName: "subtitleLabel"
62+ fontSize: "medium"
63+ color: "white"
64+ style: Text.Raised
65+ styleColor: "black"
66+ opacity: .6
5467 }
5568
5669 Row {
57− visible: root.rating >= 0
70+ visible: root.rating >= 0 && subtitleLabel.text.length == 0
5871 spacing: units.gu(1)
5972
6073 RatingStars {