button.qml 995 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. import Qt 4.7
  5. Item {
  6. id: button
  7. property alias source: image.source
  8. signal clicked
  9. width: 50; height: 50
  10. Image {
  11. id: image
  12. anchors.centerIn: parent
  13. // the user must set the source property
  14. // source: "closemark.png"
  15. Behavior on opacity { NumberAnimation { duration: 2000; easing.type: "OutExpo" } }
  16. opacity: 0.5
  17. }
  18. SequentialAnimation {
  19. id: pressAnimation
  20. PropertyAnimation { target: button; properties: "scale"; to: 0.9; duration: 100 }
  21. ParallelAnimation {
  22. PropertyAnimation { target: button; properties: "scale"; to: 1.0; duration: 100 }
  23. ScriptAction { script: button.clicked() }
  24. }
  25. }
  26. MouseArea {
  27. anchors.fill: parent
  28. //hoverEnabled: true
  29. onClicked: { pressAnimation.start() }
  30. //onEntered: { image.opacity = 1 }
  31. //onExited: { image.opacity = 0.5 }
  32. }
  33. }