main.qml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import QtQuick 2.0
  2. import "QUItBatteryComponent"
  3. Item {
  4. id: mainView
  5. width: 1280
  6. height: 720
  7. Image {
  8. anchors.fill: parent
  9. source: "images/background2.jpg"
  10. }
  11. Image {
  12. anchors.horizontalCenter: parent.horizontalCenter
  13. y: 10
  14. scale: mainView.width / 840
  15. source: "images/title.png"
  16. }
  17. QUItBattery {
  18. id: battery
  19. anchors.centerIn: parent
  20. value: slider.value
  21. charging: chargingToggle.checked
  22. maxLiquidRotation: liquidToggle.checked ? 50 : 0
  23. rotation: -90
  24. SequentialAnimation on rotation {
  25. running: rotateToggle.checked
  26. loops: Animation.Infinite
  27. NumberAnimation { to: -120; duration: 2000; easing.type: Easing.InOutQuad }
  28. NumberAnimation { to: -70; duration: 1000; easing.type: Easing.InOutQuad }
  29. }
  30. }
  31. NumberAnimation {
  32. id: rotateBackAnimation
  33. target: battery
  34. property: "rotation"
  35. to: -90
  36. duration: 3000
  37. easing.type: Easing.OutElastic
  38. }
  39. Image {
  40. anchors.horizontalCenter: parent.horizontalCenter
  41. y: 80
  42. source: "images/arrows.png"
  43. opacity: !rotateToggle.checked
  44. Behavior on opacity {
  45. NumberAnimation { duration: 400; easing.type: Easing.InOutQuad }
  46. }
  47. MouseArea {
  48. anchors.centerIn: parent
  49. width: battery.width
  50. height: 200
  51. enabled: !rotateToggle.checked
  52. onPositionChanged: {
  53. battery.rotation = (mouseX - width*0.5)*0.2 - 90
  54. }
  55. onReleased: {
  56. rotateBackAnimation.start();
  57. }
  58. onCanceled: {
  59. rotateBackAnimation.start();
  60. }
  61. onPressed: {
  62. rotateBackAnimation.stop();
  63. }
  64. }
  65. }
  66. Row {
  67. anchors.horizontalCenter: parent.horizontalCenter
  68. anchors.bottom: parent.bottom
  69. anchors.bottomMargin: 8
  70. spacing: 16
  71. Slider {
  72. id: slider
  73. width: 300
  74. text: "- Battery Level +"
  75. value: 0.5
  76. }
  77. ToggleButton {
  78. id: chargingToggle
  79. icon: "images/plug.png"
  80. }
  81. ToggleButton {
  82. id: liquidToggle
  83. icon: "images/glass.png"
  84. }
  85. ToggleButton {
  86. id: rotateToggle
  87. icon: "images/rotate.png"
  88. }
  89. }
  90. }