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
|
2019-08-21 18:39:07 +10:00
|
|
|
spacing: theme.spacing
|
|
|
|
leftPadding: spacing / 1.5
|
|
|
|
rightPadding: spacing / 1.5
|
|
|
|
topPadding: spacing / 2
|
|
|
|
bottomPadding: spacing / 2
|
2019-08-21 08:31:20 +10:00
|
|
|
opacity: enabled ? 1 : theme.disabledElementsOpacity
|
2019-08-21 07:41:24 +10:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2019-08-21 08:31:20 +10:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
|
|
|
|
|
2019-08-21 07:41:24 +10:00
|
|
|
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
|
|
|
|
svgName: loading ? "hourglass" : iconName
|
2019-08-21 18:43:37 +10:00
|
|
|
|
|
|
|
Layout.fillHeight: true
|
2019-08-21 07:41:24 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
id: label
|
|
|
|
text: button.text
|
|
|
|
visible: Boolean(text)
|
|
|
|
color: theme.controls.button.text
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2019-08-21 18:43:37 +10:00
|
|
|
Layout.fillHeight: true
|
2019-08-21 07:41:24 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|