2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-09-14 13:01:10 +08:00
|
|
|
import QtQuick
|
2022-03-30 14:14:40 +08:00
|
|
|
|
|
|
|
Item {
|
2022-04-30 15:27:56 +08: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 14:14:40 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
signal clicked
|
2022-03-30 14:14:40 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
id: button
|
|
|
|
width: icon.width + title.implicitWidth + padding * 2
|
|
|
|
height: Math.max(icon.height, title.implicitHeight) + padding * 2
|
2022-03-30 14:14:40 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Rectangle {
|
|
|
|
id: bg
|
|
|
|
anchors.fill: parent
|
|
|
|
color: "black"
|
|
|
|
border.width: 2
|
|
|
|
border.color: "white"
|
|
|
|
opacity: 0.8
|
|
|
|
}
|
2022-03-30 14:14:40 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
states: [
|
|
|
|
State {
|
2023-03-18 15:34:42 +08:00
|
|
|
name: "hovered"; when: hover.hovered
|
2022-04-30 15:27:56 +08: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 14:14:40 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
]
|
2022-03-30 14:14:40 +08:00
|
|
|
|
2023-03-18 15:34:42 +08:00
|
|
|
TapHandler {
|
2022-04-30 15:27:56 +08:00
|
|
|
id: mouse
|
2023-12-06 21:07:35 +08:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.NoButton
|
|
|
|
gesturePolicy: TapHandler.WithinBounds
|
|
|
|
|
2023-03-18 15:34:42 +08:00
|
|
|
onTapped: if (parent.enabled) parent.clicked()
|
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: hover
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-03-30 14:14:40 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Row {
|
|
|
|
x: padding
|
|
|
|
y: padding
|
|
|
|
anchors.centerIn: parent
|
|
|
|
spacing: 5
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: icon
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
}
|
2022-03-30 14:14:40 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Text {
|
|
|
|
id: title
|
|
|
|
font.pixelSize: 18
|
|
|
|
// font.family: "WenQuanYi Micro Hei"
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
text: ""
|
|
|
|
color: "white"
|
2022-03-30 14:14:40 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-03-30 14:14:40 +08:00
|
|
|
}
|