SmallRatingWidget.qml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import QtQuick 2.3
  2. import QtQuick.Controls 1.4
  3. import UM 1.1 as UM
  4. import Cura 1.1 as Cura
  5. Row
  6. {
  7. id: rating
  8. height: UM.Theme.getSize("rating_star").height
  9. visible: model.average_rating > 0 //Has a rating at all.
  10. spacing: UM.Theme.getSize("thick_lining").width
  11. width: starIcon.width + spacing + numRatingsLabel.width
  12. UM.RecolorImage
  13. {
  14. id: starIcon
  15. source: UM.Theme.getIcon("star_filled")
  16. color: model.user_rating == 0 ? UM.Theme.getColor("rating_star") : UM.Theme.getColor("primary")
  17. height: UM.Theme.getSize("rating_star").height
  18. width: UM.Theme.getSize("rating_star").width
  19. sourceSize.height: height
  20. sourceSize.width: width
  21. }
  22. Label
  23. {
  24. id: numRatingsLabel
  25. text: model.average_rating != undefined ? model.average_rating.toFixed(1) + " (" + model.num_ratings + " " + catalog.i18nc("@label", "ratings") + ")": ""
  26. verticalAlignment: Text.AlignVCenter
  27. height: starIcon.height
  28. width: contentWidth
  29. anchors.verticalCenter: starIcon.verticalCenter
  30. color: starIcon.color
  31. font: UM.Theme.getFont("default")
  32. renderType: Text.NativeRendering
  33. }
  34. }