1
0

PatternCard.qml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. cache: false // Disable caching for linuxfb compatibility
  21. asynchronous: true // Load images asynchronously
  22. Rectangle {
  23. anchors.fill: parent
  24. color: "#f0f0f0"
  25. visible: previewImage.status === Image.Error || previewImage.source == ""
  26. Text {
  27. anchors.centerIn: parent
  28. text: "No Preview"
  29. color: "#999"
  30. }
  31. }
  32. onStatusChanged: {
  33. if (status === Image.Error) {
  34. console.log("Image load error for:", preview)
  35. }
  36. }
  37. }
  38. Label {
  39. id: nameLabel
  40. width: parent.width
  41. elide: Label.ElideRight
  42. horizontalAlignment: Label.AlignHCenter
  43. font.pixelSize: 12
  44. }
  45. }
  46. MouseArea {
  47. id: mouseArea
  48. anchors.fill: parent
  49. onClicked: parent.clicked()
  50. }
  51. }