AbstractProgressIndicator.qml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import QtQuick 2.0
  2. /* This is the API definition of ProgressIndicator.
  3. */
  4. Item {
  5. id: root
  6. /* This property defines the size of ProgressIndicator.
  7. small = (64x64px)
  8. medium = (128x128px) (Default)
  9. large = (256x256px)
  10. huge = (512x512px)
  11. */
  12. property string size: "medium"
  13. /* This property defines if indicator animations are running or not
  14. */
  15. property bool running: true
  16. /* This property holds the current value of ProgressIndicator.
  17. Value should be between 0 (0%) and 1 (100%).
  18. */
  19. property real value: 0
  20. /* This property defines if percentages text is shown or not.
  21. Default is true
  22. */
  23. property bool showPercentages: true
  24. /* This property defines if indicator will be automatically hidden
  25. when it's not running anymore. Alternatively, call hide() method
  26. when you want to hide the indicator. Default is true.
  27. */
  28. property bool hidesWhenStopped: true;
  29. /* This property defines the color used for highlighting progress.
  30. Default is yellowish.
  31. */
  32. property color highlightColor: "#ffff40"
  33. /* This property inverts indicator colors.
  34. Inverted might work better on white backgrounds.
  35. Note: All indicators might not have separate inverted theming.
  36. So inverted indicator may look same as non-inverted one.
  37. */
  38. property bool invertedTheme: false
  39. /* This function animates indicator to visible */
  40. function show() {
  41. priv.__isHidden = false;
  42. if (hideAnimation.running) hideAnimation.stop();
  43. showAnimation.restart();
  44. }
  45. /* This function animates indicator to hidden */
  46. function hide() {
  47. if (showAnimation.running) showAnimation.stop();
  48. hideAnimation.restart();
  49. }
  50. /* ************************************* */
  51. /*! \internal */
  52. property alias priv: priv
  53. Component.onCompleted: {
  54. showAnimation.start();
  55. }
  56. onRunningChanged: {
  57. if (hidesWhenStopped) {
  58. if (!running) {
  59. hide();
  60. } else {
  61. show();
  62. }
  63. }
  64. }
  65. onSizeChanged: {
  66. if (size === "small") {
  67. priv.__pixelSize = 64;
  68. } else if (size === "medium") {
  69. priv.__pixelSize = 128;
  70. } else if (size === "large") {
  71. priv.__pixelSize = 256;
  72. } else if (size === "huge") {
  73. priv.__pixelSize = 512;
  74. }
  75. }
  76. QtObject {
  77. id: priv
  78. property real __value: Math.max(0,Math.min(1, value));
  79. property bool __isHidden: false
  80. property int __pixelSize: 128
  81. }
  82. }