justcheckers/MenuButton.qml

57 lines
1.2 KiB
QML

import QtQuick 2.0
import QtGraphicalEffects 1.0
Rectangle {
id: button
property color backgroundAtRest: "#9e9e9e"
property color backgroundActive: "#555555"
property string buttonText: "Button"
property bool enabled: true
function actionOnClick() { }
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 50
height: parent.parent.height * 0.1
radius: 10
color: {
if (enabled)
backgroundActive
else
backgroundAtRest
}
border.color: "#333333"
border.width: 2
antialiasing: true
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 5
verticalOffset: 5
radius: 5.0
samples: 5
}
Text {
text: buttonText
font.pointSize: parent.height * 0.2
font.bold: true
height: 30
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
MouseArea {
anchors.fill: parent
onPressed: button.color = backgroundActive
onReleased: button.color = backgroundAtRest
onClicked: actionOnClick()
}
}