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
|
2019-08-28 04:21:10 +10:00
|
|
|
opacity: loading ? theme.loadingElementsOpacity :
|
|
|
|
enabled ? 1 : theme.disabledElementsOpacity
|
2019-08-22 05:45:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
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 {} }
|
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:16:58 +11:00
|
|
|
Layout.preferredWidth: icon.width
|
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
|
|
|
|
svgName: button.icon.name
|
|
|
|
colorize: button.icon.color
|
|
|
|
// cache: button.icon.cache // TODO: need Qt 5.13+
|
2019-08-28 12:59:26 +10:00
|
|
|
|
2020-03-19 18:16:58 +11:00
|
|
|
width: svgName ? implicitWidth : 0
|
|
|
|
visible: width > 0
|
2019-08-28 12:59:26 +10:00
|
|
|
|
2020-03-19 18:16:58 +11:00
|
|
|
opacity: button.loading ? 0 : 1
|
2019-12-16 19:42:41 +11:00
|
|
|
|
2020-03-19 18:16:58 +11:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-08-28 04:11:33 +10:00
|
|
|
}
|
|
|
|
|
2020-03-19 18:16:58 +11:00
|
|
|
HBusyIndicator {
|
|
|
|
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
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
}
|