on xenial help sign in
Merged
3fa5017Andrea Cimitan
qml/Dash/Previews/PreviewComment.qml+1
@@ -41,6 +41,7 @@ PreviewWidget {
41 source: widgetData["source"]
41 source: widgetData["source"]
42 }
42 }
43 radius: "medium"
43 radius: "medium"
44+ opacity: source.status === Image.Ready ? 1 : 0
44 visible: widgetData["source"] !== ""
45 visible: widgetData["source"] !== ""
45 }
46 }
46
47
qml/Dash/Previews/PreviewCommentInput.qml+24−41
@@ -28,56 +28,39 @@ import "../../Components"
28
28
29PreviewWidget {
29PreviewWidget {
30 id: root
30 id: root
31− implicitHeight: commentContainer.implicitHeight
31+ implicitHeight: Math.max(commentTextArea.implicitHeight, submitButton.implicitHeight)
32−
33− property alias commentText: commentTextArea.text
34
32
35 function submit() {
33 function submit() {
36 var data = { "comment": commentTextArea.text };
34 var data = { "comment": commentTextArea.text };
37 triggered(root.widgetId, "commented", data);
35 triggered(root.widgetId, "commented", data);
38 }
36 }
39
37
40− Item {
38+ TextArea {
41− id: commentContainer
39+ id: commentTextArea
42− implicitHeight: commentSubmitContainer.implicitHeight + anchors.topMargin
40+ objectName: "commentTextArea"
43−
41+ anchors {
44− readonly property real innerMargin: units.gu(1)
42+ top: parent.top
45−
43+ left: parent.left
46− anchors.fill: parent
44+ right: submitButton.left
47−
45+ rightMargin: units.gu(1)
48− Item {
46+ }
49− id: commentSubmitContainer
50− anchors.fill: parent
51− implicitHeight: commentTextArea.implicitHeight + anchors.topMargin
52−
53− TextArea {
54− id: commentTextArea
55− objectName: "commentTextArea"
56− anchors {
57− top: parent.top
58− left: parent.left
59− right: submitButton.left
60− rightMargin: commentContainer.innerMargin
61− }
62− autoSize: true
47+ autoSize: true
63− }
48+ }
64
49
65− Button {
50+ Button {
66− id: submitButton
51+ id: submitButton
67− objectName: "submitButton"
52+ objectName: "submitButton"
68
53
69− readonly property bool readyToSubmit: commentTextArea.text.trim().length > 0
54+ readonly property bool readyToSubmit: commentTextArea.text.trim().length > 0
70
55
71− anchors {
56+ anchors {
72− top: parent.top
57+ top: parent.top
73− right: parent.right
58+ right: parent.right
74− }
59+ }
75− color: readyToSubmit ? Theme.palette.selected.base : Theme.palette.normal.base
60+ color: readyToSubmit ? Theme.palette.selected.base : Theme.palette.normal.base
76− text: widgetData["submit-label"] || i18n.tr("Send")
61+ text: widgetData["submit-label"] || i18n.tr("Send")
77− onClicked: {
62+ onClicked: {
78− if (readyToSubmit) root.submit()
63+ if (readyToSubmit) root.submit()
79− }
80− }
81 }
64 }
82 }
65 }
83}
66}
tests/qmltests/Dash/Previews/tst_PreviewCommentInput.qml+3−3
@@ -26,8 +26,6 @@ Rectangle {
26 height: units.gu(80)
26 height: units.gu(80)
27 color: Theme.palette.selected.background
27 color: Theme.palette.selected.background
28
28
29− property real validInputRating: 1
30− property real invalidInputRating: -1
31 property string validInputText: "Great!"
29 property string validInputText: "Great!"
32 property string invalidInputText: ""
30 property string invalidInputText: ""
33
31
@@ -75,10 +73,12 @@ Rectangle {
75
73
76 commentTextArea.text = data.inputText;
74 commentTextArea.text = data.inputText;
77 mouseClick(submitButton);
75 mouseClick(submitButton);
78− if (data.inputText === "") {
76+ if (!data.emitted) {
79 compare(spy.count, 0);
77 compare(spy.count, 0);
80 } else {
78 } else {
81 compare(spy.count, 1);
79 compare(spy.count, 1);
80+ var args = spy.signalArguments[0];
81+ compare(args[2]["comment"], data.inputText);
82 }
82 }
83 }
83 }
84 }
84 }