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 60 61 62 63 64 65 66 67 68 69 70
|
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2014 Abhinav Gangwar <abhgang@gmail.com>
//
import QtQuick 2.0
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
Rectangle {
signal buttonClick()
property int buttonWidth: 150
property int buttonHeight: 75
property string labelText: qsTr("Button")
property color labelColor: "black"
property color normalColor: "lightblue"
property color onHoverColor: "crimson"
property color borderColor: "transparent"
property real labelSize: buttonWidth/10
id: button
width: buttonWidth
height: buttonHeight
border.width: 1
border.color: borderColor
radius: 6
smooth: true
scale: clickArea.pressed ? 1.1 : 1.0
color: clickArea.pressed ? Qt.darker( normalColor, 1.5 ) : normalColor
Behavior on color { ColorAnimation{ duration: 50 } }
Behavior on scale { NumberAnimation{ duration: 50 } }
Text {
id: buttonLabel
text: labelText
color: labelColor
font.pixelSize: labelSize
width: parent.width
horizontalAlignment: Text.AlignHCenter
anchors.verticalCenter: parent.verticalCenter
wrapMode: Text.WordWrap
}
MouseArea {
id: clickArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
buttonClick()
}
onEntered: {
button.border.color = onHoverColor
button.border.width = 2
}
onExited: {
button.border.color = borderColor
button.border.width = 1
}
}
}
|