on xenial help sign in
Hide rating widgets when scope provides rating set to < 0.0.

Also fallback to regular preview image if there are no more_screenshots specified. Approved by Michał Sawicz, PS Jenkins bot.

commit2d8a97d2025d517366a316eb1c7e68ba4fe21d4a authorMichal Hruby <michal.mhr@gmail.com> dateMon 19 Aug 2013, 20:52 (13 years ago) parentfc62c983b35a59
3 files changed+55−35
Dash/Apps/AppInfo.qml+1 Dash/Apps/AppPreview.qml+37−32 tests/qmltests/Dash/Apps/tst_AppPreview.qml+17−3
Dash/Apps/AppInfo.qml+1
@@ -53,6 +53,7 @@ Row {
5353 }
5454
5555 Row {
56+ visible: root.rating >= 0
5657 spacing: units.gu(1)
5758
5859 RatingStars {
Dash/Apps/AppPreview.qml+37−32
@@ -38,7 +38,7 @@ DashPreview {
3838 right: parent.right
3939 margins: units.gu(1)
4040 }
41− model: previewData.infoMap["more-screenshots"].value
41+ model: previewData.infoMap["more-screenshots"] != null ? previewData.infoMap["more-screenshots"].value : [previewData.image]
4242
4343 delegate: UbuntuShape {
4444 id: shape
@@ -138,9 +138,9 @@ DashPreview {
138138
139139 appName: root.previewData.title
140140 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
142143 rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
143− reviews: root.previewData.infoMap["reviews"] ? root.previewData.infoMap["reviews"].value : 0
144144 }
145145
146146 Label {
@@ -154,42 +154,47 @@ DashPreview {
154154 styleColor: "black"
155155 }
156156
157− ListItem.ThinDivider {}
158−
159− Item {
157+ Column {
158+ visible: root.previewData.rating >= 0
160159 anchors { left: parent.left; right: parent.right }
161− height: rateLabel.height
162−
163− Label {
164− id: rateLabel
165− fontSize: "medium"
166− color: "white"
167− style: Text.Raised
168− styleColor: "black"
169− opacity: .9
170− text: i18n.tr("Rate this")
171−
172− anchors.left: parent.left
173− anchors.verticalCenter: parent.verticalCenter
174− }
160+ spacing: parent.spacing
161+
162+ ListItem.ThinDivider { }
163+
164+ Item {
165+ anchors { left: parent.left; right: parent.right }
166+ height: rateLabel.height
167+
168+ Label {
169+ id: rateLabel
170+ fontSize: "medium"
171+ color: "white"
172+ style: Text.Raised
173+ styleColor: "black"
174+ opacity: .9
175+ text: i18n.tr("Rate this")
176+
177+ anchors.left: parent.left
178+ anchors.verticalCenter: parent.verticalCenter
179+ }
175180
176− // FIXME these need to be made interactive and connected to the scope
177− RatingStars {
178− anchors.right: parent.right
179− anchors.verticalCenter: parent.verticalCenter
181+ // FIXME these need to be made interactive and connected to the scope
182+ RatingStars {
183+ anchors.right: parent.right
184+ anchors.verticalCenter: parent.verticalCenter
185+ }
180186 }
181− }
182187
183− ListItem.ThinDivider {}
188+ ListItem.ThinDivider { }
184189
185− AppReviews {
186− objectName: "appReviews"
187− anchors { left: parent.left; right: parent.right }
190+ AppReviews {
191+ objectName: "appReviews"
192+ anchors { left: parent.left; right: parent.right }
188193
189− model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
194+ model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
190195
191− onSendReview: root.sendUserReview(review);
196+ onSendReview: root.sendUserReview(review);
197+ }
192198 }
193−
194199 }
195200}
tests/qmltests/Dash/Apps/tst_AppPreview.qml+17−3
@@ -35,7 +35,7 @@ Item {
3535
3636 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.";
3737 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 }
3939 QtObject { id: rated; property int value: 120 }
4040 QtObject { id: reviews; property int value: 8 }
4141 QtObject { id: progress; property string value: "source" }
@@ -51,12 +51,12 @@ Item {
5151 property string title: "Unity App"
5252 property string appIcon: "fake_image.png"
5353 property string description: "This is an Application description"
54+ property real rating: rating.value
55+ property int numRatings: reviews.value
5456 property var execute: root.fake_call
5557 property var infoMap: {
5658 "more-screenshots": screenshots,
57− "rating": rating,
5859 "rated": rated,
59− "reviews": reviews,
6060 "comments": comments
6161 }
6262 property var actions: [
@@ -88,6 +88,7 @@ Item {
8888 var reviewField = findChild(appPreview, "reviewField");
8989 reviewField.focus = false;
9090 reviewField.text = "";
91+ data.rating = rating.value;
9192 }
9293
9394 function test_actions() {
@@ -148,5 +149,18 @@ Item {
148149 compare(comment, comments.value[i][3], "Comment don't match");
149150 }
150151 }
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+
151165 }
152166}