@@ -0,0 +1,103 @@
2+ * Copyright (C) 2015 Canonical, Ltd.
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+import Ubuntu.Components 0.1
19+import "../../Components"
21+/*! \brief Preview widget for rating.
23+ The widget can show a rating widget and a field to enter a comment.
24+ The visibility of the two widgets is specified by widgetData["visible"],
25+ accepting "both", "rating" or "review".
26+ The requirement of the review is specified by widgetData["visible"],
27+ accepting "both", "rating" or "review".
28+ It is possible to customise labels, widgetData["rating-label"] for the rating,
29+ widgetData["rewiew-label"] for the comment field and widgetData["submit-label"]
30+ for the submit button.
31+ The icons used in the rating widget can be customised with
32+ widgetData["rating-icon-empty"] and widgetData["rating-icon-full"].
33+ The successeful submit emits triggered(widgetId, widgetData["required"], data),
34+ with data being {"rating": rating value, "review": review comment, "author": null (for now)}.
39+ implicitHeight: commentContainer.implicitHeight
41+ property alias commentText: commentTextArea.text
44+ // checks if comment text area actually contains something
45+ if (commentTextArea.text === "") return;
47+ var data = { "comment": commentTextArea.text };
48+ triggered(root.widgetId, "commented", data);
53+ implicitHeight: commentSubmitContainer.implicitHeight + anchors.topMargin
55+ readonly property real innerMargin: units.gu(1)
61+ bottom: parent.bottom
65+ id: commentSubmitContainer
70+ bottom: parent.bottom
72+ implicitHeight: commentTextArea.implicitHeight + anchors.topMargin
76+ objectName: "commentTextArea"
80+ right: submitButton.left
81+ rightMargin: commentContainer.innerMargin
87+ objectName: "submitButton"
89+ readonly property bool readyToSubmit: commentTextArea.text.length > 0
95+ color: readyToSubmit ? Theme.palette.selected.base : Theme.palette.normal.base
96+ text: widgetData["submit-label"] || i18n.tr("Send")
98+ if (readyToSubmit) root.submit()