on xenial help sign in
Hide rating widgets when scope provides rating set to < 0.0.
2d8a97dMichal Hruby
Dash/Apps/AppInfo.qml+1
@@ -53,6 +53,7 @@ Row {
53 }
53 }
54
54
55 Row {
55 Row {
56+ visible: root.rating >= 0
56 spacing: units.gu(1)
57 spacing: units.gu(1)
57
58
58 RatingStars {
59 RatingStars {
Dash/Apps/AppPreview.qml+37−32
@@ -38,7 +38,7 @@ DashPreview {
38 right: parent.right
38 right: parent.right
39 margins: units.gu(1)
39 margins: units.gu(1)
40 }
40 }
41− model: previewData.infoMap["more-screenshots"].value
41+ model: previewData.infoMap["more-screenshots"] != null ? previewData.infoMap["more-screenshots"].value : [previewData.image]
42
42
43 delegate: UbuntuShape {
43 delegate: UbuntuShape {
44 id: shape
44 id: shape
@@ -138,9 +138,9 @@ DashPreview {
138
138
139 appName: root.previewData.title
139 appName: root.previewData.title
140 icon: IconUtil.from_gicon(root.previewData.appIcon)
140 icon: IconUtil.from_gicon(root.previewData.appIcon)
141− rating: root.previewData.infoMap["rating"] ? root.previewData.infoMap["rating"].value : 0
141+ rating: Math.round(root.previewData.rating * 10)
142+ reviews: root.previewData.numRatings
142 rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
143 rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
143− reviews: root.previewData.infoMap["reviews"] ? root.previewData.infoMap["reviews"].value : 0
144 }
144 }
145
145
146 Label {
146 Label {
@@ -154,42 +154,47 @@ DashPreview {
154 styleColor: "black"
154 styleColor: "black"
155 }
155 }
156
156
157− ListItem.ThinDivider {}
157+ Column {
158−
158+ visible: root.previewData.rating >= 0
159− Item {
160 anchors { left: parent.left; right: parent.right }
159 anchors { left: parent.left; right: parent.right }
160+ spacing: parent.spacing
161+
162+ ListItem.ThinDivider { }
163+
164+ Item {
165+ anchors { left: parent.left; right: parent.right }
161− height: rateLabel.height
166+ height: rateLabel.height
162−
167+
163− Label {
168+ Label {
164− id: rateLabel
169+ id: rateLabel
165− fontSize: "medium"
170+ fontSize: "medium"
166− color: "white"
171+ color: "white"
167− style: Text.Raised
172+ style: Text.Raised
168− styleColor: "black"
173+ styleColor: "black"
169− opacity: .9
174+ opacity: .9
170− text: i18n.tr("Rate this")
175+ text: i18n.tr("Rate this")
171−
176+
172− anchors.left: parent.left
177+ anchors.left: parent.left
173− anchors.verticalCenter: parent.verticalCenter
178+ anchors.verticalCenter: parent.verticalCenter
174− }
179+ }
175
180
176− // FIXME these need to be made interactive and connected to the scope
181+ // FIXME these need to be made interactive and connected to the scope
177− RatingStars {
182+ RatingStars {
178− anchors.right: parent.right
183+ anchors.right: parent.right
179− anchors.verticalCenter: parent.verticalCenter
184+ anchors.verticalCenter: parent.verticalCenter
185+ }
180 }
186 }
181− }
182
187
183− ListItem.ThinDivider {}
188+ ListItem.ThinDivider { }
184
189
185− AppReviews {
190+ AppReviews {
186− objectName: "appReviews"
191+ objectName: "appReviews"
187− anchors { left: parent.left; right: parent.right }
192+ anchors { left: parent.left; right: parent.right }
188
193
189− model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
194+ model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
190
195
191− onSendReview: root.sendUserReview(review);
196+ onSendReview: root.sendUserReview(review);
197+ }
192 }
198 }
193−
194 }
199 }
195}
200}
tests/qmltests/Dash/Apps/tst_AppPreview.qml+17−3
@@ -35,7 +35,7 @@ Item {
35
35
36 property string commentary: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus a mi vitae augue rhoncus lobortis ut rutrum metus. Curabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh.";
36 property string commentary: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus a mi vitae augue rhoncus lobortis ut rutrum metus. Curabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh.";
37 QtObject { id: screenshots; property var value: ["fake_image1.png", "fake_image2.png", "fake_image3.png"] }
37 QtObject { id: screenshots; property var value: ["fake_image1.png", "fake_image2.png", "fake_image3.png"] }
38− QtObject { id: rating; property int value: 8 }
38+ QtObject { id: rating; property real value: 0.8 }
39 QtObject { id: rated; property int value: 120 }
39 QtObject { id: rated; property int value: 120 }
40 QtObject { id: reviews; property int value: 8 }
40 QtObject { id: reviews; property int value: 8 }
41 QtObject { id: progress; property string value: "source" }
41 QtObject { id: progress; property string value: "source" }
@@ -51,12 +51,12 @@ Item {
51 property string title: "Unity App"
51 property string title: "Unity App"
52 property string appIcon: "fake_image.png"
52 property string appIcon: "fake_image.png"
53 property string description: "This is an Application description"
53 property string description: "This is an Application description"
54+ property real rating: rating.value
55+ property int numRatings: reviews.value
54 property var execute: root.fake_call
56 property var execute: root.fake_call
55 property var infoMap: {
57 property var infoMap: {
56 "more-screenshots": screenshots,
58 "more-screenshots": screenshots,
57− "rating": rating,
58 "rated": rated,
59 "rated": rated,
59− "reviews": reviews,
60 "comments": comments
60 "comments": comments
61 }
61 }
62 property var actions: [
62 property var actions: [
@@ -88,6 +88,7 @@ Item {
88 var reviewField = findChild(appPreview, "reviewField");
88 var reviewField = findChild(appPreview, "reviewField");
89 reviewField.focus = false;
89 reviewField.focus = false;
90 reviewField.text = "";
90 reviewField.text = "";
91+ data.rating = rating.value;
91 }
92 }
92
93
93 function test_actions() {
94 function test_actions() {
@@ -148,5 +149,18 @@ Item {
148 compare(comment, comments.value[i][3], "Comment don't match");
149 compare(comment, comments.value[i][3], "Comment don't match");
149 }
150 }
150 }
151 }
152+
153+ function test_negative_rating() {
154+ data.rating = -1.0;
155+ var rated = findChild(appPreview, "reviewsLabel");
156+ verify(rated.visible == false);
157+ var commentsArea = findChild(appPreview, "commentsArea");
158+ verify(commentsArea.visible == false);
159+ var appReviews = findChild(appPreview, "appReviews");
160+ verify(appReviews.visible == false);
161+ var buttons = findChild(appPreview, "gridButtons");
162+ verify(buttons.visible == true);
163+ }
164+
151 }
165 }
152}
166}