107 lines
3.0 KiB
QML
Raw Normal View History

// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
2019-12-19 07:46:16 -04:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
2019-12-18 04:53:08 -04:00
import "../../../Base"
2019-08-27 22:46:31 -04:00
Rectangle {
id: banner
property alias avatar: bannerAvatar
property alias icon: bannerIcon
property alias labelText: bannerLabel.text
property alias buttonModel: bannerRepeater.model
property var buttonCallbacks: []
implicitHeight: childrenRect.height
color: theme.controls.box.background
2019-07-16 08:10:37 -04: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 08:10:37 -04:00
HRowLayout {
id: bannerRow
2019-08-27 22:46:31 -04:00
Rectangle {
2019-07-16 08:10:37 -04:00
id: bannerAvatarWrapper
color: "black"
2019-07-16 08:10:37 -04:00
Layout.preferredWidth: bannerAvatar.width
Layout.minimumHeight: bannerAvatar.height
Layout.preferredHeight: bannerLabel.height
2019-07-16 08:10:37 -04:00
HUserAvatar {
id: bannerAvatar
clientUserId: chat.userId
2019-07-16 08:10:37 -04:00
anchors.centerIn: parent
2020-03-26 21:59:33 -04:00
radius: 0
2019-07-16 08:10:37 -04:00
}
}
2019-07-16 08:10:37 -04:00
HIcon {
id: bannerIcon
visible: Boolean(svgName)
2019-07-16 08:10:37 -04:00
Layout.leftMargin: theme.spacing / 2
}
2019-07-16 08:10:37 -04:00
HLabel {
id: bannerLabel
textFormat: Text.StyledText
wrapMode: HLabel.Wrap
2019-07-16 08:10:37 -04:00
Layout.fillWidth: true
Layout.leftMargin: bannerIcon.Layout.leftMargin
Layout.rightMargin: Layout.leftMargin
}
HSpacer {}
}
HRowLayout {
2019-07-16 08:10:37 -04:00
HRowLayout {
id: bannerButtons
2019-07-16 08:10:37 -04:00
Repeater {
id: bannerRepeater
model: []
2019-08-20 17:41:24 -04:00
HButton {
2019-07-16 08:10:37 -04:00
id: button
readonly property bool shouldFocus:
banner.visible && model.index === 0
2019-07-16 08:10:37 -04:00
text: modelData.text
icon.name: modelData.iconName
2019-08-28 18:21:13 -04:00
icon.color: modelData.iconColor || theme.icons.colorize
2019-07-16 08:10:37 -04:00
onClicked: buttonCallbacks[modelData.name](button)
2019-07-16 08:10:37 -04:00
Layout.preferredHeight: theme.baseElementsHeight
onShouldFocusChanged:
if (shouldFocus) forceActiveFocus()
2019-07-16 08:10:37 -04:00
}
}
}
2019-08-27 22:46:31 -04:00
Rectangle {
2019-07-16 08:10:37 -04:00
id: buttonsRightPadding
color: theme.controls.button.background
2019-12-09 11:35:50 -04:00
visible: bannerGrid.flow === GridLayout.TopToBottom
2019-07-16 08:10:37 -04:00
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}
}