2019-12-19 22:46:16 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-08-22 05:45:13 +10:00
|
|
|
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
|
2019-08-22 05:45:13 +10:00
|
|
|
spacing: button.spacing
|
2020-07-10 17:47:37 +10:00
|
|
|
opacity: button.loading ? theme.loadingElementsOpacity :
|
2019-08-28 04:21:10 +10:00
|
|
|
enabled ? 1 : theme.disabledElementsOpacity
|
2019-08-22 05:45:13 +10:00
|
|
|
|
|
|
|
|
2020-03-28 01:36:50 +11:00
|
|
|
property var button
|
2019-08-22 05:45:13 +10:00
|
|
|
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 {} }
|
2019-08-22 05:45:13 +10:00
|
|
|
|
|
|
|
|
2020-03-19 18:16:58 +11:00
|
|
|
Item {
|
|
|
|
visible: button.icon.name || button.loading
|
2019-12-16 19:42:41 +11:00
|
|
|
|
2020-03-19 18:52:00 +11:00
|
|
|
Layout.preferredWidth:
|
2020-03-24 05:04:00 +11:00
|
|
|
button.loading ? busyIndicatorLoader.width : icon.width
|
2020-07-12 07:55:05 +10:00
|
|
|
Layout.preferredHeight:
|
|
|
|
button.loading ? busyIndicatorLoader.height : icon.height
|
2020-03-19 18:52:00 +11:00
|
|
|
|
2019-12-16 19:42:41 +11:00
|
|
|
Layout.fillHeight: true
|
2019-12-02 19:40:01 +11:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
2019-12-16 19:42:41 +11:00
|
|
|
|
2020-03-19 18:16:58 +11:00
|
|
|
HIcon {
|
|
|
|
id: icon
|
2020-03-20 02:11:58 +11:00
|
|
|
anchors.centerIn: parent
|
2020-03-19 18:16:58 +11:00
|
|
|
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+
|
|
|
|
|
2020-03-19 18:16:58 +11:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-08-28 04:11:33 +10:00
|
|
|
}
|
|
|
|
|
2020-03-24 05:04:00 +11:00
|
|
|
HLoader {
|
|
|
|
id: busyIndicatorLoader
|
2020-03-20 02:11:58 +11:00
|
|
|
anchors.centerIn: parent
|
2020-03-19 18:16:58 +11:00
|
|
|
width: height
|
|
|
|
height: parent.height
|
|
|
|
opacity: button.loading ? 1 : 0
|
2020-05-11 05:29:18 +10:00
|
|
|
|
2020-03-24 05:04:00 +11:00
|
|
|
active: opacity > 0
|
2020-05-11 05:29:18 +10:00
|
|
|
sourceComponent: HBusyIndicator {}
|
2020-03-19 18:16:58 +11:00
|
|
|
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-08-28 04:11:33 +10:00
|
|
|
}
|
2019-08-22 05:45:13 +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
|
2019-08-22 05:45:13 +10:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
}
|