diff options
Diffstat (limited to 'src/gui/qml/TextImageButton.qml')
-rw-r--r-- | src/gui/qml/TextImageButton.qml | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/gui/qml/TextImageButton.qml b/src/gui/qml/TextImageButton.qml new file mode 100644 index 0000000..3630029 --- /dev/null +++ b/src/gui/qml/TextImageButton.qml @@ -0,0 +1,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) } + } +} + |