2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2012-02-02 23:28:00 +00:00
|
|
|
|
2018-10-03 09:19:27 +00:00
|
|
|
import QtQuick 2.12
|
2013-07-23 09:19:33 +00:00
|
|
|
import QtQuick.Window 2.1
|
2012-02-02 23:28:00 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: container
|
|
|
|
|
2013-03-08 15:44:32 +00:00
|
|
|
property alias text: buttonLabel.text
|
|
|
|
property alias label: buttonLabel
|
2012-02-02 23:28:00 +00:00
|
|
|
signal clicked
|
2018-10-03 09:19:27 +00:00
|
|
|
property alias containsMouse: hoverHandler.hovered
|
|
|
|
property alias pressed: tapHandler.pressed
|
2013-10-25 14:53:55 +00:00
|
|
|
implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2)
|
|
|
|
implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3)
|
2013-04-18 10:30:20 +00:00
|
|
|
height: implicitHeight
|
|
|
|
width: implicitWidth
|
2013-03-08 15:44:32 +00:00
|
|
|
|
|
|
|
SystemPalette { id: palette }
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: frame
|
|
|
|
anchors.fill: parent
|
|
|
|
color: palette.button
|
|
|
|
gradient: Gradient {
|
2018-10-03 09:19:27 +00:00
|
|
|
GradientStop { position: 0.0; color: tapHandler.pressed ? Qt.darker(palette.button, 1.3) : palette.button }
|
2013-03-08 15:44:32 +00:00
|
|
|
GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) }
|
|
|
|
}
|
|
|
|
antialiasing: true
|
2013-07-23 09:19:33 +00:00
|
|
|
radius: height / 6
|
2013-03-08 15:44:32 +00:00
|
|
|
border.color: Qt.darker(palette.button, 1.5)
|
|
|
|
border.width: 1
|
|
|
|
}
|
2012-02-02 23:28:00 +00:00
|
|
|
|
2018-10-03 09:19:27 +00:00
|
|
|
TapHandler {
|
|
|
|
id: tapHandler
|
|
|
|
onTapped: container.clicked();
|
|
|
|
}
|
|
|
|
HoverHandler {
|
|
|
|
id: hoverHandler
|
2013-01-15 16:10:57 +00:00
|
|
|
}
|
2012-02-02 23:28:00 +00:00
|
|
|
|
2013-03-08 15:44:32 +00:00
|
|
|
Text {
|
|
|
|
id: buttonLabel
|
|
|
|
text: container.text
|
|
|
|
color: palette.buttonText
|
2013-04-18 10:30:20 +00:00
|
|
|
anchors.centerIn: parent
|
2012-02-02 23:28:00 +00:00
|
|
|
}
|
|
|
|
}
|