MenuBackButton.qml 2.5 KB

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