SettingCard.qml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // 设置卡片组件
  2. import QtQuick
  3. import Felgo 4.0
  4. Rectangle {
  5. id: root
  6. property string title: ""
  7. property string subTitle: ""
  8. property string icon: ""
  9. property bool hasSwitch: false
  10. property bool switchChecked: false
  11. property bool showArrow: false
  12. property alias switchId: controlSwitch
  13. signal clicked()
  14. signal switchToggled(bool checked)
  15. color: app.cardColor
  16. radius: 5
  17. MouseArea {
  18. anchors.fill: parent
  19. onClicked: root.clicked()
  20. }
  21. Column {
  22. anchors.centerIn: parent
  23. spacing: 5
  24. // 图标
  25. AppImage {
  26. anchors.horizontalCenter: parent.horizontalCenter
  27. width: 50
  28. height: 50
  29. source: root.icon !== "" ? root.icon : ""
  30. fillMode: Image.PreserveAspectFit
  31. visible: root.icon !== ""
  32. }
  33. // 标题
  34. AppText {
  35. id: titleText
  36. anchors.horizontalCenter: parent.horizontalCenter
  37. text: root.title
  38. color: app.fontColor
  39. font.bold: true
  40. fontSize: 14
  41. }
  42. // 副标题
  43. AppText {
  44. anchors.horizontalCenter: parent.horizontalCenter
  45. text: root.subTitle
  46. color: "gray"
  47. fontSize: 10
  48. visible: root.subTitle !== ""
  49. }
  50. // 开关(如果有)
  51. AppSwitch {
  52. id: controlSwitch
  53. anchors.horizontalCenter: parent.horizontalCenter
  54. checked: root.switchChecked
  55. visible: root.hasSwitch
  56. onToggled: root.switchToggled(checked)
  57. }
  58. // 箭头指示
  59. AppText {
  60. anchors.horizontalCenter: parent.horizontalCenter
  61. text: ">"
  62. color: "gray"
  63. fontSize: 16
  64. visible: root.showArrow && !root.hasSwitch
  65. }
  66. }
  67. }