on xenial help sign in
Renamed and moved to textarea
82996dfAndrea Cimitan
qml/Dash/Previews/PreviewRating.qml+11−9
@@ -36,7 +36,7 @@ import "../../Components"
36
36
37PreviewWidget {
37PreviewWidget {
38 id: root
38 id: root
39− implicitHeight: childrenRect.height
39+ implicitHeight: ratingLabelAndWidgetContainer.implicitHeight + reviewContainer.implicitHeight
40
40
41 function submit() {
41 function submit() {
42 // checks rating-input requirements
42 // checks rating-input requirements
@@ -45,9 +45,9 @@ PreviewWidget {
45 rating.value < 0) ||
45 rating.value < 0) ||
46 ((widgetData["required"] === "both" ||
46 ((widgetData["required"] === "both" ||
47 widgetData["required"] === "review") &&
47 widgetData["required"] === "review") &&
48− reviewField.text === "")) return;
48+ reviewTextArea.text === "")) return;
49
49
50− var data = {"rating": rating.value, "review": reviewField.text, "author": null};
50+ var data = {"rating": rating.value, "review": reviewTextArea.text, "author": null};
51 triggered(root.widgetId, widgetData["required"], data);
51 triggered(root.widgetId, widgetData["required"], data);
52 }
52 }
53
53
@@ -90,6 +90,7 @@ PreviewWidget {
90
90
91 Item {
91 Item {
92 id: reviewContainer
92 id: reviewContainer
93+ implicitHeight: reviewLabel.implicitHeight + reviewSubmitContainer.implicitHeight + anchors.topMargin
93
94
94 readonly property real innerMargin: units.gu(1)
95 readonly property real innerMargin: units.gu(1)
95
96
@@ -116,20 +117,21 @@ PreviewWidget {
116 }
117 }
117
118
118 Item {
119 Item {
120+ id: reviewSubmitContainer
119 anchors {
121 anchors {
120 top: reviewLabel.bottom
122 top: reviewLabel.bottom
121 left: parent.left
123 left: parent.left
122 right: parent.right
124 right: parent.right
125+ bottom: parent.bottom
123 topMargin: reviewContainer.innerMargin
126 topMargin: reviewContainer.innerMargin
124 }
127 }
125− implicitHeight: childrenRect.height
128+ implicitHeight: submitButton.implicitHeight + anchors.topMargin
126
129
127− TextField {
130+ TextArea {
128− id: reviewField
131+ id: reviewTextArea
129− objectName: "reviewField"
132+ objectName: "reviewTextArea"
130 anchors {
133 anchors {
131 top: parent.top
134 top: parent.top
132− bottom: parent.bottom
133 left: parent.left
135 left: parent.left
134 right: submitButton.left
136 right: submitButton.left
135 rightMargin: reviewContainer.innerMargin
137 rightMargin: reviewContainer.innerMargin
@@ -141,7 +143,7 @@ PreviewWidget {
141 objectName: "submitButton"
143 objectName: "submitButton"
142
144
143 readonly property bool readyToSubmit: {
145 readonly property bool readyToSubmit: {
144− if (reviewField.text === "" ||
146+ if (reviewTextArea.text === "" ||
145 (widgetData["visible"] === "both" && rating.value < 0)) return false;
147 (widgetData["visible"] === "both" && rating.value < 0)) return false;
146 else return true;
148 else return true;
147 }
149 }
tests/qmltests/Dash/Previews/tst_PreviewRating.qml+8−7
@@ -45,7 +45,8 @@ Rectangle {
45
45
46 PreviewRating {
46 PreviewRating {
47 id: previewRating
47 id: previewRating
48− anchors.fill: parent
48+ anchors.left: parent.left
49+ anchors.right: parent.right
49 widgetData: widgetDataBoth
50 widgetData: widgetDataBoth
50 widgetId: "previewRating"
51 widgetId: "previewRating"
51 }
52 }
@@ -60,12 +61,12 @@ Rectangle {
60 when: windowShown
61 when: windowShown
61
62
62 property var rating: findChild(previewRating, "rating")
63 property var rating: findChild(previewRating, "rating")
63− property var reviewField: findChild(previewRating, "reviewField")
64+ property var reviewTextArea: findChild(previewRating, "reviewTextArea")
64 property var submitButton: findChild(previewRating, "submitButton")
65 property var submitButton: findChild(previewRating, "submitButton")
65
66
66 function init() {
67 function init() {
67 rating.value = -1;
68 rating.value = -1;
68− reviewField.text = "";
69+ reviewTextArea.text = "";
69 }
70 }
70
71
71 function test_labels() {
72 function test_labels() {
@@ -123,9 +124,9 @@ Rectangle {
123 }
124 }
124
125
125 if (data.widgetData["visible"] !== "rating") {
126 if (data.widgetData["visible"] !== "rating") {
126− verify(reviewField.visible === true);
127+ verify(reviewTextArea.visible === true);
127
128
128− reviewField.text = data.inputText;
129+ reviewTextArea.text = data.inputText;
129 mouseClick(submitButton, submitButton.width / 2, submitButton.height / 2);
130 mouseClick(submitButton, submitButton.width / 2, submitButton.height / 2);
130 switch (data.widgetData["required"]) {
131 switch (data.widgetData["required"]) {
131 case "rating": compare(spy.count, 0); break;
132 case "rating": compare(spy.count, 0); break;
@@ -144,7 +145,7 @@ Rectangle {
144 }
145 }
145 }
146 }
146 } else {
147 } else {
147− verify(reviewField.visible === false);
148+ verify(reviewTextArea.visible === false);
148 }
149 }
149
150
150 compare(spy.count === 1, data.emitted);
151 compare(spy.count === 1, data.emitted);
@@ -166,7 +167,7 @@ Rectangle {
166
167
167 if (data.inputRating > 0) rating.value = data.inputRating;
168 if (data.inputRating > 0) rating.value = data.inputRating;
168 if (data.inputText !== "") {
169 if (data.inputText !== "") {
169− reviewField.text = data.inputText;
170+ reviewTextArea.text = data.inputText;
170 mouseClick(submitButton, submitButton.width / 2, submitButton.height / 2);
171 mouseClick(submitButton, submitButton.width / 2, submitButton.height / 2);
171 }
172 }
172
173