on xenial help sign in
Readded old component
59127cfAndrea Cimitan
qml/Components/RatingStars.qml+22−7
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2013 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -16,11 +16,26 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18
18
19−// FIXME this goes away when new scopes go in: compatibility layer with old RatingStars widget
19+Row {
20−
21−Rating {
22 id: root
20 id: root
23− property alias rating: root.value
21+ property int rating
24− property alias maximumRating: root.maximumValue
22+ property int maximumRating: 5
25− property alias starCount: root.size
23+ property int starCount: 5
24+ height: childrenRect.height
25+ width: childrenRect.width
26+
27+ readonly property int effectiveRating: Math.max(0, Math.min(root.starCount * root.rating / root.maximumRating, root.maximumRating))
28+
29+ Repeater {
30+ model: root.effectiveRating
31+ Image {
32+ source: "graphics/icon_star_on.png"
33+ }
34+ }
35+ Repeater {
36+ model: root.starCount - root.effectiveRating
37+ Image {
38+ source: "graphics/icon_star_off.png"
39+ }
40+ }
26}
41}
qml/Components/graphics/icon_star_off@20.pngnew file

Binary file not shown.

qml/Components/graphics/icon_star_on@20.pngnew file

Binary file not shown.

tests/qmltests/CMakeLists.txt+1
@@ -14,6 +14,7 @@ set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
14add_qml_test(Components AnimationControllerWithSignals)
14add_qml_test(Components AnimationControllerWithSignals)
15add_qml_test(Components Carousel)
15add_qml_test(Components Carousel)
16add_qml_test(Components OpenEffect)
16add_qml_test(Components OpenEffect)
17+add_qml_test(Components RatingStars)
17add_qml_test(Panel IndicatorItem)
18add_qml_test(Panel IndicatorItem)
18add_qml_test(utils/Unity/Test UnityTest)
19add_qml_test(utils/Unity/Test UnityTest)
19
20