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