| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- // 设置卡片组件
- import QtQuick
- import Felgo 4.0
- Rectangle {
- id: root
- property string title: ""
- property string subTitle: ""
- property string icon: ""
- property bool hasSwitch: false
- property bool switchChecked: false
- property bool showArrow: false
- property alias switchId: controlSwitch
- signal clicked()
- signal switchToggled(bool checked)
- color: app.cardColor
- radius: 5
- MouseArea {
- anchors.fill: parent
- onClicked: root.clicked()
- }
- Column {
- anchors.centerIn: parent
- spacing: 5
- // 图标
- AppImage {
- anchors.horizontalCenter: parent.horizontalCenter
- width: 50
- height: 50
- source: root.icon !== "" ? root.icon : ""
- fillMode: Image.PreserveAspectFit
- visible: root.icon !== ""
- }
- // 标题
- AppText {
- id: titleText
- anchors.horizontalCenter: parent.horizontalCenter
- text: root.title
- color: app.fontColor
- font.bold: true
- fontSize: 14
- }
- // 副标题
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: root.subTitle
- color: "gray"
- fontSize: 10
- visible: root.subTitle !== ""
- }
- // 开关(如果有)
- AppSwitch {
- id: controlSwitch
- anchors.horizontalCenter: parent.horizontalCenter
- checked: root.switchChecked
- visible: root.hasSwitch
- onToggled: root.switchToggled(checked)
- }
- // 箭头指示
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: ">"
- color: "gray"
- fontSize: 16
- visible: root.showArrow && !root.hasSwitch
- }
- }
- }
|