MenuBackButton.qml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import QtQuick 2.0
  2. Item {
  3. id: root
  4. signal clicked()
  5. signal back()
  6. SystemPalette {
  7. id: palette
  8. }
  9. MouseArea {
  10. id: ma
  11. anchors.fill: parent
  12. anchors.margins: -8
  13. }
  14. Rectangle {
  15. id: bar1
  16. x: 0
  17. y: root.height / 6
  18. width: root.height
  19. height: root.height / 9
  20. antialiasing: true
  21. color: palette.button
  22. }
  23. Rectangle {
  24. id: bar2
  25. x: 0
  26. y: root.height / 2 - height / 2
  27. width: root.height
  28. height: root.height / 9
  29. antialiasing: true
  30. color: palette.button
  31. }
  32. Rectangle {
  33. id: bar3
  34. x: 0
  35. y: root.height / 2 + height * 2
  36. width: root.height
  37. height: root.height / 9
  38. antialiasing: true
  39. color: palette.button
  40. }
  41. property int animationDuration: 450
  42. state: "menu"
  43. states: [
  44. State {
  45. name: "menu"
  46. PropertyChanges { target: ma; onClicked: root.clicked() }
  47. },
  48. State {
  49. name: "back"
  50. PropertyChanges { target: root; rotation: 180 }
  51. PropertyChanges { target: bar1; rotation: 45; width: root.height / 3 * 2; x: root.height / 2; y: root.height / 4 }
  52. PropertyChanges { target: bar2; width: root.height / 6 * 5 + 1; x: root.height / 9 }
  53. PropertyChanges { target: bar3; rotation: -45; width: root.height / 3 * 2; x: root.height / 2; y: root.height / 3 * 2 }
  54. PropertyChanges { target: ma; onClicked: root.back() }
  55. }
  56. ]
  57. transitions: [
  58. Transition {
  59. RotationAnimation { target: root; direction: RotationAnimation.Clockwise; duration: animationDuration; easing.type: Easing.InOutQuad }
  60. PropertyAnimation { target: bar1; properties: "rotation, width, x, y"; duration: animationDuration; easing.type: Easing.InOutQuad }
  61. PropertyAnimation { target: bar2; properties: "rotation, width, x, y"; duration: animationDuration; easing.type: Easing.InOutQuad }
  62. PropertyAnimation { target: bar3; properties: "rotation, width, x, y"; duration: animationDuration; easing.type: Easing.InOutQuad }
  63. }
  64. ]
  65. }