Changeset View
Changeset View
Standalone View
Standalone View
discover/qml/Rating.qml
Show All 15 Lines | |||||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.1 | 20 | import QtQuick 2.1 | ||
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.1 | ||
22 | import org.kde.kquickcontrolsaddons 2.0 | 22 | import org.kde.kquickcontrolsaddons 2.0 | ||
23 | import org.kde.discover.app 1.0 | 23 | import org.kde.discover.app 1.0 | ||
24 | import org.kde.kirigami 2.0 as Kirigami | ||||
24 | 25 | | |||
25 | RowLayout | 26 | RowLayout | ||
26 | { | 27 | { | ||
27 | id: view | 28 | id: view | ||
28 | property bool editable: false | 29 | property bool editable: false | ||
29 | property int max: 10 | 30 | property int max: 10 | ||
30 | property int rating: 2 | 31 | property int rating: 2 | ||
31 | property real starSize: SystemFonts.generalFont.pointSize*2 | 32 | property real starSize: SystemFonts.generalFont.pointSize*2 | ||
32 | 33 | | |||
33 | clip: true | 34 | clip: true | ||
34 | spacing: 0 | 35 | spacing: 0 | ||
35 | 36 | | |||
36 | readonly property var ratingIndex: (theRepeater.count/view.max)*view.rating | 37 | readonly property var ratingIndex: (theRepeater.count/view.max)*view.rating | ||
37 | 38 | | |||
38 | Repeater { | 39 | Repeater { | ||
39 | id: theRepeater | 40 | id: theRepeater | ||
40 | model: view.rating>0 ? 5 : 0 | 41 | model: view.rating>0 ? 5 : 0 | ||
41 | delegate: QIconItem { | 42 | delegate: Kirigami.Icon { | ||
42 | Layout.minimumWidth: view.starSize | 43 | Layout.minimumWidth: view.starSize | ||
43 | Layout.minimumHeight: view.starSize | 44 | Layout.minimumHeight: view.starSize | ||
44 | Layout.preferredWidth: view.starSize | 45 | Layout.preferredWidth: view.starSize | ||
45 | Layout.preferredHeight: view.starSize | 46 | Layout.preferredHeight: view.starSize | ||
46 | 47 | | |||
47 | width: height | 48 | width: height | ||
48 | icon: "rating" | 49 | source: "rating" | ||
49 | opacity: (view.editable && mouse.item.containsMouse ? 0.7 | 50 | opacity: (view.editable && mouse.item.containsMouse ? 0.7 | ||
50 | : index>=view.ratingIndex ? 0.2 | 51 | : index>=view.ratingIndex ? 0.2 | ||
51 | : 1) | 52 | : 1) | ||
52 | 53 | | |||
53 | ConditionalLoader { | 54 | ConditionalLoader { | ||
54 | id: mouse | 55 | id: mouse | ||
55 | 56 | | |||
56 | anchors.fill: parent | 57 | anchors.fill: parent | ||
Show All 10 Lines |