summaryrefslogtreecommitdiffstats
path: root/examples/declarative/toys/dynamic/qml/Button.qml
blob: 963a8503d624e4b98b6753c99a28dff3ad6c6478 (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
33
34
35
36
37
38
39
40
import Qt 4.7

Rectangle {
    id: container

    property variant text
    signal clicked

    height: text.height + 10; width: text.width + 20
    border.width: 1
    radius: 4
    smooth: true

    gradient: Gradient {
        GradientStop {
            position: 0.0
            color: !mouseArea.pressed ? activePalette.light : activePalette.button
        }
        GradientStop {
            position: 1.0
            color: !mouseArea.pressed ? activePalette.button : activePalette.dark
        }
    }

    SystemPalette { id: activePalette }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        onClicked: container.clicked()
    }

    Text {
        id: text
        anchors.centerIn:parent
        font.pointSize: 10
        text: parent.text
        color: activePalette.buttonText
    }
}