moment/src/gui/Base/HButtonContent.qml

73 lines
1.7 KiB
QML
Raw Normal View History

2019-12-19 22:46:16 +11:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
HRowLayout {
2019-08-28 05:00:50 +10:00
id: buttonContent
spacing: button.spacing
2019-08-28 04:21:10 +10:00
opacity: loading ? theme.loadingElementsOpacity :
enabled ? 1 : theme.disabledElementsOpacity
property AbstractButton button
property QtObject buttonTheme
readonly property alias icon: icon
readonly property alias label: label
2019-12-16 19:42:41 +11:00
Behavior on opacity { HNumberAnimation {} }
Item {
visible: button.icon.name || button.loading
2019-12-16 19:42:41 +11:00
Layout.preferredWidth:
button.loading ? busyIndicator.width : icon.width
2019-12-16 19:42:41 +11:00
Layout.fillHeight: true
Layout.alignment: Qt.AlignCenter
2019-12-16 19:42:41 +11:00
HIcon {
id: icon
2020-03-20 02:11:58 +11:00
anchors.centerIn: parent
width: svgName ? implicitWidth : 0
visible: width > 0
opacity: button.loading ? 0 : 1
2019-12-16 19:42:41 +11:00
2020-03-20 02:11:58 +11:00
colorize: button.icon.color
svgName: button.icon.name
// cache: button.icon.cache // TODO: need Qt 5.13+
Behavior on opacity { HNumberAnimation {} }
2019-08-28 04:11:33 +10:00
}
HBusyIndicator {
id: busyIndicator
2020-03-20 02:11:58 +11:00
anchors.centerIn: parent
width: height
height: parent.height
opacity: button.loading ? 1 : 0
visible: opacity > 0
Behavior on opacity { HNumberAnimation {} }
2019-08-28 04:11:33 +10:00
}
}
HLabel {
id: label
text: button.text
visible: Boolean(text)
color: buttonTheme.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
2019-09-10 01:20:59 +10:00
elide: Text.ElideRight
Layout.fillWidth: true
Layout.fillHeight: true
}
}