moment/src/gui/Base/HLabeledItem.qml

90 lines
2.0 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.Layouts 1.12
HColumnLayout {
2019-07-16 19:29:47 +10:00
spacing: theme.spacing / 2
default property alias insideData: itemHolder.data
2020-06-25 23:46:26 +10:00
property bool loading: false
readonly property Item item: itemHolder.children[0]
readonly property alias label: label
readonly property alias errorLabel: errorLabel
readonly property alias toolTip: toolTip
HRowLayout {
2020-06-25 23:46:26 +10:00
spacing: theme.spacing
HLabel {
id: label
opacity: item.opacity
wrapMode: Text.Wrap
Layout.fillWidth: true
}
HIcon {
svgName: "field-tooltip-available"
opacity: item.opacity
visible: toolTip.text
Binding on colorize {
value: theme.colors.accentElement
when: hoverHandler.hovered || toolTip.visible
}
}
HoverHandler {
id: hoverHandler
enabled: toolTip.text
}
TapHandler {
onTapped: toolTip.instantShow()
enabled: toolTip.text
}
HToolTip {
id: toolTip
visible: toolTip.text && hoverHandler.hovered
}
2020-06-25 23:46:26 +10:00
HLoader {
source: "HBusyIndicator.qml"
active: loading
visible: height > 0
Layout.preferredWidth: height
Layout.preferredHeight: active ? label.height : 0
Behavior on Layout.preferredHeight { HNumberAnimation {} }
}
}
Item {
id: itemHolder
// implicitWidth: childrenRect.width
implicitHeight: childrenRect.height
Layout.fillWidth: true
}
HLabel {
id: errorLabel
opacity: item.opacity
visible: Layout.maximumHeight > 0
wrapMode: Text.Wrap
color: theme.colors.errorText
Layout.maximumHeight: text ? implicitHeight : 0
Layout.fillWidth: true
Behavior on Layout.maximumHeight { HNumberAnimation {} }
}
}