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

96 lines
2.6 KiB
QML
Raw Normal View History

import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../Base"
2019-08-28 12:46:31 +10:00
Rectangle {
id: banner
2019-07-16 22:10:37 +10:00
implicitHeight: childrenRect.height
2019-08-28 12:46:31 +10:00
color: theme.controls.box.background
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-08-28 12:46:31 +10:00
Rectangle {
2019-07-16 22:10:37 +10:00
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
clientUserId: chatPage.userId
2019-07-16 22:10:37 +10:00
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-08-21 07:41:24 +10:00
HButton {
2019-07-16 22:10:37 +10:00
id: button
text: modelData.text
icon.name: modelData.iconName
2019-08-29 08:21:13 +10:00
icon.color: modelData.iconColor || theme.icons.colorize
2019-07-16 22:10:37 +10:00
onClicked: buttonCallbacks[modelData.name](button)
2019-07-16 22:10:37 +10:00
Layout.preferredHeight: theme.baseElementsHeight
}
}
}
2019-08-28 12:46:31 +10:00
Rectangle {
2019-07-16 22:10:37 +10:00
id: buttonsRightPadding
color: theme.controls.button.background
visible: bannerGrid.flow == GridLayout.TopToBottom
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}
}