2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-12-07 06:48:22 +00:00
|
|
|
|
2022-08-31 07:59:05 +00:00
|
|
|
import QtQuick
|
2011-12-07 06:48:22 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: button
|
|
|
|
|
2012-02-20 00:34:44 +00:00
|
|
|
property bool checked: false
|
2011-12-07 06:48:22 +00:00
|
|
|
property alias text : buttonText.text
|
2012-04-20 11:01:04 +00:00
|
|
|
//! [button]
|
2011-12-07 06:48:22 +00:00
|
|
|
Accessible.name: text
|
|
|
|
Accessible.description: "This button does " + text
|
|
|
|
Accessible.role: Accessible.Button
|
2014-10-15 11:58:34 +00:00
|
|
|
Accessible.onPressAction: {
|
2012-01-10 11:12:51 +00:00
|
|
|
button.clicked()
|
|
|
|
}
|
2012-04-20 11:01:04 +00:00
|
|
|
//! [button]
|
2011-12-07 06:48:22 +00:00
|
|
|
|
|
|
|
signal clicked
|
|
|
|
|
|
|
|
width: buttonText.width + 20
|
|
|
|
height: 30
|
|
|
|
gradient: Gradient {
|
|
|
|
GradientStop { position: 0.0; color: "lightsteelblue" }
|
2012-12-11 19:05:04 +00:00
|
|
|
GradientStop { position: 1.0;
|
|
|
|
color: button.focus ? "red" : "blue" }
|
2011-12-07 06:48:22 +00:00
|
|
|
}
|
2013-01-21 14:53:47 +00:00
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
radius: 5
|
2012-07-18 03:53:40 +00:00
|
|
|
antialiasing: true
|
2011-12-07 06:48:22 +00:00
|
|
|
|
|
|
|
Text {
|
|
|
|
id: buttonText
|
|
|
|
anchors.centerIn: parent
|
|
|
|
font.pixelSize: parent.height * .5
|
2012-12-11 19:05:04 +00:00
|
|
|
style: Text.Sunken
|
|
|
|
color: "white"
|
|
|
|
styleColor: "black"
|
2011-12-07 06:48:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
anchors.fill: parent
|
2012-12-11 19:05:04 +00:00
|
|
|
onClicked: parent.clicked()
|
2011-12-07 06:48:22 +00:00
|
|
|
}
|
2013-01-21 14:53:47 +00:00
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
Keys.onSpacePressed: clicked()
|
2011-12-07 06:48:22 +00:00
|
|
|
}
|