moment/src/qml/Chat/Banners/Banner.qml

93 lines
2.5 KiB
QML
Raw Normal View History

import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../Base"
HRectangle {
id: banner
2019-07-16 22:10:37 +10:00
implicitHeight: childrenRect.height
property alias avatar: bannerAvatar
property alias icon: bannerIcon
property alias labelText: bannerLabel.text
property alias buttonModel: bannerRepeater.model
property var buttonCallbacks: []
2019-07-16 22:10:37 +10:00
HGridLayout {
id: bannerGrid
width: parent.width
flow: bannerAvatarWrapper.width +
bannerIcon.width +
bannerLabel.implicitWidth +
bannerButtons.width >
parent.width ?
GridLayout.TopToBottom : GridLayout.LeftToRight
2019-07-16 22:10:37 +10:00
HRowLayout {
id: bannerRow
2019-07-16 22:10:37 +10:00
HRectangle {
id: bannerAvatarWrapper
color: "black"
2019-07-16 22:10:37 +10:00
Layout.preferredWidth: bannerAvatar.width
Layout.minimumHeight: bannerAvatar.height
Layout.preferredHeight: bannerLabel.height
2019-07-16 22:10:37 +10:00
HUserAvatar {
id: bannerAvatar
anchors.centerIn: parent
}
}
2019-07-16 22:10:37 +10:00
HIcon {
id: bannerIcon
dimension: bannerLabel.implicitHeight
visible: Boolean(svgName)
2019-07-16 22:10:37 +10:00
Layout.leftMargin: theme.spacing / 2
}
2019-07-16 22:10:37 +10:00
HLabel {
id: bannerLabel
textFormat: Text.StyledText
wrapMode: Text.Wrap
Layout.fillWidth: true
Layout.leftMargin: bannerIcon.Layout.leftMargin
Layout.rightMargin: Layout.leftMargin
}
HSpacer {}
}
HRowLayout {
2019-07-16 22:10:37 +10:00
HRowLayout {
id: bannerButtons
2019-07-16 22:10:37 +10:00
Repeater {
id: bannerRepeater
model: []
2019-07-16 22:10:37 +10:00
HUIButton {
id: button
text: modelData.text
iconName: modelData.iconName
onClicked: buttonCallbacks[modelData.name](button)
2019-07-16 22:10:37 +10:00
Layout.preferredHeight: theme.baseElementsHeight
}
}
}
2019-07-16 22:10:37 +10:00
HRectangle {
id: buttonsRightPadding
color: theme.controls.button.background
visible: bannerGrid.flow == GridLayout.TopToBottom
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}
}