summaryrefslogtreecommitdiffstats
path: root/src/gui/qml/TextImageButton.qml
blob: 3630029a44011737ad33e46c6d730f888ce398fe (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import QtQuick 1.1

Rectangle {
    id: backgroundRect
    width: 150
    height: 30
    radius: 0

    property alias image: img.source
    property alias text: text.text
    property alias color: backgroundRect.color
    signal clicked

    color: "red"
    z: 2

    Image {
        id: img
        width: height
        anchors.top: parent.top
        anchors.topMargin: 2
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 2
        anchors.left: parent.left
        anchors.leftMargin: 5
        smooth: true
        source: "qrc:/qtquickplugin/images/template_image.png"
    }

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

    Text {
        id: text
        text: "Button text"
        font.bold: true
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
        anchors.right: parent.right
        anchors.rightMargin: 0
        anchors.left: img.right
        anchors.leftMargin: 5
        anchors.top: parent.top
        anchors.topMargin: 0
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 0
        color: "white"
        font.pixelSize: 12
    }

    states: State {
        name: "pressed"; when: mouseArea.pressed
        PropertyChanges { target: backgroundRect; color: Qt.darker(color) }
    }
}