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 1.3
19 import "../../Components"
21 /*! \brief Preview widget for editable rating.
23 Shows a single display rating that can be switched by the user to edit mode
24 and then behaves as a rating display widget
26 The display part uses widgetData["author"], widgetData["review"] and widgetData["rating"].
28 The edit part uses the same fields as the "rating-input" widget
33 implicitHeight: display.visible ? display.implicitHeight : input.implicitHeight
37 objectName: "editButton"
41 anchors.right: parent.right
42 visible: display.visible
43 onClicked: display.visible = false
46 PreviewRatingSingleDisplay {
50 anchors.left: parent.left
51 anchors.right: editIcon.left
53 rating: widgetData["rating"] || -1
54 author: widgetData["author"] || ""
55 review: widgetData["review"] || ""
56 urlIconEmpty: widgetData["rating-icon-empty"]
57 urlIconFull: widgetData["rating-icon-full"]
58 urlIconHalf: widgetData["rating-icon-half"]
59 labelColor: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
66 visible: !display.visible
69 widgetId: root.widgetId
70 widgetData: root.widgetData
71 isCurrentPreview: root.isCurrentPreview
72 scopeStyle: root.scopeStyle
74 ratingValue: widgetData["rating"]
75 reviewText: widgetData["review"]
77 onTriggered: root.triggered(widgetId, actionId, data);