2022-09-14 05:01:10 +00:00
|
|
|
import QtQuick
|
2022-03-30 06:14:40 +00:00
|
|
|
|
|
|
|
Item {
|
2022-04-30 07:27:56 +00:00
|
|
|
property bool enabled: true
|
|
|
|
property alias text: title.text
|
|
|
|
property alias textColor: title.color
|
|
|
|
property alias textFont: title.font
|
|
|
|
property alias backgroundColor: bg.color
|
|
|
|
property alias border: bg.border
|
|
|
|
property alias iconSource: icon.source
|
|
|
|
property int padding: 5
|
2022-03-30 06:14:40 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
signal clicked
|
2022-03-30 06:14:40 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
id: button
|
|
|
|
width: icon.width + title.implicitWidth + padding * 2
|
|
|
|
height: Math.max(icon.height, title.implicitHeight) + padding * 2
|
2022-03-30 06:14:40 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Rectangle {
|
|
|
|
id: bg
|
|
|
|
anchors.fill: parent
|
|
|
|
color: "black"
|
|
|
|
border.width: 2
|
|
|
|
border.color: "white"
|
|
|
|
opacity: 0.8
|
|
|
|
}
|
2022-03-30 06:14:40 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
states: [
|
|
|
|
State {
|
2023-03-18 07:34:42 +00:00
|
|
|
name: "hovered"; when: hover.hovered
|
2022-04-30 07:27:56 +00:00
|
|
|
PropertyChanges { target: bg; color: "white" }
|
|
|
|
PropertyChanges { target: title; color: "black" }
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "disabled"; when: !enabled
|
|
|
|
PropertyChanges { target: button; opacity: 0.2 }
|
2022-03-30 06:14:40 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
]
|
2022-03-30 06:14:40 +00:00
|
|
|
|
2023-03-18 07:34:42 +00:00
|
|
|
TapHandler {
|
2022-04-30 07:27:56 +00:00
|
|
|
id: mouse
|
2023-03-18 07:34:42 +00:00
|
|
|
onTapped: if (parent.enabled) parent.clicked()
|
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: hover
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-03-30 06:14:40 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Row {
|
|
|
|
x: padding
|
|
|
|
y: padding
|
|
|
|
anchors.centerIn: parent
|
|
|
|
spacing: 5
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: icon
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
}
|
2022-03-30 06:14:40 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Text {
|
|
|
|
id: title
|
|
|
|
font.pixelSize: 18
|
|
|
|
// font.family: "WenQuanYi Micro Hei"
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
text: ""
|
|
|
|
color: "white"
|
2022-03-30 06:14:40 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-03-30 06:14:40 +00:00
|
|
|
}
|
|
|
|
|