moment/src/qml/Base/HButtonContent.qml

91 lines
2.2 KiB
QML
Raw Normal View History

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
Behavior on opacity { HNumberAnimation {} }
HIcon {
property bool loading: button.loading || false
id: icon
svgName: button.icon.name
2019-08-29 08:32:16 +10:00
colorize: enabled ? button.icon.color: theme.icons.disabledColorize
cache: button.icon.cache
onLoadingChanged: if (! loading) resetAnimations.start()
Layout.fillHeight: true
Layout.alignment: Qt.AlignCenter
2019-08-28 04:11:33 +10:00
ParallelAnimation {
id: resetAnimations
HNumberAnimation { target: icon; property: "opacity"; to: 1 }
HNumberAnimation { target: icon; property: "rotation"; to: 0 }
}
HNumberAnimation on opacity {
2019-08-28 04:11:33 +10:00
id: blink
from: 1
2019-08-28 05:00:50 +10:00
to: 0.5
2019-08-28 04:11:33 +10:00
factor: 2
running: button.loading || false
2019-08-28 05:00:50 +10:00
onFinished: { [from, to] = [to, from]; start() }
2019-08-28 04:11:33 +10:00
}
SequentialAnimation {
2019-08-28 05:00:50 +10:00
running: button.loading || false
2019-08-28 04:11:33 +10:00
loops: Animation.Infinite
HPauseAnimation { factor: blink.factor * 8 }
HNumberAnimation {
id: rotation1
target: icon
property: "rotation"
from: 0
to: 180
factor: blink.factor
}
HPauseAnimation { factor: blink.factor * 8 }
HNumberAnimation {
target: rotation1.target
property: rotation1.property
from: rotation1.to
to: 360
factor: rotation1.factor
}
}
}
HLabel {
id: label
text: button.text
visible: Boolean(text)
color: buttonTheme.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Layout.fillWidth: true
Layout.fillHeight: true
}
}