summaryrefslogtreecommitdiffstats
path: root/QtDemo/qml/QtDemo/Button.qml
blob: f39ad8681f919e1f0be2c99193ae5bb40c622df4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import QtQuick 2.0

Item {
    id: root
    width: (app.height + app.width) * 0.04
    height: width

    property string imageSource : ""
    property double rotation: 0
    signal clicked()

    Image {
        id: buttonImage
        anchors.fill: root
        anchors.margins: 0
        source: root.imageSource
        opacity: 1.0
        rotation: root.rotation
    }

    MouseArea {
        id: buttonMouseArea
        anchors.fill: root
        anchors.margins: -20
        hoverEnabled: true
        onClicked: root.clicked()
        onEntered: buttonImage.anchors.margins = -(root.width * 0.1)
        onExited: buttonImage.anchors.margins = 0
        onPressed: {buttonImage.opacity = 0.7; buttonImage.anchors.margins = -(root.width * 0.1)}
        onReleased: { buttonImage.opacity = 1.0; buttonImage.anchors.margins = 0}
    }
}