Unity 8
PreviewRatingEdit.qml
1 /*
2  * Copyright (C) 2015 Canonical, Ltd.
3  *
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.
7  *
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.
12  *
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/>.
15  */
16 
17 import QtQuick 2.4
18 import Ubuntu.Components 1.3
19 import "../../Components"
20 
21 /*! \brief Preview widget for editable rating.
22 
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
25 
26  The display part uses widgetData["author"], widgetData["review"] and widgetData["rating"].
27 
28  The edit part uses the same fields as the "rating-input" widget
29 */
30 
31 PreviewWidget {
32  id: root
33  implicitHeight: display.visible ? display.implicitHeight : input.implicitHeight
34 
35  Button {
36  id: editIcon
37  objectName: "editButton"
38 
39  iconName: "edit"
40  width: height
41  anchors.right: parent.right
42  visible: display.visible
43  onClicked: display.visible = false
44  }
45 
46  PreviewRatingSingleDisplay {
47  id: display
48  objectName: "display"
49 
50  anchors.left: parent.left
51  anchors.right: editIcon.left
52 
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
60  }
61 
62  PreviewRatingInput {
63  id: input
64  objectName: "input"
65 
66  visible: !display.visible
67  width: parent.width
68 
69  widgetId: root.widgetId
70  widgetData: root.widgetData
71  isCurrentPreview: root.isCurrentPreview
72  scopeStyle: root.scopeStyle
73 
74  ratingValue: widgetData["rating"]
75  reviewText: widgetData["review"]
76 
77  onTriggered: root.triggered(widgetId, actionId, data);
78  }
79 
80 }