2016-04-04 16:33:08 +02:00
|
|
|
import QtQuick 2.0
|
|
|
|
|
2016-04-09 05:02:10 +02:00
|
|
|
Rectangle {
|
2016-04-04 16:33:08 +02:00
|
|
|
id: button
|
2016-04-09 05:02:10 +02:00
|
|
|
radius: 5
|
|
|
|
color: focus ? "#33000000" : "transparent"
|
|
|
|
width: 30
|
|
|
|
height: 30
|
2016-04-04 16:33:08 +02:00
|
|
|
property url normalImg: ""
|
|
|
|
property url hoverImg: normalImg
|
|
|
|
property url pressImg: normalImg
|
|
|
|
|
|
|
|
signal clicked()
|
2016-04-09 05:02:10 +02:00
|
|
|
signal enterPressed()
|
2016-04-04 16:33:08 +02:00
|
|
|
|
2016-04-09 05:02:10 +02:00
|
|
|
onNormalImgChanged: img.source = normalImg
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: img
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2016-04-09 04:19:59 +02:00
|
|
|
|
2016-04-04 16:33:08 +02:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
2016-04-09 05:02:10 +02:00
|
|
|
onEntered: img.source = hoverImg
|
|
|
|
onPressed: img.source = pressImg
|
|
|
|
onExited: img.source = normalImg
|
|
|
|
onReleased: img.source = normalImg
|
2016-04-04 16:33:08 +02:00
|
|
|
onClicked: button.clicked()
|
|
|
|
}
|
2016-04-09 05:02:10 +02:00
|
|
|
Component.onCompleted: {
|
|
|
|
img.source = normalImg
|
|
|
|
}
|
|
|
|
Keys.onPressed: {
|
2020-03-17 18:16:10 +01:00
|
|
|
if(event.key == Qt.Key_Return ||
|
|
|
|
event.key == Qt.Key_Enter) {
|
2016-04-09 05:02:10 +02:00
|
|
|
button.clicked()
|
|
|
|
button.enterPressed()
|
|
|
|
}
|
|
|
|
}
|
2016-04-04 16:33:08 +02:00
|
|
|
}
|