Button.qml 907 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. import Qt 4.7
  5. Rectangle {
  6. id: container
  7. property string text: "Button"
  8. signal clicked
  9. width: buttonLabel.width + 20; height: buttonLabel.height + 10
  10. smooth: true
  11. border { width: 1; color: Qt.darker(activePalette.button) }
  12. radius: 8
  13. color: activePalette.button
  14. gradient: Gradient {
  15. GradientStop {
  16. position: 0.0
  17. color: {
  18. if (mouseArea.pressed)
  19. return activePalette.dark
  20. else
  21. return activePalette.light
  22. }
  23. }
  24. GradientStop { position: 1.0; color: activePalette.button }
  25. }
  26. MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
  27. Text {
  28. id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
  29. }
  30. }