1
0

PatternCard.qml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. Rectangle {
  4. property alias name: nameLabel.text
  5. property alias preview: previewImage.source
  6. signal clicked()
  7. color: mouseArea.pressed ? "#e0e0e0" : "#f5f5f5"
  8. radius: 8
  9. border.color: "#d0d0d0"
  10. Column {
  11. anchors.fill: parent
  12. anchors.margins: 10
  13. spacing: 10
  14. Image {
  15. id: previewImage
  16. width: parent.width
  17. height: parent.height - nameLabel.height - 10
  18. fillMode: Image.PreserveAspectFit
  19. source: preview ? "file:///" + preview : ""
  20. Rectangle {
  21. anchors.fill: parent
  22. color: "#f0f0f0"
  23. visible: previewImage.status === Image.Error || previewImage.source == ""
  24. Text {
  25. anchors.centerIn: parent
  26. text: "No Preview"
  27. color: "#999"
  28. }
  29. }
  30. }
  31. Label {
  32. id: nameLabel
  33. width: parent.width
  34. elide: Label.ElideRight
  35. horizontalAlignment: Label.AlignHCenter
  36. font.pixelSize: 12
  37. }
  38. }
  39. MouseArea {
  40. id: mouseArea
  41. anchors.fill: parent
  42. onClicked: parent.clicked()
  43. }
  44. }