CustomProgressBar.qml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. import QtQuick 1.1
  5. import "SymbianUIConstants.js" as Constants
  6. Item {
  7. id: progressBar
  8. property int maxValue: 100 // Default maximum value
  9. property int currentValue: 0
  10. height: Constants.PROGRESSBAR_HEIGHT
  11. // The background rectangle of the progress bar
  12. Rectangle {
  13. height: Constants.PROGRESSBAR_BASE_HEIGHT
  14. anchors {
  15. left: parent.left
  16. right: parent.right
  17. verticalCenter: parent.verticalCenter
  18. }
  19. gradient: Gradient {
  20. GradientStop { position: 0.0; color: "transparent" }
  21. GradientStop { position: 0.5; color: "gray" }
  22. GradientStop { position: 1.0; color: "transparent" }
  23. }
  24. }
  25. // The actual progressing bar
  26. Rectangle {
  27. width: {
  28. if (currentValue <= maxValue) {
  29. return parent.width * (currentValue / maxValue)
  30. }
  31. return parent.width
  32. }
  33. height: Constants.PROGRESSBAR_HEIGHT
  34. anchors {
  35. left: parent.left
  36. verticalCenter: parent.verticalCenter
  37. }
  38. gradient: Gradient {
  39. GradientStop { position: 0.0; color: "transparent" }
  40. GradientStop { position: 0.5; color: "white" }
  41. GradientStop { position: 1.0; color: "transparent" }
  42. }
  43. Behavior on width { SmoothedAnimation { } }
  44. }
  45. }