2017-08-30 23:29:46 +00:00
|
|
|
import QtQuick 2.5
|
2017-08-29 14:28:33 +00:00
|
|
|
import QtQuick.Controls 2.1
|
2017-08-29 05:02:56 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: img
|
|
|
|
property var onClicked: function () {}
|
2019-05-20 07:25:00 +00:00
|
|
|
property int roundness: 0
|
2019-05-05 12:47:35 +00:00
|
|
|
property int animationDuration: 500
|
2017-08-29 05:02:56 +00:00
|
|
|
|
|
|
|
fillMode: Image.Pad
|
|
|
|
horizontalAlignment: Image.AlignHCenter
|
|
|
|
verticalAlignment: Image.AlignVCenter
|
|
|
|
opacity: 0.3
|
|
|
|
smooth: true
|
|
|
|
|
|
|
|
states: State {
|
|
|
|
name: "mouse-over"
|
|
|
|
when: mouseArea.containsMouse
|
|
|
|
PropertyChanges {
|
|
|
|
target: img
|
|
|
|
opacity: 1.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
transitions: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
properties: "opacity"
|
|
|
|
easing.type: Easing.InOutQuad
|
2019-05-05 12:47:35 +00:00
|
|
|
duration: animationDuration
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
2017-08-30 23:29:46 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2017-08-29 05:02:56 +00:00
|
|
|
|
|
|
|
onClicked: parent.onClicked()
|
|
|
|
}
|
|
|
|
|
2019-05-20 07:25:00 +00:00
|
|
|
layer.enabled: roundness > 0
|
2017-08-29 05:02:56 +00:00
|
|
|
layer.effect: OpacityMask {
|
|
|
|
maskSource: Item {
|
|
|
|
width: img.width
|
|
|
|
height: img.height
|
|
|
|
Rectangle {
|
2019-05-20 07:25:00 +00:00
|
|
|
anchors.fill: parent
|
2017-08-29 05:02:56 +00:00
|
|
|
radius: roundness
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|