@@ -40,14 +40,16 @@ PreviewWidget {
4040 switch(widgetData["visible"]) {
4141 default:
4242 case "both":
43− return ratingLabelAndWidgetContainer.implicitHeight + reviewContainer.implicitHeight;
43+ return ratingLabelAndWidgetContainer.implicitHeight + (reviewContainer.visible ? reviewContainer.implicitHeight : 0);
4444 case "rating":
4545 return ratingLabelAndWidgetContainer.implicitHeight;
4646 case "review":
4747 return reviewContainer.implicitHeight;
48− }
48+ }
4949 }
5050
51+ clip: reviewContainer.visible
52+
5153 property alias ratingValue: rating.value
5254 property alias reviewText: reviewTextArea.text
5355
@@ -64,21 +66,17 @@ PreviewWidget {
6466 triggered(root.widgetId, "rated", data);
6567 }
6668
67− Item {
69+ Column {
6870 id: ratingLabelAndWidgetContainer
69− anchors {
70− left: parent.left
71− right: parent.right
72− }
73− implicitHeight: rating.height
71+ anchors { left: parent.left; right: parent.right; }
72+ spacing: units.gu(0.5)
7473 visible: widgetData["visible"] !== "review"
7574
7675 Label {
76+ id: ratingLabel
7777 objectName: "ratingLabel"
78− anchors {
79− verticalCenter: parent.verticalCenter
80− left: parent.left
81− }
78+ anchors { left: parent.left; right: parent.right; }
79+ fontSize: "large"
8280 color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
8381 opacity: .8
8482 text: widgetData["rating-label"] || i18n.tr("Rate this")
@@ -87,23 +85,22 @@ PreviewWidget {
8785 Rating {
8886 id: rating
8987 objectName: "rating"
90− anchors {
91− verticalCenter: parent.verticalCenter
92− right: parent.right
93− }
88+ anchors.left: parent.left
9489 size: 5
90+ height: units.gu(4)
9591 onValueChanged: {
9692 if (widgetData["visible"] === "rating") root.submit();
9793 }
9894
99− property var urlIconEmpty: widgetData["rating-icon-empty"]
100− property var urlIconFull: widgetData["rating-icon-full"]
95+ property var urlIconEmpty: widgetData["rating-icon-empty"] || "image://theme/non-starred"
96+ property var urlIconFull: widgetData["rating-icon-full"] || "image://theme/starred"
10197 }
10298 }
10399
104100 Item {
105101 id: reviewContainer
106− implicitHeight: reviewLabel.implicitHeight + reviewSubmitContainer.implicitHeight + anchors.topMargin
102+ objectName: "reviewContainer"
103+ implicitHeight: visible ? reviewSubmitContainer.implicitHeight + anchors.topMargin : 0
107104
108105 readonly property real innerMargin: units.gu(1)
109106
@@ -112,32 +109,31 @@ PreviewWidget {
112109 right: parent.right
113110 top: ratingLabelAndWidgetContainer.visible ? ratingLabelAndWidgetContainer.bottom : parent.top
114111 bottom: parent.bottom
115− topMargin: ratingLabelAndWidgetContainer.visible ? reviewContainer.innerMargin : 0
112+ topMargin: ratingLabelAndWidgetContainer.visible ? innerMargin : 0
113+ }
114+ visible: {
115+ switch(widgetData["visible"]) {
116+ default:
117+ case "both":
118+ return widgetData["required"] === "review" || rating.value > 0;
119+ case "rating":
120+ return false;
121+ case "review":
122+ return true;
123+ }
116124 }
117− visible: widgetData["visible"] !== "rating"
118125
119− Label {
120− objectName: "reviewLabel"
121− id: reviewLabel
122− anchors {
123− top: parent.top
124− left: parent.left
125− right: parent.right
126+ Behavior on implicitHeight {
127+ UbuntuNumberAnimation {
128+ duration: UbuntuAnimation.FastDuration
129+ easing.type: Easing.OutCubic
126130 }
127− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
128− opacity: .8
129− text: widgetData["review-label"] || i18n.tr("Add a review")
130131 }
131132
132133 Item {
133134 id: reviewSubmitContainer
134− anchors {
135− top: reviewLabel.bottom
136− left: parent.left
137− right: parent.right
138− bottom: parent.bottom
139− topMargin: reviewContainer.innerMargin
140− }
135+ objectName: "reviewSubmitContainer"
136+ anchors.fill: parent
141137 implicitHeight: reviewTextArea.implicitHeight + anchors.topMargin
142138
143139 TextArea {
@@ -148,12 +144,17 @@ PreviewWidget {
148144 if(inputMethodVisible && activeFocus)
149145 root.makeSureVisible(reviewTextArea);
150146 }
147+ onVisibleChanged: {
148+ if (visible && widgetData["visible"] !== "review")
149+ focus = true;
150+ }
151151 anchors {
152152 top: parent.top
153153 left: parent.left
154154 right: submitButton.left
155155 rightMargin: reviewContainer.innerMargin
156156 }
157+ placeholderText: widgetData["review-label"] || i18n.tr("Add a review")
157158 }
158159
159160 Button {
@@ -170,11 +171,9 @@ PreviewWidget {
170171 top: parent.top
171172 right: parent.right
172173 }
173− color: readyToSubmit ? theme.palette.selected.base : theme.palette.normal.base
174+ enabled: readyToSubmit
174175 text: widgetData["submit-label"] || i18n.tr("Send")
175− onClicked: {
176− if (readyToSubmit) root.submit()
177− }
176+ onClicked: root.submit()
178177 }
179178 }
180179 }