2019-08-21 07:41:24 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: button
|
|
|
|
opacity: enabled ? 1 : theme.controls.button.disabledOpacity
|
|
|
|
onVisibleChanged: if (! visible) loading = false
|
|
|
|
|
|
|
|
|
|
|
|
readonly property alias ico: ico
|
|
|
|
readonly property alias label: label
|
|
|
|
|
|
|
|
property string iconName: ""
|
|
|
|
property color backgroundColor: theme.controls.button.background
|
|
|
|
property bool loading: false
|
|
|
|
property bool circle: false
|
|
|
|
|
|
|
|
|
|
|
|
background: HRectangle {
|
|
|
|
radius: circle ? height : 0
|
|
|
|
color: backgroundColor
|
|
|
|
|
|
|
|
HRectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
radius: parent.radius
|
|
|
|
color: button.checked ?
|
|
|
|
theme.controls.button.checkedOverlay :
|
|
|
|
|
|
|
|
button.enabled && button.pressed ?
|
|
|
|
theme.controls.button.pressedOverlay :
|
|
|
|
|
2019-08-21 07:43:59 +10:00
|
|
|
(button.enabled && button.hovered) || button.visualFocus ?
|
2019-08-21 07:41:24 +10:00
|
|
|
theme.controls.button.hoveredOverlay :
|
|
|
|
|
|
|
|
"transparent"
|
|
|
|
|
|
|
|
Behavior on color { HColorAnimation { factor: 0.5 } }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: HRowLayout {
|
|
|
|
spacing: button.spacing
|
|
|
|
|
|
|
|
HIcon {
|
|
|
|
id: ico
|
|
|
|
x: button.leftPadding
|
|
|
|
y: button.topPadding + button.availableHeight / 2 - height / 2
|
|
|
|
svgName: loading ? "hourglass" : iconName
|
|
|
|
}
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
id: label
|
|
|
|
text: button.text
|
|
|
|
visible: Boolean(text)
|
|
|
|
color: theme.controls.button.text
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|