Merge lp:~mzanetti/unity8/previewcommentinput into lp:unity8

Proposed by Michael Zanetti
Status: Superseded
Proposed branch: lp:~mzanetti/unity8/previewcommentinput
Merge into: lp:unity8
Diff against target: 212 lines (+170/-0)
5 files modified
qml/Dash/Previews/PreviewCommentInput.qml (+82/-0)
qml/Dash/Previews/PreviewWidgetFactory.qml (+1/-0)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Dash/Previews/tst_PreviewCommentInput.qml (+85/-0)
tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml (+1/-0)
To merge this branch: bzr merge lp:~mzanetti/unity8/previewcommentinput
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Andrea Cimitan (community) Needs Fixing
Review via email: mp+260719@code.launchpad.net

This proposal has been superseded by a proposal from 2015-06-25.

Commit message

Implements a comment input widget

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.

no

 * Did you perform an exploratory manual test run of your code change and any related functionality?

yes

 * Did you make sure that your branch does not contain spurious tags?

yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

n/a

 * If you changed the UI, has there been a design review?

added a new component as per visual spec.

 * Did you have a look at the warnings when running tests? Can they be reduced?

yes. only the old Theme.palette thing.

To post a comment you must log in.
1794. By Michael Zanetti

update doc

1795. By Michael Zanetti

rename the widget property from "comment" to "comment-input"

Revision history for this message
Andrea Cimitan (cimi) :
review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1796. By Michael Zanetti

fix issues from review

Revision history for this message
Michael Zanetti (mzanetti) wrote :

Addressed all comments. Thanks.

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

Minor optimizations/coding style issues, see inline comments

1797. By Michael Zanetti

simplify anchoring

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Minor optimizations/coding style issues, see inline comments

fixed.

1798. By Michael Zanetti

simplify further

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) wrote :

Add this file to the test in previewwidgetfactory

review: Needs Fixing
1799. By Michael Zanetti

hook it up to tst_PreviewWidgetFactory

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Add this file to the test in previewwidgetfactory

done

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in tests/qmltests/CMakeLists.txt
1 conflicts encountered.

1800. By Michael Zanetti

merge trunk

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Text conflict in tests/qmltests/CMakeLists.txt
> 1 conflicts encountered.

