InfoCard.qml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // 通用信息卡片组件
  2. import QtQuick
  3. import Felgo 4.0
  4. Rectangle {
  5. id: root
  6. property string titleText: ""
  7. property string contentText: ""
  8. property string subContentText: ""
  9. property string iconSource: ""
  10. property int iconSize: 50
  11. property bool showSettingsIcon: false
  12. property var extraContent: []
  13. color: app.cardColor
  14. radius: 5
  15. Column {
  16. anchors.centerIn: parent
  17. spacing: 5
  18. // 图标
  19. AppImage {
  20. id: icon
  21. anchors.horizontalCenter: parent.horizontalCenter
  22. anchors.topMargin: 30
  23. width: root.iconSize
  24. height: root.iconSize
  25. source: root.iconSource
  26. fillMode: Image.PreserveAspectFit
  27. cache: true
  28. }
  29. // 标题
  30. AppText {
  31. id: title
  32. anchors.horizontalCenter: parent.horizontalCenter
  33. text: root.titleText
  34. color: app.fontColor
  35. font.bold: true
  36. fontSize: 16
  37. }
  38. // 主内容
  39. AppText {
  40. id: content
  41. anchors.horizontalCenter: parent.horizontalCenter
  42. text: root.contentText
  43. color: "gray"
  44. fontSize: 10
  45. }
  46. // 副内容
  47. AppText {
  48. anchors.horizontalCenter: parent.horizontalCenter
  49. text: root.subContentText
  50. color: "gray"
  51. fontSize: 10
  52. visible: root.subContentText !== ""
  53. }
  54. // 额外内容列表
  55. Repeater {
  56. model: root.extraContent.length
  57. AppText {
  58. anchors.horizontalCenter: parent.horizontalCenter
  59. text: root.extraContent[index].text
  60. color: root.extraContent[index].color
  61. fontSize: 10
  62. }
  63. }
  64. // 设置图标
  65. AppImage {
  66. id: settingsIcon
  67. anchors.horizontalCenter: parent.horizontalCenter
  68. anchors.topMargin: 5
  69. width: 30
  70. height: 30
  71. source: "../../assets/set.svg"
  72. fillMode: Image.PreserveAspectFit
  73. visible: root.showSettingsIcon
  74. }
  75. }
  76. }