2020-09-23 19:57:54 -04:00
|
|
|
// 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
|
|
|
|
|
2019-07-13 05:39:01 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-12-18 04:53:08 -04:00
|
|
|
import "../../../Base"
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2019-08-27 22:46:31 -04:00
|
|
|
Rectangle {
|
2019-04-21 15:20:20 -04:00
|
|
|
id: banner
|
|
|
|
|
2019-05-08 13:45:25 -04:00
|
|
|
property alias avatar: bannerAvatar
|
|
|
|
property alias icon: bannerIcon
|
2019-04-21 15:20:20 -04:00
|
|
|
property alias labelText: bannerLabel.text
|
|
|
|
property alias buttonModel: bannerRepeater.model
|
2019-04-28 14:20:30 -04:00
|
|
|
property var buttonCallbacks: []
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2020-07-12 00:25:57 -04:00
|
|
|
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-04-21 15:20:20 -04:00
|
|
|
|
2019-07-16 08:10:37 -04:00
|
|
|
HRowLayout {
|
|
|
|
id: bannerRow
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2019-08-27 22:46:31 -04:00
|
|
|
Rectangle {
|
2019-07-16 08:10:37 -04:00
|
|
|
id: bannerAvatarWrapper
|
|
|
|
color: "black"
|
2019-05-08 13:45:25 -04:00
|
|
|
|
2019-07-16 08:10:37 -04:00
|
|
|
Layout.preferredWidth: bannerAvatar.width
|
|
|
|
Layout.minimumHeight: bannerAvatar.height
|
|
|
|
Layout.preferredHeight: bannerLabel.height
|
2019-05-08 13:45:25 -04:00
|
|
|
|
2019-07-16 08:10:37 -04:00
|
|
|
HUserAvatar {
|
|
|
|
id: bannerAvatar
|
2020-08-23 16:57:53 -04:00
|
|
|
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-04-21 15:20:20 -04:00
|
|
|
|
2019-07-16 08:10:37 -04:00
|
|
|
HIcon {
|
|
|
|
id: bannerIcon
|
|
|
|
visible: Boolean(svgName)
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2019-07-16 08:10:37 -04:00
|
|
|
Layout.leftMargin: theme.spacing / 2
|
|
|
|
}
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2019-07-16 08:10:37 -04:00
|
|
|
HLabel {
|
|
|
|
id: bannerLabel
|
|
|
|
textFormat: Text.StyledText
|
2020-07-17 01:45:02 -04:00
|
|
|
wrapMode: HLabel.Wrap
|
2019-07-16 08:10:37 -04:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: bannerIcon.Layout.leftMargin
|
|
|
|
Layout.rightMargin: Layout.leftMargin
|
|
|
|
}
|
|
|
|
|
|
|
|
HSpacer {}
|
|
|
|
}
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2019-04-28 15:18:36 -04:00
|
|
|
HRowLayout {
|
2019-07-16 08:10:37 -04:00
|
|
|
HRowLayout {
|
|
|
|
id: bannerButtons
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2019-07-16 08:10:37 -04:00
|
|
|
Repeater {
|
|
|
|
id: bannerRepeater
|
|
|
|
model: []
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2019-08-20 17:41:24 -04:00
|
|
|
HButton {
|
2019-07-16 08:10:37 -04:00
|
|
|
id: button
|
2020-08-28 07:40:48 -04:00
|
|
|
|
|
|
|
readonly property bool shouldFocus:
|
|
|
|
banner.visible && model.index === 0
|
|
|
|
|
2019-07-16 08:10:37 -04:00
|
|
|
text: modelData.text
|
2019-08-21 15:45:13 -04:00
|
|
|
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-04-21 15:20:20 -04:00
|
|
|
|
2019-07-16 08:10:37 -04:00
|
|
|
Layout.preferredHeight: theme.baseElementsHeight
|
2020-08-28 07:40:48 -04:00
|
|
|
|
|
|
|
onShouldFocusChanged:
|
|
|
|
if (shouldFocus) forceActiveFocus()
|
2019-07-16 08:10:37 -04:00
|
|
|
}
|
|
|
|
}
|
2019-04-21 15:20:20 -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
|
2019-04-21 15:20:20 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|