Warning, /education/marble/examples/cpp/marble-game/CustomButton.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2014 Abhinav Gangwar <abhgang@gmail.com> 0004 // 0005 0006 0007 import QtQuick 2.0 0008 import QtQuick.Controls 1.2 0009 import QtQuick.Controls.Styles 1.2 0010 0011 Rectangle { 0012 signal buttonClick() 0013 0014 property int buttonWidth: 150 0015 property int buttonHeight: 75 0016 property string labelText: qsTr("Button") 0017 property color labelColor: "black" 0018 property color normalColor: "lightblue" 0019 property color onHoverColor: "crimson" 0020 property color borderColor: "transparent" 0021 0022 property real labelSize: buttonWidth/10 0023 0024 id: button 0025 width: buttonWidth 0026 height: buttonHeight 0027 border.width: 1 0028 border.color: borderColor 0029 radius: 6 0030 smooth: true 0031 scale: clickArea.pressed ? 1.1 : 1.0 0032 color: clickArea.pressed ? Qt.darker( normalColor, 1.5 ) : normalColor 0033 0034 Behavior on color { ColorAnimation{ duration: 50 } } 0035 Behavior on scale { NumberAnimation{ duration: 50 } } 0036 0037 Text { 0038 id: buttonLabel 0039 0040 text: labelText 0041 color: labelColor 0042 font.pixelSize: labelSize 0043 width: parent.width 0044 horizontalAlignment: Text.AlignHCenter 0045 anchors.verticalCenter: parent.verticalCenter 0046 wrapMode: Text.WordWrap 0047 } 0048 0049 MouseArea { 0050 id: clickArea 0051 anchors.fill: parent 0052 hoverEnabled: true 0053 onClicked: { 0054 buttonClick() 0055 } 0056 onEntered: { 0057 button.border.color = onHoverColor 0058 button.border.width = 2 0059 } 0060 onExited: { 0061 button.border.color = borderColor 0062 button.border.width = 1 0063 } 0064 } 0065 }