on xenial help sign in
Readded old component
commit59127cf56a3130eefdb91c1dc31e1fd9239cfd0c authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 14 Feb 2014, 10:14 (13 years ago) parentfbac9ca
4 files changed+23−7
qml/Components/RatingStars.qml+22−7 qml/Components/graphics/icon_star_off@20.png qml/Components/graphics/icon_star_on@20.png tests/qmltests/CMakeLists.txt+1
qml/Components/RatingStars.qml+22−7
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2013 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -16,11 +16,26 @@
1616
1717import QtQuick 2.0
1818
19−// FIXME this goes away when new scopes go in: compatibility layer with old RatingStars widget
20−
21−Rating {
19+Row {
2220 id: root
23− property alias rating: root.value
24− property alias maximumRating: root.maximumValue
25− property alias starCount: root.size
21+ property int rating
22+ property int maximumRating: 5
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+ }
2641}
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")
1414add_qml_test(Components AnimationControllerWithSignals)
1515add_qml_test(Components Carousel)
1616add_qml_test(Components OpenEffect)
17+add_qml_test(Components RatingStars)
1718add_qml_test(Panel IndicatorItem)
1819add_qml_test(utils/Unity/Test UnityTest)
1920