TextLabel.qml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. import QtQuick 1.0
  5. Rectangle {
  6. id: textLabel
  7. property alias mouseAreaEnabled: textLabelMouseArea.enabled
  8. property alias text: textLabelText.text
  9. property alias textVerticalAlignment: textLabelText.verticalAlignment
  10. property int textLeftMargin: 0
  11. property int fontPixelSize: height * 0.33
  12. signal clicked()
  13. width: 200 // Default width
  14. height: 80 // Default height
  15. radius: 5
  16. color: "transparent"
  17. border.color: textLabelMouseArea.pressed ? "red" : "white";
  18. border.width: textLabelMouseArea.pressed ? 4 : 2;
  19. smooth: true
  20. gradient: Gradient {
  21. GradientStop { position: 0.0; color: "transparent" }
  22. GradientStop { position: 0.8; color: "transparent" }
  23. GradientStop { position: 1.0; color: "#ee01e6" }
  24. }
  25. Text {
  26. id: textLabelText
  27. anchors {
  28. fill: parent
  29. leftMargin: 10 + textLabel.textLeftMargin
  30. rightMargin: 10
  31. }
  32. verticalAlignment: Text.AlignVCenter
  33. wrapMode: Text.WordWrap
  34. color: "white";
  35. font.pixelSize: textLabel.fontPixelSize
  36. font.bold: true
  37. onLinkActivated: GameEngine.openLink(link);
  38. }
  39. MouseArea {
  40. id: textLabelMouseArea
  41. anchors.fill: parent
  42. onClicked: textLabel.clicked();
  43. }
  44. }