merged

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'qml/Dash/Previews/PreviewCommentInput.qml'
2--- qml/Dash/Previews/PreviewCommentInput.qml 1970-01-01 00:00:00 +0000
3+++ qml/Dash/Previews/PreviewCommentInput.qml 2015-06-23 13:40:34 +0000
4@@ -0,0 +1,82 @@
5+/*
6+ * Copyright (C) 2015 Canonical, Ltd.
7+ *
8+ * This program is free software; you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License as published by
10+ * the Free Software Foundation; version 3.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21+import QtQuick 2.0
22+import Ubuntu.Components 1.1
23+import "../../Components"
24+
25+/*! \brief Preview widget for commenting.
26+
27+ The widget can show a field to enter a comment.
28+ It is possible to customise the submit button's label by setting widgetData["submit-label"]
29+ The successeful submit emits triggered(widgetId, "commented", data),
30+ with data being {"comment": comment}.
31+*/
32+
33+PreviewWidget {
34+ id: root
35+ implicitHeight: commentContainer.implicitHeight
36+
37+ property alias commentText: commentTextArea.text
38+
39+ function submit() {
40+ var data = { "comment": commentTextArea.text };
41+ triggered(root.widgetId, "commented", data);
42+ }
43+
44+ Item {
45+ id: commentContainer
46+ implicitHeight: commentSubmitContainer.implicitHeight + anchors.topMargin
47+
48+ readonly property real innerMargin: units.gu(1)
49+
50+ anchors.fill: parent
51+
52+ Item {
53+ id: commentSubmitContainer
54+ anchors.fill: parent
55+ implicitHeight: commentTextArea.implicitHeight + anchors.topMargin
56+
57+ TextField {
58+ id: commentTextArea
59+ objectName: "commentTextArea"
60+ anchors {
61+ top: parent.top
62+ left: parent.left
63+ right: submitButton.left
64+ rightMargin: commentContainer.innerMargin
65+ }
66+ }
67+
68+ Button {
69+ id: submitButton
70+ objectName: "submitButton"
71+
72+ readonly property bool readyToSubmit: commentTextArea.text.trim().length > 0
73+
74+ anchors {
75+ top: parent.top
76+ right: parent.right
77+ }
78+ color: readyToSubmit ? Theme.palette.selected.base : Theme.palette.normal.base
79+ text: widgetData["submit-label"] || i18n.tr("Send")
80+ onClicked: {
81+ if (readyToSubmit) root.submit()
82+ }
83+ }
84+ }
85+ }
86+}
87
88=== modified file 'qml/Dash/Previews/PreviewWidgetFactory.qml'
89--- qml/Dash/Previews/PreviewWidgetFactory.qml 2015-05-08 13:12:02 +0000
90+++ qml/Dash/Previews/PreviewWidgetFactory.qml 2015-06-23 13:40:34 +0000
91@@ -62,6 +62,7 @@
92 case "table": return "PreviewTable.qml";
93 case "text": return "PreviewTextSummary.qml";
94 case "video": return "PreviewVideoPlayback.qml";
95+ case "comment-input": return "PreviewCommentInput.qml";
96 default: return "";
97 }
98 }
99
100=== modified file 'tests/qmltests/CMakeLists.txt'
101--- tests/qmltests/CMakeLists.txt 2015-06-18 19:23:08 +0000
102+++ tests/qmltests/CMakeLists.txt 2015-06-23 13:40:34 +0000
103@@ -27,6 +27,7 @@
104 add_unity8_qmltest(Dash/Previews Preview)
105 add_unity8_qmltest(Dash/Previews PreviewActions)
106 add_unity8_qmltest(Dash/Previews PreviewAudioPlayback)
107+add_unity8_qmltest(Dash/Previews PreviewCommentInput)
108 add_unity8_qmltest(Dash/Previews PreviewExpandable)
109 add_unity8_qmltest(Dash/Previews PreviewHeader)
110 add_unity8_qmltest(Dash/Previews PreviewImageGallery)
111
112=== added file 'tests/qmltests/Dash/Previews/tst_PreviewCommentInput.qml'
113--- tests/qmltests/Dash/Previews/tst_PreviewCommentInput.qml 1970-01-01 00:00:00 +0000
114+++ tests/qmltests/Dash/Previews/tst_PreviewCommentInput.qml 2015-06-23 13:40:34 +0000
115@@ -0,0 +1,85 @@
116+/*
117+ * Copyright 2015 Canonical Ltd.
118+ *
119+ * This program is free software; you can redistribute it and/or modify
120+ * it under the terms of the GNU General Public License as published by
121+ * the Free Software Foundation; version 3.
122+ *
123+ * This program is distributed in the hope that it will be useful,
124+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
125+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
126+ * GNU General Public License for more details.
127+ *
128+ * You should have received a copy of the GNU General Public License
129+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
130+ */
131+
132+import QtQuick 2.0
133+import QtTest 1.0
134+import Ubuntu.Components 1.1
135+import "../../../../qml/Dash/Previews"
136+import Unity.Test 0.1 as UT
137+
138+Rectangle {
139+ id: root
140+ width: units.gu(40)
141+ height: units.gu(80)
142+ color: Theme.palette.selected.background
143+
144+ property real validInputRating: 1
145+ property real invalidInputRating: -1
146+ property string validInputText: "Great!"
147+ property string invalidInputText: ""
148+
149+ property var widgetDataNewLabels: { "submit-label": "TestSubmitLabel" }
150+
151+ PreviewCommentInput {
152+ id: previewCommentInput
153+ anchors.left: parent.left
154+ anchors.right: parent.right
155+ widgetData: widgetDataNewLabels
156+ widgetId: "previewCommentInput"
157+ }
158+
159+ SignalSpy {
160+ id: spy
161+ signalName: "triggered"
162+ }
163+
164+ UT.UnityTestCase {
165+ name: "PreviewCommentInputTest"
166+ when: windowShown
167+
168+ property var commentTextArea: findChild(previewCommentInput, "commentTextArea")
169+ property var submitButton: findChild(previewCommentInput, "submitButton")
170+
171+ function init() {
172+ commentTextArea.text = "";
173+ }
174+
175+ function test_labels() {
176+ previewCommentInput.widgetData = widgetDataNewLabels;
177+ compare(submitButton.text, widgetDataNewLabels["submit-label"]);
178+ }
179+
180+ function test_submit_data() {
181+ return [
182+ {tag: "empty review", inputText: invalidInputText, emitted: false},
183+ {tag: "filled review", inputText: validInputText, emitted: true},
184+ ];
185+ }
186+
187+ function test_submit(data) {
188+ spy.clear();
189+ spy.target = previewCommentInput;
190+
191+ commentTextArea.text = data.inputText;
192+ mouseClick(submitButton);
193+ if (data.inputText === "") {
194+ compare(spy.count, 0);
195+ } else {
196+ compare(spy.count, 1);
197+ }
198+ }
199+ }
200+}
201
202=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml'
203--- tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2014-08-26 19:21:31 +0000
204+++ tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2015-06-23 13:40:34 +0000
205@@ -77,6 +77,7 @@
206 return [
207 { tag: "Actions", type: "actions", source: "PreviewActions.qml" },
208 { tag: "Audio", type: "audio", source: "PreviewAudioPlayback.qml" },
209+ { tag: "Comment Input", type: "comment-input", source: "PreviewCommentInput.qml" },
210 { tag: "Expandable", type: "expandable", source: "PreviewExpandable.qml" },
211 { tag: "Gallery", type: "gallery", source: "PreviewImageGallery.qml" },
212 { tag: "Header", type: "header", source: "PreviewHeader.qml" },

Subscribers

People subscribed via source and target branches