MessageProgress.qml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. import QtQuick 1.0
  5. Item {
  6. id: message
  7. smooth: true
  8. opacity: 0
  9. function showMessageOngoing(text)
  10. {
  11. clear();
  12. textLabel.border.color = "white";
  13. message.width = gameArea.xDim - 10;
  14. message.height = gameArea.yDim * 0.1;
  15. textLabel.text = text;
  16. textLabel.fontPixelSize = message.height * 0.33;
  17. ongoingMessageAnim.restart();
  18. }
  19. function showMessageProgress(received, total)
  20. {
  21. if (message.opacity>0){
  22. progressBar.opacity = 1;
  23. progressBar.value = received;
  24. if (total!=-1)
  25. progressBar.maximum = total;
  26. else
  27. progressBar.maximum = 2000000;
  28. if (progressBar.value > progressBar.maximum)
  29. progressBar.maximum = progressBar.maximum * 1.2
  30. progressBar.color = "blue";
  31. progressBar.secondColor = "white";
  32. if (received==total) {
  33. textLabel.text = "Downloaded";
  34. }
  35. }
  36. }
  37. function hideOngoingMessage()
  38. {
  39. clear();
  40. }
  41. function clear()
  42. {
  43. ongoingMessageAnim.stop();
  44. message.opacity = 0;
  45. }
  46. SequentialAnimation {
  47. id: ongoingMessageAnim
  48. loops: Animation.Infinite
  49. PropertyAction { target: message; properties: "opacity"; value: 1 }
  50. PropertyAction { target: message; properties: "x";
  51. value: (gameArea.xDim - message.width) * 0.5 }
  52. PropertyAction { target: message; properties: "y";
  53. value: gameArea.yDim - message.height - 5 }
  54. PropertyAnimation {
  55. target: message
  56. property: "opacity"
  57. from: 0.5; to: 1
  58. duration: 2000
  59. }
  60. PropertyAnimation {
  61. target: message
  62. property: "opacity"
  63. from: 1; to: 0.5
  64. duration: 2000
  65. }
  66. }
  67. TextLabel {
  68. id: textLabel
  69. anchors.fill: parent
  70. opacity: 1
  71. border.color: "black"
  72. gradient: Gradient {
  73. GradientStop { position: 0.0; color: "transparent" }
  74. GradientStop { position: 0.6; color: "black" }
  75. GradientStop { position: 0.8; color: "black" }
  76. GradientStop { position: 1.0; color: "#ee01e6" }
  77. }
  78. mouseAreaEnabled: false
  79. textVerticalAlignment: Text.AlignVCenter
  80. }
  81. ProgressBar {
  82. id: progressBar
  83. opacity: 0
  84. width: textLabel.width
  85. height: 20
  86. anchors.bottom: textLabel.bottom
  87. anchors.left: textLabel.left
  88. }
  89. }